Skip to content

Commit a64a62c

Browse files
Lv Zhengrafaeljw
authored andcommitted
ACPI / EC: Fix regression related to PM ops support in ECDT device
On platforms (ASUS X550ZE and possibly all ASUS X series) with valid ECDT EC but invalid DSDT EC, EC PM ops won't be invoked as ECDT EC is not an ACPI device. Thus the following commit actually removed post-resume acpi_ec_enable_event() invocation for such platforms, and triggered a regression on them that after being resumed, EC (actually should be ECDT) driver stops handling EC events: Commit: c2b46d6 Subject: ACPI / EC: Add PM operations to improve event handling for resume process Notice that the root cause actually is "ECDT is not an ACPI device" rather than "the timing of acpi_ec_enable_event() invocation", this patch fixes this issue by enumerating ECDT EC as an ACPI device. Due to the existence of the noirq stage, the ability of tuning the timing of acpi_ec_enable_event() invocation is still meaningful. This patch is a little bit different from the posted fix by moving acpi_config_boot_ec() from acpi_ec_ecdt_start() to acpi_ec_add() to make sure that EC event handling won't be stopped as long as the ACPI EC driver is bound. Thus the following sequence shouldn't disable EC event handling: unbind,suspend,resume,bind. Fixes: c2b46d6 (ACPI / EC: Add PM operations to improve event handling for resume process) Link: https://bugzilla.kernel.org/show_bug.cgi?id=196847 Reported-by: Luya Tshimbalanga <luya@fedoraproject.org> Tested-by: Luya Tshimbalanga <luya@fedoraproject.org> Cc: 4.9+ <stable@vger.kernel.org> # 4.9+ Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 53c5eaa commit a64a62c

File tree

5 files changed

+69
-24
lines changed

5 files changed

+69
-24
lines changed

drivers/acpi/ec.c

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,32 +1597,41 @@ static int acpi_ec_add(struct acpi_device *device)
15971597
{
15981598
struct acpi_ec *ec = NULL;
15991599
int ret;
1600+
bool is_ecdt = false;
1601+
acpi_status status;
16001602

16011603
strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
16021604
strcpy(acpi_device_class(device), ACPI_EC_CLASS);
16031605

1604-
ec = acpi_ec_alloc();
1605-
if (!ec)
1606-
return -ENOMEM;
1607-
if (ec_parse_device(device->handle, 0, ec, NULL) !=
1608-
AE_CTRL_TERMINATE) {
1606+
if (!strcmp(acpi_device_hid(device), ACPI_ECDT_HID)) {
1607+
is_ecdt = true;
1608+
ec = boot_ec;
1609+
} else {
1610+
ec = acpi_ec_alloc();
1611+
if (!ec)
1612+
return -ENOMEM;
1613+
status = ec_parse_device(device->handle, 0, ec, NULL);
1614+
if (status != AE_CTRL_TERMINATE) {
16091615
ret = -EINVAL;
16101616
goto err_alloc;
1617+
}
16111618
}
16121619

16131620
if (acpi_is_boot_ec(ec)) {
1614-
boot_ec_is_ecdt = false;
1615-
/*
1616-
* Trust PNP0C09 namespace location rather than ECDT ID.
1617-
*
1618-
* But trust ECDT GPE rather than _GPE because of ASUS quirks,
1619-
* so do not change boot_ec->gpe to ec->gpe.
1620-
*/
1621-
boot_ec->handle = ec->handle;
1622-
acpi_handle_debug(ec->handle, "duplicated.\n");
1623-
acpi_ec_free(ec);
1624-
ec = boot_ec;
1625-
ret = acpi_config_boot_ec(ec, ec->handle, true, false);
1621+
boot_ec_is_ecdt = is_ecdt;
1622+
if (!is_ecdt) {
1623+
/*
1624+
* Trust PNP0C09 namespace location rather than
1625+
* ECDT ID. But trust ECDT GPE rather than _GPE
1626+
* because of ASUS quirks, so do not change
1627+
* boot_ec->gpe to ec->gpe.
1628+
*/
1629+
boot_ec->handle = ec->handle;
1630+
acpi_handle_debug(ec->handle, "duplicated.\n");
1631+
acpi_ec_free(ec);
1632+
ec = boot_ec;
1633+
}
1634+
ret = acpi_config_boot_ec(ec, ec->handle, true, is_ecdt);
16261635
} else
16271636
ret = acpi_ec_setup(ec, true);
16281637
if (ret)
@@ -1635,8 +1644,10 @@ static int acpi_ec_add(struct acpi_device *device)
16351644
ret = !!request_region(ec->command_addr, 1, "EC cmd");
16361645
WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr);
16371646

1638-
/* Reprobe devices depending on the EC */
1639-
acpi_walk_dep_device_list(ec->handle);
1647+
if (!is_ecdt) {
1648+
/* Reprobe devices depending on the EC */
1649+
acpi_walk_dep_device_list(ec->handle);
1650+
}
16401651
acpi_handle_debug(ec->handle, "enumerated.\n");
16411652
return 0;
16421653

@@ -1692,6 +1703,7 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context)
16921703

