Skip to content

Commit

Permalink
ACPI: EC: PM: Avoid flushing EC work when EC GPE is inactive
Browse files Browse the repository at this point in the history
Flushing the EC work while suspended to idle when the EC GPE status
is not set causes some EC wakeup events (notably power button and
lid ones) to be missed after a series of spurious wakeups on the Dell
XPS13 9360 in my office.

If that happens, the machine cannot be woken up from suspend-to-idle
by the power button or lid status change and it needs to be woken up
in some other way (eg. by a key press).

Flushing the EC work only after successful dispatching the EC GPE,
which means that its status has been set, avoids the issue, so change
the code in question accordingly.

Fixes: 7b30175 ("ACPI: EC: PM: Avoid premature returns from acpi_s2idle_wake()")
Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Chris Chiu <chiu@endlessm.com>
  • Loading branch information
Rafael J. Wysocki committed May 18, 2020
1 parent 7b30175 commit 607b9df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 5 additions & 1 deletion drivers/acpi/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2016,9 +2016,13 @@ bool acpi_ec_dispatch_gpe(void)
* to allow the caller to process events properly after that.
*/
ret = acpi_dispatch_gpe(NULL, first_ec->gpe);
if (ret == ACPI_INTERRUPT_HANDLED)
if (ret == ACPI_INTERRUPT_HANDLED) {
pm_pr_dbg("EC GPE dispatched\n");

/* Flush the event and query workqueues. */
acpi_ec_flush_work();
}

return false;
}
#endif /* CONFIG_PM_SLEEP */
Expand Down
15 changes: 4 additions & 11 deletions drivers/acpi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,13 +980,6 @@ static int acpi_s2idle_prepare_late(void)
return 0;
}

static void acpi_s2idle_sync(void)
{
/* The EC driver uses special workqueues that need to be flushed. */
acpi_ec_flush_work();
acpi_os_wait_events_complete(); /* synchronize Notify handling */
}

static bool acpi_s2idle_wake(void)
{
if (!acpi_sci_irq_valid())
Expand Down Expand Up @@ -1018,16 +1011,15 @@ static bool acpi_s2idle_wake(void)
return true;

/*
* Cancel the wakeup and process all pending events in case
* Cancel the SCI wakeup and process all pending events in case
* there are any wakeup ones in there.
*
* Note that if any non-EC GPEs are active at this point, the
* SCI will retrigger after the rearming below, so no events
* should be missed by canceling the wakeup here.
*/
pm_system_cancel_wakeup();

acpi_s2idle_sync();
acpi_os_wait_events_complete();

/*
* The SCI is in the "suspended" state now and it cannot produce
Expand Down Expand Up @@ -1060,7 +1052,8 @@ static void acpi_s2idle_restore(void)
* of GPEs.
*/
acpi_os_wait_events_complete(); /* synchronize GPE processing */
acpi_s2idle_sync();
acpi_ec_flush_work(); /* flush the EC driver's workqueues */
acpi_os_wait_events_complete(); /* synchronize Notify handling */

s2idle_wakeup = false;

Expand Down

0 comments on commit 607b9df

Please sign in to comment.