summaryrefslogtreecommitdiffstats
path: root/sys/dev/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci/pci.c')
-rw-r--r--sys/dev/pci/pci.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 8343181..fbe9abd 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -161,6 +161,7 @@ static device_method_t pci_methods[] = {
DEVMETHOD(bus_release_resource, pci_release_resource),
DEVMETHOD(bus_activate_resource, pci_activate_resource),
DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource),
+ DEVMETHOD(bus_child_deleted, pci_child_deleted),
DEVMETHOD(bus_child_detached, pci_child_detached),
DEVMETHOD(bus_child_pnpinfo_str, pci_child_pnpinfo_str_method),
DEVMETHOD(bus_child_location_str, pci_child_location_str_method),
@@ -5194,7 +5195,7 @@ pci_deactivate_resource(device_t dev, device_t child, int type,
}
void
-pci_delete_child(device_t dev, device_t child)
+pci_child_deleted(device_t dev, device_t child)
{
struct resource_list_entry *rle;
struct resource_list *rl;
@@ -5203,12 +5204,13 @@ pci_delete_child(device_t dev, device_t child)
dinfo = device_get_ivars(child);
rl = &dinfo->resources;
- if (device_is_attached(child))
- device_detach(child);
-
/* Turn off access to resources we're about to free */
- pci_write_config(child, PCIR_COMMAND, pci_read_config(child,
- PCIR_COMMAND, 2) & ~(PCIM_CMD_MEMEN | PCIM_CMD_PORTEN), 2);
+ if (bus_child_present(child) != 0) {
+ pci_write_config(child, PCIR_COMMAND, pci_read_config(child,
+ PCIR_COMMAND, 2) & ~(PCIM_CMD_MEMEN | PCIM_CMD_PORTEN), 2);
+
+ pci_disable_busmaster(child);
+ }
/* Free all allocated resources */
STAILQ_FOREACH(rle, rl, link) {
@@ -5229,7 +5231,6 @@ pci_delete_child(device_t dev, device_t child)
}
resource_list_free(rl);
- device_delete_child(dev, child);
pci_freecfg(dinfo);
}
OpenPOWER on IntegriCloud