All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 02/10] ACPI: use device drivers_autoprobe to delay loading acpi drivers
Date: Mon,  1 Oct 2012 23:33:00 -0700	[thread overview]
Message-ID: <1349159588-15029-3-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1349159588-15029-1-git-send-email-yinghai@kernel.org>

Current acpi driver for pci_root is working like this way for hotplug:

	acpi try to enumberate acpi device and create acpi_device for pci_root
	and loading driver for it, and that drivers .add aka acpi_pci_root_add
	calls pci_acpi_scan_root to enumerate pci devices but not add those pci
	devices into device tree to prevent drivers for pci devices get probed.

	Later .start aka acpi_pci_root_start will call pci_bus_add_devices to
	add pci devices into the tree to make drivers for pci devices get
	attached or probed.

The reason for that .add must get back for pci_root, so could create acpi_device
for other pci_devices. otherwise adding the pci device tree early than
acpi_device will cause binding for acpi/pci failing becuse pci_device can not find acpi_dev that is not created yet.

booting path is working becasue driver for acpi driver is registered later,
that means all acpi_device get created at first, and later when acpi_driver
get registered, and .add get called, that probe pci devices, when pci devices
is found, it could find acpi_device and binding will be ok, even
pci_add_bus_devices in done in acpi_pci_root_add.

That .start design is broken, and it will leave pci devices out of device tree
for a while.

We could use device drivers_autoprobe and acpi_bus_type notifier to control
the process to make sure for hot adding path, will have all acpi_device get
created, then attach acpi driver for acpi_device for pci_root.
That will make the path more like booting path.

After that we could remove the workaround .start in acpi driver ops.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/acpi/scan.c |   48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 5dfec09..67785da 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1451,6 +1451,20 @@ static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops,
 		return -ENODEV;
 }
 
