From: Jiang Liu <liuj97@gmail.com>
To: Yinghai Lu <yinghai@kernel.org>,
Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: Jiang Liu <jiang.liu@huawei.com>, Jiang Liu <liuj97@gmail.com>,
Keping Chen <chenkeping@huawei.com>,
linux-pci@vger.kernel.org
Subject: [PATCH RFC 17/17] PCI: serialize PCI hotplug operations triggered by fakephp drivers
Date: Tue, 17 Apr 2012 00:29:11 +0800 [thread overview]
Message-ID: <1334593751-5916-18-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1334593751-5916-1-git-send-email-jiang.liu@huawei.com>
Use PCI hotplug lock to globally serialize hotplug operations triggered
by fakephp driver.
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
drivers/pci/hotplug/fakephp.c | 38 ++++++++++++++++++++++++++++++++------
1 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index a019c9a..ee6c79e 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -38,9 +38,24 @@ static ssize_t legacy_show(struct kobject *kobj, struct attribute *attr,
return 2;
}
+static void rescan_callback(void *data)
+{
+ struct legacy_slot *slot = data;
+
+ pci_hotplug_enter();
+ if (!list_empty(&slot->list))
+ pci_rescan_bus(slot->dev->bus);
+ pci_hotplug_exit();
+}
+
static void remove_callback(void *data)
{
- pci_stop_and_remove_bus_device((struct pci_dev *)data);
+ struct legacy_slot *slot = data;
+
+ pci_hotplug_enter();
+ if (!list_empty(&slot->list))
+ pci_stop_and_remove_bus_device(slot->dev);
+ pci_hotplug_exit();
}
static ssize_t legacy_store(struct kobject *kobj, struct attribute *attr,
@@ -53,10 +68,11 @@ static ssize_t legacy_store(struct kobject *kobj, struct attribute *attr,
return -EINVAL;
if (val)
- pci_rescan_bus(slot->dev->bus);
+ sysfs_schedule_callback(&slot->kobj, rescan_callback,
+ slot, THIS_MODULE);
else
- sysfs_schedule_callback(&slot->dev->dev.kobj, remove_callback,
- slot->dev, THIS_MODULE);
+ sysfs_schedule_callback(&slot->kobj, remove_callback,
+ slot, THIS_MODULE);
return len;
}
@@ -107,20 +123,25 @@ static int legacy_notify(struct notifier_block *nb,
struct pci_dev *pdev = to_pci_dev(data);
if (action == BUS_NOTIFY_ADD_DEVICE) {
+ pci_hotplug_enter();
legacy_add_slot(pdev);
+ pci_hotplug_exit();
} else if (action == BUS_NOTIFY_DEL_DEVICE) {
struct legacy_slot *slot;
+ pci_hotplug_enter();
list_for_each_entry(slot, &legacy_list, list)
if (slot->dev == pdev)
goto found;
+ pci_hotplug_exit();
dev_warn(&pdev->dev, "Missing legacy fake slot?");
return -ENODEV;
found:
kobject_del(&slot->kobj);
- list_del(&slot->list);
+ list_del_init(&slot->list);
kobject_put(&slot->kobj);
+ pci_hotplug_exit();
}
return 0;
@@ -135,11 +156,14 @@ static int __init init_legacy(void)
struct pci_dev *pdev = NULL;
/* Add existing devices */
+ pci_hotplug_disable();
for_each_pci_dev(pdev)
legacy_add_slot(pdev);
/* Be alerted of any new ones */
bus_register_notifier(&pci_bus_type, &legacy_notifier);
+ pci_hotplug_enable();
+
return 0;
}
module_init(init_legacy);
@@ -150,11 +174,13 @@ static void __exit remove_legacy(void)
bus_unregister_notifier(&pci_bus_type, &legacy_notifier);
+ pci_hotplug_disable();
list_for_each_entry_safe(slot, tmp, &legacy_list, list) {
- list_del(&slot->list);
+ list_del_init(&slot->list);
kobject_del(&slot->kobj);
kobject_put(&slot->kobj);
}
+ pci_hotplug_enable();
}
module_exit(remove_legacy);
--
1.7.5.4
next prev parent reply other threads:[~2012-04-16 16:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-16 16:28 [PATCH RFC 00/17] Introduce a global lock to serialize all PCI hotplug Jiang Liu
2012-04-16 16:28 ` [PATCH RFC 01/17] PCI: introduce pci_bus_get()/pci_bus_put() to hide PCI implementation details Jiang Liu
2012-04-16 16:28 ` [PATCH RFC 02/17] PCI: introduce recursive rwsem to serialize PCI hotplug operations Jiang Liu
2012-04-16 16:28 ` [PATCH RFC 03/17] PCI: replace pci_remove_rescan_mutex with the PCI hotplug lock Jiang Liu
2012-04-16 16:28 ` [PATCH RFC 04/17] PCI: serialize hotplug operations triggered by PCI hotplug sysfs interfaces Jiang Liu
2012-04-16 16:28 ` [PATCH RFC 05/17] PCI: correctly flush workqueue when destroy pcie hotplug controller Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 06/17] PCI: prepare for serializing hotplug operations triggered by pciehp driver Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 07/17] PCI: serialize hotplug operaitons triggered by the " Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 08/17] PCI: fix two race windows when probing/removing SHPC controller Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 09/17] PCI: correctly flush workqueues and timer when destroy " Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 10/17] PCI: serialize hotplug operaitons triggered by the shpchp driver Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 11/17] PCI: release IO resource in error handling path in cpcihp_generic_init() Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 12/17] PCI: clean up all resources in error handling path in zt5550_hc_init_one() Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 13/17] PCI: trivial code clean up in cpci_hotplug_core.c Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 14/17] PCI: fix race windows when shutting down cpcihp controller Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 15/17] PCI: hold a reference count to the PCI bus used by cpcihp drivers Jiang Liu
2012-04-16 16:29 ` [PATCH RFC 16/17] PCI: serialize PCI hotplug operations triggered " Jiang Liu
2012-04-16 16:29 ` Jiang Liu [this message]
2012-04-16 21:33 ` [PATCH RFC 00/17] Introduce a global lock to serialize all PCI hotplug Greg KH
2012-04-17 11:57 ` Jiang Liu
2012-04-17 14:53 ` Jiang Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1334593751-5916-18-git-send-email-jiang.liu@huawei.com \
--to=liuj97@gmail.com \
--cc=bhelgaas@google.com \
--cc=chenkeping@huawei.com \
--cc=jiang.liu@huawei.com \
--cc=kaneshige.kenji@jp.fujitsu.com \
--cc=linux-pci@vger.kernel.org \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).