linux-pci.vger.kernel.org archive mirror
 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>,
	Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org
Subject: [PATCH 09/10] PCI, ACPI: using acpi/pci bind path for pci_host_bridge
Date: Mon,  1 Oct 2012 23:33:07 -0700	[thread overview]
Message-ID: <1349159588-15029-10-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1349159588-15029-1-git-send-email-yinghai@kernel.org>

Now pci_dev is using:
	pci_bus_add_device
		==> device_add
			==> platform_notify aka acpi_platform_notify
				==> acpi_bind_one
					==> acpi_pci_bind_notify

pci_host_bridge calling till to acpi_bind_one but not in acpi_pci_bind_notify
because acpi_pci_bind_notify only handle pci_dev.

Extend acpi_pci_bind_notify to handle pci_host_bridge.

After that, We could remove same calling in acpi_pci_root_add and
acpi_pci_root_remove.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
---
 drivers/acpi/pci_bind.c |   59 +++++++++++++++++++++++++++++++---------------
 drivers/acpi/pci_root.c |   21 ----------------
 2 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index aac7f9a..b59a5df 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -35,33 +35,59 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_bind");
 
-static int acpi_pci_unbind(struct acpi_device *acpi_dev, struct pci_dev *dev)
+static int acpi_pci_unbind(struct acpi_device *acpi_dev, struct device *dev)
 {
+	struct pci_dev *pdev = NULL;
+	struct pci_bus *bus = NULL;
+
+	if (dev_is_pci(dev)) {
+		pdev = to_pci_dev(dev);
+		if (pdev->subordinate)
+			bus = pdev->subordinate;
+	} else
+			bus = to_pci_host_bridge(dev)->bus;
+
 	if (acpi_dev) {
-		device_set_run_wake(&dev->dev, false);
-		pci_acpi_remove_pm_notifier(acpi_dev);
+		device_set_run_wake(dev, false);
+		if (pdev)
+			pci_acpi_remove_pm_notifier(acpi_dev);
+		else
+			pci_acpi_remove_bus_pm_notifier(acpi_dev);
 	}
 
-	if (dev->subordinate)
-		acpi_pci_irq_del_prt(dev->subordinate);
+	if (bus)
+		acpi_pci_irq_del_prt(bus);
 
 	return 0;
 }
 
-static int acpi_pci_bind(struct acpi_device *acpi_dev, struct pci_dev *dev)
+static int acpi_pci_bind(struct acpi_device *acpi_dev, struct device *dev)
 {
 	acpi_status status;
-	struct pci_bus *bus;
+	struct pci_dev *pdev = NULL;
+	struct pci_bus *bus = NULL;
 	acpi_handle tmp_hdl;
 	acpi_handle handle;
 
+	if (dev_is_pci(dev)) {
+		pdev = to_pci_dev(dev);
+		if (pdev->subordinate)
+			bus = pdev->subordinate;
+		else
+			bus = pdev->bus;
+	} else
+			bus = to_pci_host_bridge(dev)->bus;
+
 	if (acpi_dev) {
-		pci_acpi_add_pm_notifier(acpi_dev, dev);
+		if (pdev)
+			pci_acpi_add_pm_notifier(acpi_dev, pdev);
+		else
+			pci_acpi_add_bus_pm_notifier(acpi_dev, bus);
 		if (acpi_dev->wakeup.flags.run_wake)
-			device_set_run_wake(&dev->dev, true);
+			device_set_run_wake(dev, true);
 		handle = acpi_dev->handle;
 	} else
-		handle = DEVICE_ACPI_HANDLE(&dev->dev);
+		handle = DEVICE_ACPI_HANDLE(dev);
 
 	/*
 	 * Evaluate and parse _PRT, if exists.  This code allows parsing of
@@ -72,13 +98,8 @@ static int acpi_pci_bind(struct acpi_device *acpi_dev, struct pci_dev *dev)
 	 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
 	 */
 	status = acpi_get_handle(handle, METHOD_NAME__PRT, &tmp_hdl);
-	if (ACPI_SUCCESS(status)) {
-		if (dev->subordinate)
-			bus = dev->subordinate;
-		else
-			bus = dev->bus;
+	if (ACPI_SUCCESS(status))
 		acpi_pci_irq_add_prt(handle, bus);
-	}
 
 	return 0;
 }
@@ -86,10 +107,10 @@ static int acpi_pci_bind(struct acpi_device *acpi_dev, struct pci_dev *dev)
 void acpi_pci_bind_notify(struct acpi_device *acpi_dev, struct device *dev,
 			  bool bind)
 {
-	if (dev_is_pci(dev)) {
+	if (dev_is_pci(dev) || dev_is_pci_host_bridge(dev)) {
 		if (bind)
-			acpi_pci_bind(acpi_dev, to_pci_dev(dev));
+			acpi_pci_bind(acpi_dev, dev);
 		else
-			acpi_pci_unbind(acpi_dev, to_pci_dev(dev));
+			acpi_pci_unbind(acpi_dev, dev);
 	}
 }
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 8134f72..725ec10 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -505,7 +505,6 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
 	int result;
 	struct acpi_pci_root *root;
 	struct acpi_pci_driver *driver;
-	acpi_handle handle;
 	u32 flags;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
@@ -591,21 +590,8 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
 		goto out_del_root;
 	}
 
-	/*
-	 * PCI Routing Table
-	 * -----------------
-	 * Evaluate and parse _PRT, if exists.
-	 */
-	status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
-	if (ACPI_SUCCESS(status))
-		result = acpi_pci_irq_add_prt(device->handle, root->bus);
-
 	acpi_pci_root_osc_control_set(root);
 
-	pci_acpi_add_bus_pm_notifier(device, root->bus);
-	if (device->wakeup.flags.run_wake)
-		device_set_run_wake(root->bus->bridge, true);
-
 	if (system_state != SYSTEM_BOOTING) {
 		pcibios_resource_survey_bus(root->bus);
 		pci_assign_unassigned_bus_resources(root->bus);
@@ -649,13 +635,6 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
 			driver->remove(root);
 	mutex_unlock(&acpi_pci_root_lock);
 
-	device_set_run_wake(root->bus->bridge, false);
-	pci_acpi_remove_bus_pm_notifier(device);
-
-	status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
-	if (ACPI_SUCCESS(status))
-		acpi_pci_irq_del_prt(root->bus);
-
 	pci_remove_root_bus(root->bus);
 
 	mutex_lock(&acpi_pci_root_lock);
-- 
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 ` [PATCH 02/10] ACPI: use device drivers_autoprobe to delay loading acpi drivers Yinghai Lu
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 ` Yinghai Lu [this message]
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-10-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --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 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).