Skip to content

Commit a83919e

Browse files
rafaeljwbjorn-helgaas
authored andcommitted
xen/pcifront: Use global PCI rescan-remove locking
Multiple race conditions are possible between the Xen pcifront device addition and removal and the generic PCI device addition and removal that can be triggered via sysfs. To avoid those race conditions make the Xen pcifront code use global PCI rescan-remove locking. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 1c2042c commit a83919e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/pci/xen-pcifront.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
471471
}
472472
pcifront_init_sd(sd, domain, bus, pdev);
473473

474+
pci_lock_rescan_remove();
475+
474476
b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
475477
&pcifront_bus_ops, sd);
476478
if (!b) {
477479
dev_err(&pdev->xdev->dev,
478480
"Error creating PCI Frontend Bus!\n");
479481
err = -ENOMEM;
482+
pci_unlock_rescan_remove();
480483
goto err_out;
481484
}
482485

@@ -494,6 +497,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
494497
/* Create SysFS and notify udev of the devices. Aka: "going live" */
495498
pci_bus_add_devices(b);
496499

500+
pci_unlock_rescan_remove();
497501
return err;
498502

499503
err_out:
@@ -556,6 +560,7 @@ static void pcifront_free_roots(struct pcifront_device *pdev)
556560

557561
dev_dbg(&pdev->xdev->dev, "cleaning up root buses\n");
558562

563+
pci_lock_rescan_remove();
559564
list_for_each_entry_safe(bus_entry, t, &pdev->root_buses, list) {
560565
list_del(&bus_entry->list);
561566

@@ -568,6 +573,7 @@ static void pcifront_free_roots(struct pcifront_device *pdev)
568573

569574
kfree(bus_entry);
570575
}
576+
pci_unlock_rescan_remove();
571577
}
572578

573579
static pci_ers_result_t pcifront_common_process(int cmd,
@@ -1043,8 +1049,10 @@ static int pcifront_detach_devices(struct pcifront_device *pdev)
10431049
domain, bus, slot, func);
10441050
continue;
10451051
}
1052+
pci_lock_rescan_remove();
10461053
pci_stop_and_remove_bus_device(pci_dev);
10471054
pci_dev_put(pci_dev);
1055+
pci_unlock_rescan_remove();
10481056

10491057
dev_dbg(&pdev->xdev->dev,
10501058
"PCI device %04x:%02x:%02x.%d removed.\n",

0 commit comments

Comments
 (0)