Skip to content

Commit 71bf41b

Browse files
committed
ACPI: EC: Evaluate _REG outside the EC scope more carefully
Commit 60fa6ae ("ACPI: EC: Install address space handler at the namespace root") caused _REG methods for EC operation regions outside the EC device scope to be evaluated which on some systems leads to the evaluation of _REG methods in the scopes of device objects representing devices that are not present and not functional according to the _STA return values. Some of those device objects represent EC "alternatives" and if _REG is evaluated for their operation regions, the platform firmware may be confused and the platform may start to behave incorrectly. To avoid this problem, only evaluate _REG for EC operation regions located in the scopes of device objects representing known-to-be-present devices. For this purpose, partially revert commit 60fa6ae and trigger the evaluation of _REG for EC operation regions from acpi_bus_attach() for the known-valid devices. Fixes: 60fa6ae ("ACPI: EC: Install address space handler at the namespace root") Link: https://lore.kernel.org/linux-acpi/[email protected] Link: https://bugzilla.redhat.com/show_bug.cgi?id=2298938 Link: https://bugzilla.redhat.com/show_bug.cgi?id=2302253 Reported-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Cc: All applicable <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent cdf65d7 commit 71bf41b

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

drivers/acpi/ec.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,12 +1487,13 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec)
14871487
static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
14881488
bool call_reg)
14891489
{
1490-
acpi_handle scope_handle = ec == first_ec ? ACPI_ROOT_OBJECT : ec->handle;
14911490
acpi_status status;
14921491

14931492
acpi_ec_start(ec, false);
14941493

14951494
if (!test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) {
1495+
acpi_handle scope_handle = ec == first_ec ? ACPI_ROOT_OBJECT : ec->handle;
1496+
14961497
acpi_ec_enter_noirq(ec);
14971498
status = acpi_install_address_space_handler_no_reg(scope_handle,
14981499
ACPI_ADR_SPACE_EC,
@@ -1506,7 +1507,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,
15061507
}
15071508

15081509
if (call_reg && !test_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags)) {
1509-
acpi_execute_reg_methods(scope_handle, ACPI_UINT32_MAX, ACPI_ADR_SPACE_EC);
1510+
acpi_execute_reg_methods(ec->handle, ACPI_UINT32_MAX, ACPI_ADR_SPACE_EC);
15101511
set_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags);
15111512
}
15121513

@@ -1721,6 +1722,12 @@ static void acpi_ec_remove(struct acpi_device *device)
17211722
}
17221723
}
17231724

1725+
void acpi_ec_register_opregions(struct acpi_device *adev)
1726+
{
1727+
if (first_ec && first_ec->handle != adev->handle)
1728+
acpi_execute_reg_methods(adev->handle, 1, ACPI_ADR_SPACE_EC);
1729+
}
1730+
17241731
static acpi_status
17251732
ec_parse_io_ports(struct acpi_resource *resource, void *context)
17261733
{

drivers/acpi/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
223223
acpi_handle handle, acpi_ec_query_func func,
224224
void *data);
225225
void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
226+
void acpi_ec_register_opregions(struct acpi_device *adev);
226227

227228
#ifdef CONFIG_PM_SLEEP
228229
void acpi_ec_flush_work(void);

drivers/acpi/scan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,8 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)
22732273
if (device->handler)
22742274
goto ok;
22752275

2276+
acpi_ec_register_opregions(device);
2277+
22762278
if (!device->flags.initialized) {
22772279
device->flags.power_manageable =
22782280
device->power.states[ACPI_STATE_D0].flags.valid;

0 commit comments

Comments
 (0)