Skip to content

Commit 7b30175

Browse files
committed
ACPI: EC: PM: Avoid premature returns from acpi_s2idle_wake()
If the EC GPE status is not set after checking all of the other GPEs, acpi_s2idle_wake() returns 'false', to indicate that the SCI event that has just triggered is not a system wakeup one, but it does that without canceling the pending wakeup and re-arming the SCI for system wakeup which is a mistake, because it may cause s2idle_loop() to busy spin until the next valid wakeup event. [If that happens, the first spurious wakeup is still pending after acpi_s2idle_wake() has returned, so s2idle_enter() does nothing, acpi_s2idle_wake() is called again and it sees that the SCI has triggered, but no GPEs are active, so 'false' is returned again, and so on.] Fix that by moving all of the GPE checking logic from acpi_s2idle_wake() to acpi_ec_dispatch_gpe() and making the latter return 'true' only if a non-EC GPE has triggered and 'false' otherwise, which will cause acpi_s2idle_wake() to cancel the pending SCI wakeup and re-arm the SCI for system wakeup regardless of the EC GPE status. This also addresses a lockup observed on an Elitegroup EF20EA laptop after attempting to wake it up from suspend-to-idle by a key press. Fixes: d540628 ("ACPI: PM: s2idle: Refine active GPEs check") Link: https://bugzilla.kernel.org/show_bug.cgi?id=207603 Reported-by: Todd Brandt <[email protected]> Fixes: fdde0ff ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system") Link: https://lore.kernel.org/linux-acpi/CAB4CAwdqo7=MvyG_PE+PGVfeA17AHF5i5JucgaKqqMX6mjArbQ@mail.gmail.com/ Reported-by: Chris Chiu <[email protected]> Tested-by: Chris Chiu <[email protected]> Cc: 5.4+ <[email protected]> # 5.4+ Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 0e698df commit 7b30175

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

drivers/acpi/ec.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,23 +1994,31 @@ void acpi_ec_set_gpe_wake_mask(u8 action)
19941994
acpi_set_gpe_wake_mask(NULL, first_ec->gpe, action);
19951995
}
19961996

1997-
bool acpi_ec_other_gpes_active(void)
1998-
{
1999-
return acpi_any_gpe_status_set(first_ec ? first_ec->gpe : U32_MAX);
2000-
}
2001-
20021997
bool acpi_ec_dispatch_gpe(void)
20031998
{
20041999
u32 ret;
20052000

20062001
if (!first_ec)
2002+
return acpi_any_gpe_status_set(U32_MAX);
2003+
2004+
/*
2005+
* Report wakeup if the status bit is set for any enabled GPE other
2006+
* than the EC one.
2007+
*/
2008+
if (acpi_any_gpe_status_set(first_ec->gpe))
2009+
return true;
2010+
2011+
if (ec_no_wakeup)
20072012
return false;
20082013

2014+
/*
2015+
* Dispatch the EC GPE in-band, but do not report wakeup in any case
2016+
* to allow the caller to process events properly after that.
2017+
*/
20092018
ret = acpi_dispatch_gpe(NULL, first_ec->gpe);
2010-
if (ret == ACPI_INTERRUPT_HANDLED) {
2019+
if (ret == ACPI_INTERRUPT_HANDLED)
20112020
pm_pr_dbg("EC GPE dispatched\n");
2012-
return true;
2013-
}
2021+
20142022
return false;
20152023
}
20162024
#endif /* CONFIG_PM_SLEEP */

drivers/acpi/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
202202

203203
#ifdef CONFIG_PM_SLEEP
204204
void acpi_ec_flush_work(void);
205-
bool acpi_ec_other_gpes_active(void);
206205
bool acpi_ec_dispatch_gpe(void);
207206
#endif
208207

drivers/acpi/sleep.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,20 +1013,10 @@ static bool acpi_s2idle_wake(void)
10131013
if (acpi_check_wakeup_handlers())
10141014
return true;
10151015

1016-
/*
1017-
* If the status bit is set for any enabled GPE other than the
1018-
* EC one, the wakeup is regarded as a genuine one.
1019-
*/
1020-
if (acpi_ec_other_gpes_active())
1016+
/* Check non-EC GPE wakeups and dispatch the EC GPE. */
1017+
if (acpi_ec_dispatch_gpe())
10211018
return true;
10221019

1023-
/*
1024-
* If the EC GPE status bit has not been set, the wakeup is
1025-
* regarded as a spurious one.
1026-
*/
1027-
if (!acpi_ec_dispatch_gpe())
1028-
return false;
1029-
10301020
/*
10311021
* Cancel the wakeup and process all pending events in case
10321022
* there are any wakeup ones in there.

0 commit comments

Comments
 (0)