summaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/cpqphp_pci.c
diff options
context:
space:
mode:
authorRafael J. Wysocki2014-01-14 20:03:14 +0100
committerBjorn Helgaas2014-01-14 20:14:25 +0100
commitc4ec84c7db0e4b01ed40cc2388f16ae5c6513cc0 (patch)
treeb280cdcdbf714b6709e8d87a0d157f4979cb73d7 /drivers/pci/hotplug/cpqphp_pci.c
parentpcmcia: Use global PCI rescan-remove locking (diff)
downloadkernel-qcow2-linux-c4ec84c7db0e4b01ed40cc2388f16ae5c6513cc0.tar.gz
kernel-qcow2-linux-c4ec84c7db0e4b01ed40cc2388f16ae5c6513cc0.tar.xz
kernel-qcow2-linux-c4ec84c7db0e4b01ed40cc2388f16ae5c6513cc0.zip
PCI: hotplug: Use global PCI rescan-remove locking
Multiple race conditions are possible between PCI hotplug and the generic PCI bus rescan and device removal that can be triggered via sysfs. To avoid those race conditions make PCI hotplug 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>
Diffstat (limited to 'drivers/pci/hotplug/cpqphp_pci.c')
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 6e4a12c91adb..a3e3c2002b58 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -86,6 +86,8 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
struct pci_bus *child;
int num;
+ pci_lock_rescan_remove();
+
if (func->pci_dev == NULL)
func->pci_dev = pci_get_bus_and_slot(func->bus,PCI_DEVFN(func->device, func->function));
@@ -100,7 +102,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function));
if (func->pci_dev == NULL) {
dbg("ERROR: pci_dev still null\n");
- return 0;
+ goto out;
}
}
@@ -113,6 +115,8 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
pci_dev_put(func->pci_dev);
+ out:
+ pci_unlock_rescan_remove();
return 0;
}
@@ -123,6 +127,7 @@ int cpqhp_unconfigure_device(struct pci_func* func)
dbg("%s: bus/dev/func = %x/%x/%x\n", __func__, func->bus, func->device, func->function);
+ pci_lock_rescan_remove();
for (j=0; j<8 ; j++) {
struct pci_dev* temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j));
if (temp) {
@@ -130,6 +135,7 @@ int cpqhp_unconfigure_device(struct pci_func* func)
pci_stop_and_remove_bus_device(temp);
}
}
+ pci_unlock_rescan_remove();
return 0;
}