[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1368719459-24800-9-git-send-email-jiang.liu@huawei.com>
Date: Thu, 16 May 2013 23:50:56 +0800
From: Jiang Liu <liuj97@...il.com>
To: Bjorn Helgaas <bhelgaas@...gle.com>,
Yinghai Lu <yinghai@...nel.org>
Cc: Jiang Liu <jiang.liu@...wei.com>,
"Rafael J . Wysocki" <rjw@...k.pl>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Gu Zheng <guz.fnst@...fujitsu.com>,
Toshi Kani <toshi.kani@...com>,
Myron Stowe <myron.stowe@...hat.com>,
Yijing Wang <wangyijing@...wei.com>,
Jiang Liu <liuj97@...il.com>, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Jeremy Fitzhardinge <jeremy@...p.org>,
xen-devel@...ts.xensource.com,
virtualization@...ts.linux-foundation.org
Subject: [RFC PATCH v2, part3 08/11] PCI, xen-pcifront: use PCI bus lock to protect PCI device hotplug
Use PCI bus lock to protect concurrent PCI device hotplug operations.
Signed-off-by: Jiang Liu <jiang.liu@...wei.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
Cc: Jeremy Fitzhardinge <jeremy@...p.org>
Cc: xen-devel@...ts.xensource.com
Cc: virtualization@...ts.linux-foundation.org
Cc: linux-pci@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
---
drivers/pci/xen-pcifront.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c
index 6aa2c0f..2b213b3 100644
--- a/drivers/pci/xen-pcifront.c
+++ b/drivers/pci/xen-pcifront.c
@@ -505,6 +505,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
/* Create SysFS and notify udev of the devices. Aka: "going live" */
pci_bus_add_devices(b);
+ pci_bus_unlock(b, true);
return err;
@@ -538,6 +539,11 @@ static int pcifront_rescan_root(struct pcifront_device *pdev,
/* If the bus is unknown, create it. */
return pcifront_scan_root(pdev, domain, bus);
+ if (pci_bus_lock(b, PCI_BUS_STATE_STOPPING - 1, true) < 0) {
+ err = -EBUSY;
+ goto out;
+ }
+
err = pcifront_scan_bus(pdev, domain, bus, b);
/* Claim resources before going "live" with our devices */
@@ -545,6 +551,9 @@ static int pcifront_rescan_root(struct pcifront_device *pdev,
/* Create SysFS and notify udev of the devices. Aka: "going live" */
pci_bus_add_devices(b);
+ pci_bus_unlock(b, true);
+
+out:
pci_bus_put(b);
return err;
@@ -559,8 +568,11 @@ static void pcifront_free_roots(struct pcifront_device *pdev)
for_each_pci_root_bus(bus) {
sd = bus->sysdata;
- if (sd->pdev == pdev) {
+ if (sd->pdev != pdev)
+ continue;
+ if (pci_bus_lock(bus, PCI_BUS_STATE_REMOVED - 1, true) == 0) {
pci_stop_root_bus(bus);
+ /* it also unlocks PCI buses */
pci_remove_root_bus(bus);
}
}
@@ -1042,7 +1054,7 @@ static int pcifront_detach_devices(struct pcifront_device *pdev)
domain, bus, slot, func);
continue;
}
- pci_stop_and_remove_bus_device(pci_dev);
+ pci_stop_and_remove_device(pci_dev);
pci_dev_put(pci_dev);
dev_dbg(&pdev->xdev->dev,
--
1.8.1.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists