[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1368719459-24800-11-git-send-email-jiang.liu@huawei.com>
Date: Thu, 16 May 2013 23:50:58 +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
Subject: [RFC PATCH v2, part3 10/11] PCI, pciehp: 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: Yinghai Lu <yinghai@...nel.org>
Cc: Yijing Wang <wangyijing@...wei.com>
Cc: linux-pci@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
---
drivers/pci/hotplug/pciehp_pci.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index aac7a40..ddc29ae 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -51,8 +51,14 @@ int pciehp_configure_device(struct slot *p_slot)
return -EINVAL;
}
+ if (pci_bus_lock(parent, PCI_BUS_STATE_STOPPING - 1, true) < 0) {
+ ctrl_err(ctrl, "Parent bus has been removed\n");
+ return -EBUSY;
+ }
+
num = pci_scan_slot(parent, PCI_DEVFN(0, 0));
if (num == 0) {
+ pci_bus_unlock(parent, true);
ctrl_err(ctrl, "No new device found\n");
return -ENODEV;
}
@@ -72,6 +78,7 @@ int pciehp_configure_device(struct slot *p_slot)
}
pci_bus_add_devices(parent);
+ pci_bus_unlock(parent, true);
return 0;
}
@@ -88,6 +95,12 @@ int pciehp_unconfigure_device(struct slot *p_slot)
ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
__func__, pci_domain_nr(parent), parent->number);
+
+ if (pci_bus_lock(parent, PCI_BUS_STATE_REMOVED - 1, true) < 0) {
+ ctrl_dbg(ctrl, "Parent bus has been removed\n");
+ return 0;
+ }
+
ret = pciehp_get_adapter_status(p_slot, &presence);
if (ret)
presence = 0;
@@ -119,5 +132,7 @@ int pciehp_unconfigure_device(struct slot *p_slot)
pci_dev_put(dev);
}
+ pci_bus_unlock(parent, true);
+
return rc;
}
--
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