+static void acpi_bus_attach(struct acpi_device *dev)
+{
+	struct acpi_device *child;
+	int ret;
+
+	ret = device_attach(&dev->dev);
+	/* make rescan working ? */
+	dev->dev.drivers_autoprobe = true;
+	WARN_ON(ret < 0);
+
+	list_for_each_entry(child, &dev->children, node)
+		acpi_bus_attach(child);
+}
+
 /*
  * acpi_bus_add and acpi_bus_start
  *
@@ -1468,11 +1482,17 @@ acpi_bus_add(struct acpi_device **child,
 	     struct acpi_device *parent, acpi_handle handle, int type)
 {
 	struct acpi_bus_ops ops;
+	int result;
 
 	memset(&ops, 0, sizeof(ops));
 	ops.acpi_op_add = 1;
 
-	return acpi_bus_scan(handle, &ops, child);
+	result = acpi_bus_scan(handle, &ops, child);
+
+	if (*child)
+		acpi_bus_attach(*child);
+
+	return result;
 }
 EXPORT_SYMBOL(acpi_bus_add);
 
@@ -1610,3 +1630,29 @@ int __init acpi_scan_init(void)
 
 	return result;
 }
+
+static int acpi_hp_notifier(struct notifier_block *nb,
+				 unsigned long event, void *data)
+{
+	struct device *dev = data;
+
+	switch (event) {
+	case BUS_NOTIFY_ADD_DEVICE:
+		dev->drivers_autoprobe = false;
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block acpi_hp_nb = {
+	.notifier_call = &acpi_hp_notifier,
+};
+
+static int __init acpi_hp_init(void)
+{
+	return bus_register_notifier(&acpi_bus_type,
+					 &acpi_hp_nb);
+}
+
+fs_initcall(acpi_hp_init);
-- 
1.7.7


  parent reply	other threads:[~2012-10-02  6:33 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02  6:32 [PATCH 00/10] PCI, ACPI: Use bus type notifier for root bus hotplug Yinghai Lu
2012-10-02  6:32 ` [PATCH 01/10] device: add drivers_autoprobe in struct device Yinghai Lu
2012-10-02 13:33   ` Greg Kroah-Hartman
2012-10-02 17:39     ` Yinghai Lu
2012-10-02 17:47       ` Greg Kroah-Hartman
2012-10-02 18:00         ` Bjorn Helgaas
2012-10-02 20:20         ` Yinghai Lu
2012-10-02 20:45           ` Greg Kroah-Hartman
2012-10-02 21:47             ` Yinghai Lu
2012-10-02 22:38               ` Bjorn Helgaas
2012-10-02 23:20                 ` Yinghai Lu
2012-10-03  0:00                 ` Yinghai Lu
2012-10-03  2:07                   ` Yinghai Lu
2012-10-03  2:08                     ` Yinghai Lu
2012-10-03 19:48                   ` Bjorn Helgaas
2012-10-03 20:50                     ` Yinghai Lu
2012-10-03 23:00                       ` [PATCH 0/4] ACPI: kill acpi_pci_root_start Yinghai Lu
2012-10-03 23:00                         ` [PATCH 1/4] ACPI: add drivers_autoprobe in struct acpi_device Yinghai Lu
2012-10-04 13:03                           ` Konrad Rzeszutek Wilk
2012-10-04 15:15                             ` Yinghai Lu
2012-10-09 16:38                               ` Konrad Rzeszutek Wilk
2012-10-03 23:00                         ` [PATCH 2/4] ACPI: use device drivers_autoprobe to delay loading acpi drivers Yinghai Lu
2012-10-03 23:00                         ` [PATCH 3/4] PCI, ACPI: Remove not used acpi_pci_root_start() Yinghai Lu
2012-10-03 23:00                         ` [PATCH 4/4] ACPI: remove acpi_op_start workaround Yinghai Lu
2012-10-04 12:57                           ` Konrad Rzeszutek Wilk
2012-10-04 17:47                         ` [PATCH 0/4] ACPI: kill acpi_pci_root_start Bjorn Helgaas
2012-10-04 18:36                           ` Yinghai Lu
2012-10-04 19:44                             ` Bjorn Helgaas
2012-10-04 19:54                               ` Rafael J. Wysocki
2012-10-04 20:14                               ` Yinghai Lu
2012-10-04 20:47                                 ` Bjorn Helgaas
2012-10-04 19:53                           ` Rafael J. Wysocki
2012-10-04 21:23                         ` Rafael J. Wysocki
2012-10-04 21:31                           ` Yinghai Lu
2012-10-04 21:53                             ` Rafael J. Wysocki
2012-10-04 22:01                               ` Yinghai Lu
2012-10-04 22:36                                 ` Rafael J. Wysocki
2012-10-04 22:46                                   ` Yinghai Lu
2012-10-05 23:01                                     ` Rafael J. Wysocki
2012-10-05 23:10                                       ` Yinghai Lu
2012-10-08 20:12                                         ` Rafael J. Wysocki
2012-10-02  6:33 ` Yinghai Lu [this message]
2012-10-02  6:33 ` [PATCH 03/10] PCI: prepare to use device drivers_autoprobe to delay attach drivers Yinghai Lu
2012-10-02  6:33 ` [PATCH 04/10] PCI: Use device_add for device and bus early Yinghai Lu
2012-10-02  6:33 ` [PATCH 05/10] PCI, ACPI: Separate out acpi_pci_root_osc_contorl_set Yinghai Lu
2012-10-02  6:33 ` [PATCH 06/10] PCI, ACPI: Move hot add root bus conf code to acpi_pci_root_add Yinghai Lu
2012-10-02  6:33 ` [PATCH 07/10] PCI, ACPI: Remove not used acpi_pci_root_start() Yinghai Lu
2012-10-02  6:33 ` [PATCH 08/10] PCI: Add dev_is_pci_host_bridge() helper Yinghai Lu
2012-10-02  6:33 ` [PATCH 09/10] PCI, ACPI: using acpi/pci bind path for pci_host_bridge Yinghai Lu
2012-10-02  6:33 ` [PATCH 10/10] PCI, ACPI: use bus_type notifier for acpi_pci_bind_notify Yinghai Lu
2012-10-06  2:57 ` [PATCH 00/10] PCI, ACPI: Use bus type notifier for root bus hotplug Jiang Liu
2012-10-06  7:25   ` Yinghai Lu
2012-10-07 15:17     ` Jiang Liu
2012-10-07 22:33       ` Yinghai Lu
2012-10-08 15:23         ` 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=1349159588-15029-3-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.