16931704
static const struct acpi_device_id ec_device_ids[] = {
16941705
{"PNP0C09", 0},
1706+
{ACPI_ECDT_HID, 0},
16951707
{"", 0},
16961708
};
16971709

@@ -1764,11 +1776,14 @@ static int __init acpi_ec_ecdt_start(void)
17641776
* Note: ec->handle can be valid if this function is called after
17651777
* acpi_ec_add(), hence the fast path.
17661778
*/
1767-
if (boot_ec->handle != ACPI_ROOT_OBJECT)
1768-
handle = boot_ec->handle;
1769-
else if (!acpi_ec_ecdt_get_handle(&handle))
1770-
return -ENODEV;
1771-
return acpi_config_boot_ec(boot_ec, handle, true, true);
1779+
if (boot_ec->handle == ACPI_ROOT_OBJECT) {
1780+
if (!acpi_ec_ecdt_get_handle(&handle))
1781+
return -ENODEV;
1782+
boot_ec->handle = handle;
1783+
}
1784+
1785+
/* Register to ACPI bus with PM ops attached */
1786+
return acpi_bus_register_early_device(ACPI_BUS_TYPE_ECDT_EC);
17721787
}
17731788

17741789
#if 0
@@ -2020,6 +2035,12 @@ int __init acpi_ec_init(void)
20202035

20212036
/* Drivers must be started after acpi_ec_query_init() */
20222037
dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
2038+
/*
2039+
* Register ECDT to ACPI bus only when PNP0C09 probe fails. This is
2040+
* useful for platforms (confirmed on ASUS X550ZE) with valid ECDT
2041+
* settings but invalid DSDT settings.
2042+
* https://bugzilla.kernel.org/show_bug.cgi?id=196847
2043+
*/
20232044
ecdt_fail = acpi_ec_ecdt_start();
20242045
return ecdt_fail && dsdt_fail ? -ENODEV : 0;
20252046
}

drivers/acpi/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ bool acpi_device_is_present(const struct acpi_device *adev);
115115
bool acpi_device_is_battery(struct acpi_device *adev);
116116
bool acpi_device_is_first_physical_node(struct acpi_device *adev,
117117
const struct device *dev);
118+
int acpi_bus_register_early_device(int type);
118119

119120
/* --------------------------------------------------------------------------
120121
Device Matching and Notification

drivers/acpi/scan.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,9 @@ static void acpi_device_get_busid(struct acpi_device *device)
10241024
case ACPI_BUS_TYPE_SLEEP_BUTTON:
10251025
strcpy(device->pnp.bus_id, "SLPF");
10261026
break;
1027+
case ACPI_BUS_TYPE_ECDT_EC:
1028+
strcpy(device->pnp.bus_id, "ECDT");
1029+
break;
10271030
default:
10281031
acpi_get_name(device->handle, ACPI_SINGLE_NAME, &buffer);
10291032
/* Clean up trailing underscores (if any) */
@@ -1304,6 +1307,9 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
13041307
case ACPI_BUS_TYPE_SLEEP_BUTTON:
13051308
acpi_add_id(pnp, ACPI_BUTTON_HID_SLEEPF);
13061309
break;
1310+
case ACPI_BUS_TYPE_ECDT_EC:
1311+
acpi_add_id(pnp, ACPI_ECDT_HID);
1312+
break;
13071313
}
13081314
}
13091315

@@ -2049,6 +2055,21 @@ void acpi_bus_trim(struct acpi_device *adev)
20492055
}
20502056
EXPORT_SYMBOL_GPL(acpi_bus_trim);
20512057

2058+
int acpi_bus_register_early_device(int type)
2059+
{
2060+
struct acpi_device *device = NULL;
2061+
int result;
2062+
2063+
result = acpi_add_single_object(&device, NULL,
2064+
type, ACPI_STA_DEFAULT);
2065+
if (result)
2066+
return result;
2067+
2068+
device->flags.match_driver = true;
2069+
return device_attach(&device->dev);
2070+
}
2071+
EXPORT_SYMBOL_GPL(acpi_bus_register_early_device);
2072+
20522073
static int acpi_bus_scan_fixed(void)
20532074
{
20542075
int result = 0;

include/acpi/acpi_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ enum acpi_bus_device_type {
105105
ACPI_BUS_TYPE_THERMAL,
106106
ACPI_BUS_TYPE_POWER_BUTTON,
107107
ACPI_BUS_TYPE_SLEEP_BUTTON,
108+
ACPI_BUS_TYPE_ECDT_EC,
108109
ACPI_BUS_DEVICE_TYPE_COUNT
109110
};
110111

include/acpi/acpi_drivers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#define ACPI_VIDEO_HID "LNXVIDEO"
5959
#define ACPI_BAY_HID "LNXIOBAY"
6060
#define ACPI_DOCK_HID "LNXDOCK"
61+
#define ACPI_ECDT_HID "LNXEC"
6162
/* Quirk for broken IBM BIOSes */
6263
#define ACPI_SMBUS_IBM_HID "SMBUSIBM"
6364

0 commit comments

Comments
 (0)