diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-09 16:33:37 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-01-13 19:14:28 -0500 |
commit | 6c0cc950ae670403a362bdcbf3cde0df33744928 (patch) | |
tree | 45c438f12c5af1ea66aae56c03ac9e53f80899fa /arch/x86 | |
parent | 295a7f6235bfa21be3454aebc1bea1eaf0b74fb7 (diff) |
ACPI / PCI: Set root bridge ACPI handle in advance
The ACPI handles of PCI root bridges need to be known to
acpi_bind_one(), so that it can create the appropriate
"firmware_node" and "physical_node" files for them, but currently
the way it gets to know those handles is not exactly straightforward
(to put it lightly).
This is how it works, roughly:
1. acpi_bus_scan() finds the handle of a PCI root bridge,
creates a struct acpi_device object for it and passes that
object to acpi_pci_root_add().
2. acpi_pci_root_add() creates a struct acpi_pci_root object,
populates its "device" field with its argument's address
(device->handle is the ACPI handle found in step 1).
3. The struct acpi_pci_root object created in step 2 is passed
to pci_acpi_scan_root() and used to get resources that are
passed to pci_create_root_bus().
4. pci_create_root_bus() creates a struct pci_host_bridge object
and passes its "dev" member to device_register().
5. platform_notify(), which for systems with ACPI is set to
acpi_platform_notify(), is called.
So far, so good. Now it starts to be "interesting".
6. acpi_find_bridge_device() is used to find the ACPI handle of
the given device (which is the PCI root bridge) and executes
acpi_pci_find_root_bridge(), among other things, for the
given device object.
7. acpi_pci_find_root_bridge() uses the name (sic!) of the given
device object to extract the segment and bus numbers of the PCI
root bridge and passes them to acpi_get_pci_rootbridge_handle().
8. acpi_get_pci_rootbridge_handle() browses the list of ACPI PCI
root bridges and finds the one that matches the given segment
and bus numbers. Its handle is then used to initialize the
ACPI handle of the PCI root bridge's device object by
acpi_bind_one(). However, this is *exactly* the ACPI handle we
started with in step 1.
Needless to say, this is quite embarassing, but it may be avoided
thanks to commit f3fd0c8 (ACPI: Allow ACPI handles of devices to be
initialized in advance), which makes it possible to initialize the
ACPI handle of a device before passing it to device_register().
Accordingly, add a new __weak routine, pcibios_root_bridge_prepare(),
defaulting to an empty implementation that can be replaced by the
interested architecutres (x86 and ia64 at the moment) with functions
that will set the root bridge's ACPI handle before its dev member is
passed to device_register(). Make both x86 and ia64 provide such
implementations of pcibios_root_bridge_prepare() and remove
acpi_pci_find_root_bridge() and acpi_get_pci_rootbridge_handle() that
aren't necessary any more.
Included is a fix for breakage on systems with non-ACPI PCI host
bridges from Bjorn Helgaas.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/pci.h | 3 | ||||
-rw-r--r-- | arch/x86/pci/acpi.c | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h index dba7805176bf..9f437e97e9e8 100644 --- a/arch/x86/include/asm/pci.h +++ b/arch/x86/include/asm/pci.h | |||
@@ -14,6 +14,9 @@ | |||
14 | struct pci_sysdata { | 14 | struct pci_sysdata { |
15 | int domain; /* PCI domain */ | 15 | int domain; /* PCI domain */ |
16 | int node; /* NUMA node */ | 16 | int node; /* NUMA node */ |
17 | #ifdef CONFIG_ACPI | ||
18 | void *acpi; /* ACPI-specific data */ | ||
19 | #endif | ||
17 | #ifdef CONFIG_X86_64 | 20 | #ifdef CONFIG_X86_64 |
18 | void *iommu; /* IOMMU private data */ | 21 | void *iommu; /* IOMMU private data */ |
19 | #endif | 22 | #endif |
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 0c01261fe5a8..3d49094ed3e8 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -522,6 +522,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | |||
522 | sd = &info->sd; | 522 | sd = &info->sd; |
523 | sd->domain = domain; | 523 | sd->domain = domain; |
524 | sd->node = node; | 524 | sd->node = node; |
525 | sd->acpi = device->handle; | ||
525 | /* | 526 | /* |
526 | * Maybe the desired pci bus has been already scanned. In such case | 527 | * Maybe the desired pci bus has been already scanned. In such case |
527 | * it is unnecessary to scan the pci bus with the given domain,busnum. | 528 | * it is unnecessary to scan the pci bus with the given domain,busnum. |
@@ -593,6 +594,14 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | |||
593 | return bus; | 594 | return bus; |
594 | } | 595 | } |
595 | 596 | ||
597 | int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) | ||
598 | { | ||
599 | struct pci_sysdata *sd = bridge->bus->sysdata; | ||
600 | |||
601 | ACPI_HANDLE_SET(&bridge->dev, sd->acpi); | ||
602 | return 0; | ||
603 | } | ||
604 | |||
596 | int __init pci_acpi_init(void) | 605 | int __init pci_acpi_init(void) |
597 | { | 606 | { |
598 | struct pci_dev *dev = NULL; | 607 | struct pci_dev *dev = NULL; |