diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-05-27 19:39:53 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-05-27 19:39:53 -0400 |
commit | dc4fdaf0e4839109169d8261814813816951c75f (patch) | |
tree | e6eaba2f03f568e051b0be16211f7160db0eaaea | |
parent | ba155e2d21f6bf05de86a78dbe5bfd8757604a65 (diff) |
PCI / ACPI: Do not set ACPI companions for host bridges with parents
Commit 97badf873ab6 (device property: Make it possible to use
secondary firmware nodes) uncovered a bug in the x86 (and ia64) PCI
host bridge initialization code that assumes bridge->bus->sysdata
to always point to a struct pci_sysdata object which need not be
the case (in particular, the Xen PCI frontend driver sets it to point
to a different data type). If it is not the case, an incorrect
pointer (or a piece of data that is not a pointer at all) will be
passed to ACPI_COMPANION_SET() and that may cause interesting
breakage to happen going forward.
To work around this problem use the observation that the ACPI
host bridge initialization always passes NULL as parent to
pci_create_root_bus(), so if pcibios_root_bridge_prepare() sees
a non-NULL parent of the bridge, it should not attempt to set
an ACPI companion for it, because that means that
pci_create_root_bus() has been called by someone else.
Fixes: 97badf873ab6 (device property: Make it possible to use secondary firmware nodes)
Reported-and-tested-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r-- | arch/ia64/pci/pci.c | 13 | ||||
-rw-r--r-- | arch/x86/pci/acpi.c | 13 |
2 files changed, 20 insertions, 6 deletions
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index d4e162d35b34..7cc3be9fa7c6 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c | |||
@@ -478,9 +478,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
478 | 478 | ||
479 | int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) | 479 | int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) |
480 | { | 480 | { |
481 | struct pci_controller *controller = bridge->bus->sysdata; | 481 | /* |
482 | 482 | * We pass NULL as parent to pci_create_root_bus(), so if it is not NULL | |
483 | ACPI_COMPANION_SET(&bridge->dev, controller->companion); | 483 | * here, pci_create_root_bus() has been called by someone else and |
484 | * sysdata is likely to be different from what we expect. Let it go in | ||
485 | * that case. | ||
486 | */ | ||
487 | if (!bridge->dev.parent) { | ||
488 | struct pci_controller *controller = bridge->bus->sysdata; | ||
489 | ACPI_COMPANION_SET(&bridge->dev, controller->companion); | ||
490 | } | ||
484 | return 0; | 491 | return 0; |
485 | } | 492 | } |
486 | 493 | ||
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index d93963340c3c..14a63ed6fe09 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -482,9 +482,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
482 | 482 | ||
483 | int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) | 483 | int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) |
484 | { | 484 | { |
485 | struct pci_sysdata *sd = bridge->bus->sysdata; | 485 | /* |
486 | 486 | * We pass NULL as parent to pci_create_root_bus(), so if it is not NULL | |
487 | ACPI_COMPANION_SET(&bridge->dev, sd->companion); | 487 | * here, pci_create_root_bus() has been called by someone else and |
488 | * sysdata is likely to be different from what we expect. Let it go in | ||
489 | * that case. | ||
490 | */ | ||
491 | if (!bridge->dev.parent) { | ||
492 | struct pci_sysdata *sd = bridge->bus->sysdata; | ||
493 | ACPI_COMPANION_SET(&bridge->dev, sd->companion); | ||
494 | } | ||
488 | return 0; | 495 | return 0; |
489 | } | 496 | } |
490 | 497 | ||