linux/include/acpi
Rafael J. Wysocki 60f75b8e97 ACPI: Try harder to resolve _ADR collisions for bridges
In theory, under a given ACPI namespace node there should be only
one child device object with _ADR whose value matches a given bus
address exactly.  In practice, however, there are systems in which
multiple child device objects under a given parent have _ADR matching
exactly the same address.  In those cases we use _STA to determine
which of the multiple matching devices is enabled, since some systems
are known to indicate which ACPI device object to associate with the
given physical (usually PCI) device this way.

Unfortunately, as it turns out, there are systems in which many
device objects under the same parent have _ADR matching exactly the
same bus address and none of them has _STA, in which case they all
should be regarded as enabled according to the spec.  Still, if
those device objects are supposed to represent bridges (e.g. this
is the case for device objects corresponding to PCIe ports), we can
try harder and skip the ones that have no child device objects in the
ACPI namespace.  With luck, we can avoid using device objects that we
are not expected to use this way.

Although this only works for bridges whose children also have ACPI
namespace representation, it is sufficient to address graphics
adapter detection issues on some systems, so rework the code finding
a matching device ACPI handle for a given bus address to implement
this idea.

Introduce a new function, acpi_find_child(), taking three arguments:
the ACPI handle of the device's parent, a bus address suitable for
the device's bus type and a bool indicating if the device is a
bridge and make it work as outlined above.  Reimplement the function
currently used for this purpose, acpi_get_child(), as a call to
acpi_find_child() with the last argument set to 'false' and make
the PCI subsystem use acpi_find_child() with the bridge information
passed as the last argument to it.  [Lan Tianyu notices that it is
not sufficient to use pci_is_bridge() for that, because the device's
subordinate pointer hasn't been set yet at this point, so use
hdr_type instead.]

This change fixes a regression introduced inadvertently by commit
33f767d (ACPI: Rework acpi_get_child() to be more efficient) which
overlooked the fact that for acpi_walk_namespace() "post-order" means
"after all children have been visited" rather than "on the way back",
so for device objects without children and for namespace walks of
depth 1, as in the acpi_get_child() case, the "post-order" callbacks
ordering is actually the same as the ordering of "pre-order" ones.
Since that commit changed the namespace walk in acpi_get_child() to
terminate after finding the first matching object instead of going
through all of them and returning the last one, it effectively
changed the result returned by that function in some rare cases and
that led to problems (the switch from a "pre-order" to a "post-order"
callback was supposed to prevent that from happening, but it was
ineffective).

As it turns out, the systems where the change made by commit
33f767d actually matters are those where there are multiple ACPI
device objects representing the same PCIe port (which effectively
is a bridge).  Moreover, only one of them, and the one we are
expected to use, has child device objects in the ACPI namespace,
so the regression can be addressed as described above.

References: https://bugzilla.kernel.org/show_bug.cgi?id=60561
Reported-by: Peter Wu <lekensteyn@gmail.com>
Tested-by: Vladimir Lalov <mail@vlalov.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: 3.9+ <stable@vger.kernel.org> # 3.9+
2013-08-07 22:55:00 +02:00
..
platform ACPICA: Update ACPICA copyrights to 2013 2013-01-25 13:30:47 +01:00
acbuffer.h ACPICA: Update ACPICA copyrights to 2013 2013-01-25 13:30:47 +01:00
acconfig.h ACPICA: Add argument typechecking for all predefined ACPI names 2013-06-01 21:54:30 +02:00
acexcep.h ACPICA: Add exception descriptions to exception info table 2013-03-12 00:45:05 +01:00
acnames.h ACPICA: Update ACPICA copyrights to 2013 2013-01-25 13:30:47 +01:00
acoutput.h ACPICA: Remove unused macros, no functional change 2013-06-01 21:54:31 +02:00
acpi.h ACPICA: Update ACPICA copyrights to 2013 2013-01-25 13:30:47 +01:00
acpi_bus.h ACPI: Try harder to resolve _ADR collisions for bridges 2013-08-07 22:55:00 +02:00
acpi_drivers.h ACPI / dock / PCI: Synchronous handling of dock events for PCI devices 2013-06-24 11:22:53 +02:00
acpi_numa.h ACPI: Store SRAT table revision 2012-01-17 04:19:04 -05:00
acpiosxf.h ACPI: Fix section to __init. Align with usage in acpixf.h 2013-05-12 14:03:14 +02:00
acpixf.h ACPICA: expose OSI version 2013-07-18 01:29:14 +02:00
acrestyp.h ACPICA: Update ACPICA copyrights to 2013 2013-01-25 13:30:47 +01:00
actbl.h ACPICA: Update ACPICA copyrights to 2013 2013-01-25 13:30:47 +01:00
actbl1.h ACPICA: Update ACPICA copyrights to 2013 2013-01-25 13:30:47 +01:00
actbl2.h ACPICA: iASL/Disassembler: Add support for MTMR table 2013-03-12 00:45:04 +01:00
actbl3.h ACPICA: Remove trailing comma in enum declarations 2013-03-12 00:45:05 +01:00
actypes.h ACPICA: expose OSI version 2013-07-18 01:29:14 +02:00
apei.h module_param: make bool parameters really bool (drivers & misc) 2012-01-13 09:32:20 +10:30
button.h
ghes.h ghes: add the needed hooks for EDAC error report 2013-02-25 19:41:51 -03:00
hed.h
pdc_intel.h
processor.h ACPI / processor: Use common hotplug infrastructure 2013-05-12 14:14:32 +02:00
reboot.h
video.h Revert "ACPI / video / i915: No ACPI backlight if firmware expects Windows 8" 2013-07-26 14:59:20 +02:00