public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Jesse Barnes <jbarnes@virtuousgeek.org>, x86 <x86@kernel.org>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yinghai Lu <yinghai@kernel.org>, Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org
Subject: [PATCH 18/23] PCI, ACPI: add acpi_pci_root_rescan()
Date: Mon,  5 Mar 2012 23:13:55 -0800	[thread overview]
Message-ID: <1331018040-30725-19-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1331018040-30725-1-git-send-email-yinghai@kernel.org>

it will rescan all acpi pci root if related pci root bus get removed before.

Signed-off-by: Yinghai <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
---
 drivers/acpi/pci_root.c |   52 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index b38e347..e1814e0 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -679,3 +679,55 @@ static int __init acpi_pci_root_init(void)
 }
 
 subsys_initcall(acpi_pci_root_init);
+
+static acpi_status
+rescan_root_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+	struct acpi_device *device, *pdevice;
+	struct acpi_pci_root *root;
+	acpi_handle phandle;
+	int ret_val;
+
+	if (!acpi_is_root_bridge(handle))
+		return AE_OK;
+
+	acpi_get_parent(handle, &phandle);
+	if (acpi_bus_get_device(phandle, &pdevice)) {
+		printk(KERN_DEBUG "no parent device, assuming NULL\n");
+		pdevice = NULL;
+	}
+
+	if (!acpi_bus_get_device(handle, &device)) {
+		/* check if  pci root_bus is removed */
+		root = acpi_driver_data(device);
+		if (pci_find_bus(root->segment, root->secondary.start))
+			return AE_OK;
+
+		printk(KERN_DEBUG "bus exists... trim\n");
+		/* this shouldn't be in here, so remove
+		 * the bus then re-add it...
+		 */
+		ret_val = acpi_bus_trim(device, 1);
+		printk(KERN_DEBUG "acpi_bus_trim return %x\n", ret_val);
+	}
+
+	ret_val = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
+	if (ret_val) {
+		printk(KERN_ERR "error adding bus, %x\n", -ret_val);
+		goto out;
+	}
+
+	root = acpi_driver_data(device);
+	pci_assign_unassigned_bus_resources(root->bus);
+
+	ret_val = acpi_bus_start(device);
+
+out:
+	return ret_val;
+}
+
+void acpi_pci_root_rescan(void)
+{
+	acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+		ACPI_UINT32_MAX, rescan_root_bridge, NULL, NULL, NULL);
+}
-- 
1.7.7

  parent reply	other threads:[~2012-03-06  7:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1331018040-30725-1-git-send-email-yinghai@kernel.org>
2012-03-06  7:13 ` [PATCH 08/23] PNPACPI: Fix device ref leaking in acpi_pnp_match Yinghai Lu
2012-03-07  3:53   ` Bjorn Helgaas
2012-03-06  7:13 ` [PATCH 17/23] PCI, ACPI: make acpi_pci_root_remove remove pci root bus too Yinghai Lu
2012-03-06  7:13 ` Yinghai Lu [this message]
2012-03-07  4:40   ` [PATCH 18/23] PCI, ACPI: add acpi_pci_root_rescan() Bjorn Helgaas
     [not found] ` <1331018040-30725-17-git-send-email-yinghai@kernel.org>
     [not found]   ` <CAErSpo59kzBL1ApWuWWcymd9UR3m3vB3zkUoJezn66As+-97dQ@mail.gmail.com>
     [not found]     ` <CAE9FiQVTng2Bi4z9YY9CustC7KkTr-6+qFaaqu8F4dd0WAKGig@mail.gmail.com>
2012-03-08  4:45       ` [PATCH 16/23] PCI: add pci bus removal through /sys/.../pci_bus/.../remove Bjorn Helgaas
2012-03-08 15:45         ` Greg Kroah-Hartman

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=1331018040-30725-19-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=x86@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