Subject: [PATCH] PCI, ACPI: Use pci_host_bridge dev to save acpi_handle

So we could avoid calling acpi_get_pci_rootbridge_handle that could cause deadlock.

non root pci bus is using bridge->dev archdata.acpi_handle.
for root bus that field is not used, could just save root handle, and get that
later when need to get root bus's handle.

-v2: move setting code to pci_root.c

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org

---
 drivers/acpi/pci_root.c  |   21 +++------------------
 drivers/pci/pci-acpi.c   |    4 +++-
 include/acpi/acpi_bus.h  |    1 -
 include/linux/pci-acpi.h |   15 ++++++++++-----
 4 files changed, 16 insertions(+), 25 deletions(-)

Index: linux-2.6/include/linux/pci-acpi.h
===================================================================
--- linux-2.6.orig/include/linux/pci-acpi.h
+++ linux-2.6/include/linux/pci-acpi.h
@@ -22,19 +22,24 @@ extern phys_addr_t acpi_pci_root_get_mcf
 static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev)
 {
 	struct pci_bus *pbus = pdev->bus;
+
 	/* Find a PCI root bus */
 	while (!pci_is_root_bus(pbus))
 		pbus = pbus->parent;
-	return acpi_get_pci_rootbridge_handle(pci_domain_nr(pbus),
-					      pbus->number);
+
+	return DEVICE_ACPI_HANDLE(pbus->bridge);
 }
 
 static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus)
 {
+	struct device *dev;
+
 	if (!pci_is_root_bus(pbus))
-		return DEVICE_ACPI_HANDLE(&(pbus->self->dev));
-	return acpi_get_pci_rootbridge_handle(pci_domain_nr(pbus),
-					      pbus->number);
+		dev = &pbus->self->dev;
+	else
+		dev = pbus->bridge;
+
+	return DEVICE_ACPI_HANDLE(dev);
 }
 #endif
 
Index: linux-2.6/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.orig/drivers/acpi/pci_root.c
+++ linux-2.6/drivers/acpi/pci_root.c
@@ -542,6 +524,9 @@ static int __devinit acpi_pci_root_add(s
 		goto out_del_root;
 	}
 
+	/* to find handle from root bus */
+	root->bus->bridge->archdata.acpi_handle = device->handle;
+
 	/*
 	 * Attach ACPI-PCI Context
 	 * -----------------------
