Skip to content

Commit

Permalink
ACPI: PM: s2idle: Rework ACPI events synchronization
Browse files Browse the repository at this point in the history
Note that the EC GPE processing need not be synchronized in
acpi_s2idle_wake() after invoking acpi_ec_dispatch_gpe(), because
that function checks the GPE status and dispatches its handler if
need be and the SCI action handler is not going to run anyway at
that point.

Moreover, it is better to drain all of the pending ACPI events
before restoring the working-state configuration of GPEs in
acpi_s2idle_restore(), because those events are likely to be related
to system wakeup, in which case they will not be relevant going
forward.

Rework the code to take these observations into account.

Tested-by: Kenneth R. Crudup <kenny@panix.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Rafael J. Wysocki committed Dec 2, 2019
1 parent 016b87c commit 024aa87
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions drivers/acpi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,16 @@ static int acpi_s2idle_prepare_late(void)
return 0;
}

static void acpi_s2idle_sync(void)
{
/*
* The EC driver uses the system workqueue and an additional special
* one, so those need to be flushed too.
*/
acpi_ec_flush_work();
acpi_os_wait_events_complete(); /* synchronize Notify handling */
}

static void acpi_s2idle_wake(void)
{
/*
Expand All @@ -1001,13 +1011,8 @@ static void acpi_s2idle_wake(void)
* should be missed by canceling the wakeup here.
*/
pm_system_cancel_wakeup();
/*
* The EC driver uses the system workqueue and an additional
* special one, so those need to be flushed too.
*/
acpi_os_wait_events_complete(); /* synchronize EC GPE processing */
acpi_ec_flush_work();
acpi_os_wait_events_complete(); /* synchronize Notify handling */

acpi_s2idle_sync();

rearm_wake_irq(acpi_sci_irq);
}
Expand All @@ -1024,6 +1029,13 @@ static void acpi_s2idle_restore_early(void)

static void acpi_s2idle_restore(void)
{
/*
* Drain pending events before restoring the working-state configuration
* of GPEs.
*/
acpi_os_wait_events_complete(); /* synchronize GPE processing */
acpi_s2idle_sync();

s2idle_wakeup = false;

acpi_enable_all_runtime_gpes();
Expand Down

0 comments on commit 024aa87

Please sign in to comment.