aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/remove.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/remove.c')
-rw-r--r--drivers/pci/remove.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index ef8b18c48f26..82f8ae572703 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -144,7 +144,15 @@ static void pci_stop_bus_devices(struct pci_bus *bus)
144{ 144{
145 struct list_head *l, *n; 145 struct list_head *l, *n;
146 146
147 list_for_each_safe(l, n, &bus->devices) { 147 /*
148 * VFs could be removed by pci_remove_bus_device() in the
149 * pci_stop_bus_devices() code path for PF.
150 * aka, bus->devices get updated in the process.
151 * but VFs are inserted after PFs when SRIOV is enabled for PF,
152 * We can iterate the list backwards to get prev valid PF instead
153 * of removed VF.
154 */
155 list_for_each_prev_safe(l, n, &bus->devices) {
148 struct pci_dev *dev = pci_dev_b(l); 156 struct pci_dev *dev = pci_dev_b(l);
149 pci_stop_bus_device(dev); 157 pci_stop_bus_device(dev);
150 } 158 }