[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1368719459-24800-10-git-send-email-jiang.liu@huawei.com>
Date: Thu, 16 May 2013 23:50:57 +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,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>
Subject: [RFC PATCH v2, part3 09/11] PCI, acpiphp: 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: "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>
Cc: Yijing Wang <wangyijing@...wei.com>
Cc: linux-pci@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
---
drivers/pci/hotplug/acpiphp_glue.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index e330331..d105dcd 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -674,6 +674,9 @@ static int __ref enable_device(struct acpiphp_slot *slot)
if (slot->flags & SLOT_ENABLED)
goto err_exit;
+ if (pci_bus_lock(bus, PCI_BUS_STATE_STOPPING - 1, true) < 0)
+ goto err_exit;
+
list_for_each_entry(func, &slot->funcs, sibling)
acpiphp_bus_add(func);
@@ -681,7 +684,7 @@ static int __ref enable_device(struct acpiphp_slot *slot)
if (num == 0) {
/* Maybe only part of funcs are added. */
dbg("No new device found\n");
- goto err_exit;
+ goto out_unlock;
}
max = acpiphp_max_busnr(bus);
@@ -726,8 +729,9 @@ static int __ref enable_device(struct acpiphp_slot *slot)
}
}
-
- err_exit:
+out_unlock:
+ pci_bus_unlock(bus, true);
+err_exit:
return 0;
}
@@ -757,7 +761,10 @@ static int disable_device(struct acpiphp_slot *slot)
{
struct acpiphp_func *func;
struct pci_dev *pdev;
+ struct pci_bus *bus = slot->bridge->pci_bus;
+ if (pci_bus_lock(bus, PCI_BUS_STATE_STOPPING - 1, true) < 0)
+ return -EBUSY;
/*
* enable_device() enumerates all functions in this device via
* pci_scan_slot(), whether they have associated ACPI hotplug
@@ -768,6 +775,7 @@ static int disable_device(struct acpiphp_slot *slot)
pci_stop_and_remove_bus_device(pdev);
pci_dev_put(pdev);
}
+ pci_bus_unlock(bus, true);
list_for_each_entry(func, &slot->funcs, sibling) {
acpiphp_bus_trim(func->handle);
--
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