PCI: Only call pci_stop_bus_device() one time for children devices during removing
PATCH 1/1 PCI: Only call pci_stop_bus_device() one time for children devices during removing
During debugging pcie hotplug with SRIOV with pcie switch, found pci_stop_bus_device() are called several times for some children devices.
Current pci_remove_bus_device() will call pci_stop_bus_device() at first. and then use remove_behind_bridge() to call pci_stop_bus_device() for children devices. But pci_stop_bus_device() already include depth first to stop children. So We can remove unnecessary calling in pci_remove_behind_bridge() for children.
The patch change original pci_remove_bus_device() to __pci_remove_bus_device(), and it only do remove work, and new pci_remove_bus_device will call pci_stop_bus_device() one time, and then call __pci_remove_bus_device().
--- drivers/pci/remove.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/pci/remove.c +7 -3
@@ -89,9 +89,8 @@ EXPORT_SYMBOL(pci_remove_bus);* device lists, remove the /proc entry, and notify userspace * (/sbin/hotplug). */ -void pci_remove_bus_device (struct pci_dev *dev) +static void __pci_remove_bus_device (struct pci_dev *dev) { -pci_stop_bus_device (dev);if (dev->subordinate) {struct pci_bus *b = dev->subordinate;
@@ -102,6 +101,11 @@ void pci_remove_bus_device(struct pci_depci_destroy_dev (dev); } +void pci_remove_bus_device (struct pci_dev *dev) +{ +pci_stop_bus_device (dev); +__pci_remove_bus_device (dev); +}/** * pci_remove_behind_bridge - remove all devices behind a PCI bridge
@@ -117,7 +121,7 @@ void pci_remove_behind_bridge(struct pciif (dev->subordinate)list_for_each_safe (l, n, &dev->subordinate->devices) -pci_remove_bus_device (pci_dev_b (l)); +__pci_remove_bus_device (pci_dev_b (l)); }static void pci_stop_bus_devices (struct pci_bus *bus)
Jesse Barnes
AppliedQuoted 9 lines · On Tue, 22 Nov 2011 21:06:53 -0800 Yinghai Lu <[email protected]> wrote:
During debugging pcie hotplug with SRIOV with pcie switch, found
pci_stop_bus_device()are called several times for some children devices.Current
pci_remove_bus_device()will callpci_stop_bus_device()at first. and then useremove_behind_bridge()to callpci_stop_bus_device()for children devices. Butpci_stop_bus_device()already include depth first to stop children. So We can remove unnecessary calling inpci_remove_behind_bridge()for children.
Quoted 5 lines
The patch change original
pci_remove_bus_device()to__pci_remove_bus_device(), and it only do remove work, and newpci_remove_bus_devicewill callpci_stop_bus_device()one time, and then call__pci_remove_bus_device().Signed-off-by Yinghai Lu <[email protected]>
applied to linux-next, thanks.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center