mbox series

[RFC,v2,0/2] ACPI[CA]: fix ECDT EC probe ordering issues

Message ID 20220706201410.88244-1-hdegoede@redhat.com
Headers show
Series ACPI[CA]: fix ECDT EC probe ordering issues | expand

Message

Hans de Goede July 6, 2022, 8:14 p.m. UTC
Hi All,

Here is v2 of my series fixing some ECDT EC probe ordering issues which
are causing issues om some laptops:

https://bugzilla.kernel.org/show_bug.cgi?id=214899

This is a RFC because fixing this requires some ACPICA changes which
obviously need to go upstream through the ACPICA project.

The problem this fixed is best described by the commit message of patch 2:

ACPI-2.0 says that the EC OpRegion handler must be available immediately
(like the standard default OpRegion handlers):

Quoting from the ACPI spec version 6.3: "6.5.4 _REG (Region) ...
2. OSPM must make Embedded Controller operation regions, accessed via
the Embedded Controllers described in ECDT, available before executing
any control method. These operation regions may become inaccessible
after OSPM runs _REG(EmbeddedControl, 0)."

So acpi_bus_init() calls acpi_ec_ecdt_probe(), which calls
acpi_install_address_space_handler() to install the EC's OpRegion
handler, early on.

This not only installs the OpRegion handler, but also calls the EC's
_REG method. The _REG method call is a problem because it may rely on
initialization done by the _INI methods of one of the PCI / _SB root devs,
see for example: https://bugzilla.kernel.org/show_bug.cgi?id=214899 .

Generally speaking _REG methods are executed when the ACPI-device they
are part of has a driver bound to it. Where as _INI methods must be
executed at table load time (according to the spec). The problem here
is that the early acpi_install_address_space_handler() call causes
the _REG handler to run too early.

To allow fixing this the ACPICA code now allows to split the OpRegion
handler installation and the executing of _REG into 2 separate steps.

This commit uses this ACPICA functionality to fix the EC probe ordering
by delaying the executing of _REG for ECDT described ECs till the matching
EC device in the DSDT gets parsed and acpi_ec_add() for it gets called.
This moves the calling of _REG for the EC on devices with an ECDT to
the same point in time where it is called on devices without an ECDT table.

Regards,

Hans


Hans de Goede (2):
  ACPICA: Make address_space_handler Install and _REG execution 2
    separate steps
  ACPI: EC: fix ECDT probe ordering issues

 drivers/acpi/acpica/evxfregn.c | 32 +++++++++++++++++++------------
 drivers/acpi/ec.c              | 33 ++++++++++++++++++++++----------
 include/acpi/acpixf.h          | 35 +++++++++++++++++++++++++---------
 include/acpi/actypes.h         |  2 ++
 4 files changed, 71 insertions(+), 31 deletions(-)