Commit 5906715b authored by Lv Zheng's avatar Lv Zheng Committed by Greg Kroah-Hartman

ACPI: EC: Fix regression related to wrong ECDT initialization order

commit 98529b92 upstream.

Commit 2a570840 (ACPI / EC: Fix a gap that ECDT EC cannot handle
EC events) introduced acpi_ec_ecdt_start(), but that function is
invoked before acpi_ec_query_init(), which is too early.  This causes
the kernel to crash if an EC event occurs after boot, when ec_query_wq
is not valid:

 BUG: unable to handle kernel NULL pointer dereference at 0000000000000102
 ...
 Workqueue: events acpi_ec_event_handler
 task: ffff9f539790dac0 task.stack: ffffb437c0e10000
 RIP: 0010:__queue_work+0x32/0x430

Normally, the DSDT EC should always be valid, so acpi_ec_ecdt_start()
is actually a no-op in the majority of cases.  However, commit
c712bb58 (ACPI / EC: Add support to skip boot stage DSDT probe)
caused the probing of the DSDT EC as the "boot EC" to be skipped when
the ECDT EC is valid and uncovered the bug.

Fix this issue by invoking acpi_ec_ecdt_start() after acpi_ec_query_init()
in acpi_ec_init().

Link: https://jira01.devtools.intel.com/browse/LCK-4348
Fixes: 2a570840 (ACPI / EC: Fix a gap that ECDT EC cannot handle EC events)
Fixes: c712bb58 (ACPI / EC: Add support to skip boot stage DSDT probe)
Reported-by: default avatarWang Wendy <wendy.wang@intel.com>
Tested-by: default avatarFeng Chenzhou <chenzhoux.feng@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
[ rjw: Changelog ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3bc8e4f9
...@@ -1728,7 +1728,7 @@ int __init acpi_ec_dsdt_probe(void) ...@@ -1728,7 +1728,7 @@ int __init acpi_ec_dsdt_probe(void)
* functioning ECDT EC first in order to handle the events. * functioning ECDT EC first in order to handle the events.
* https://bugzilla.kernel.org/show_bug.cgi?id=115021 * https://bugzilla.kernel.org/show_bug.cgi?id=115021
*/ */
int __init acpi_ec_ecdt_start(void) static int __init acpi_ec_ecdt_start(void)
{ {
acpi_handle handle; acpi_handle handle;
...@@ -1959,20 +1959,17 @@ static inline void acpi_ec_query_exit(void) ...@@ -1959,20 +1959,17 @@ static inline void acpi_ec_query_exit(void)
int __init acpi_ec_init(void) int __init acpi_ec_init(void)
{ {
int result; int result;
int ecdt_fail, dsdt_fail;
/* register workqueue for _Qxx evaluations */ /* register workqueue for _Qxx evaluations */
result = acpi_ec_query_init(); result = acpi_ec_query_init();
if (result) if (result)
goto err_exit; return result;
/* Now register the driver for the EC */
result = acpi_bus_register_driver(&acpi_ec_driver);
if (result)
goto err_exit;
err_exit: /* Drivers must be started after acpi_ec_query_init() */
if (result) ecdt_fail = acpi_ec_ecdt_start();
acpi_ec_query_exit(); dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
return result; return ecdt_fail && dsdt_fail ? -ENODEV : 0;
} }
/* EC driver currently not unloadable */ /* EC driver currently not unloadable */
......
...@@ -185,7 +185,6 @@ typedef int (*acpi_ec_query_func) (void *data); ...@@ -185,7 +185,6 @@ typedef int (*acpi_ec_query_func) (void *data);
int acpi_ec_init(void); int acpi_ec_init(void);
int acpi_ec_ecdt_probe(void); int acpi_ec_ecdt_probe(void);
int acpi_ec_dsdt_probe(void); int acpi_ec_dsdt_probe(void);
int acpi_ec_ecdt_start(void);
void acpi_ec_block_transactions(void); void acpi_ec_block_transactions(void);
void acpi_ec_unblock_transactions(void); void acpi_ec_unblock_transactions(void);
int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
......
...@@ -2051,7 +2051,6 @@ int __init acpi_scan_init(void) ...@@ -2051,7 +2051,6 @@ int __init acpi_scan_init(void)
acpi_gpe_apply_masked_gpes(); acpi_gpe_apply_masked_gpes();
acpi_update_all_gpes(); acpi_update_all_gpes();
acpi_ec_ecdt_start();
acpi_scan_initialized = true; acpi_scan_initialized = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment