OSDN Git Service

ACPI: PM: s2idle: Check fixed wakeup events in acpi_s2idle_wake()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 21 Feb 2020 00:46:18 +0000 (01:46 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 21 Feb 2020 18:01:25 +0000 (10:01 -0800)
Commit fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from
waking up the system") overlooked the fact that fixed events can wake
up the system too and broke RTC wakeup from suspend-to-idle as a
result.

Fix this issue by checking the fixed events in acpi_s2idle_wake() in
addition to checking wakeup GPEs and break out of the suspend-to-idle
loop if the status bits of any enabled fixed events are set then.

Fixes: fdde0ff8590b ("ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system")
Reported-and-tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/acpi/acpica/evevent.c
drivers/acpi/sleep.c
include/acpi/acpixf.h

index 8c83d8c..789d5e9 100644 (file)
@@ -265,4 +265,49 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
                 handler) (acpi_gbl_fixed_event_handlers[event].context));
 }
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_any_fixed_event_status_set
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      TRUE or FALSE
+ *
+ * DESCRIPTION: Checks the PM status register for active fixed events
+ *
+ ******************************************************************************/
+
+u32 acpi_any_fixed_event_status_set(void)
+{
+       acpi_status status;
+       u32 in_status;
+       u32 in_enable;
+       u32 i;
+
+       status = acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &in_enable);
+       if (ACPI_FAILURE(status)) {
+               return (FALSE);
+       }
+
+       status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &in_status);
+       if (ACPI_FAILURE(status)) {
+               return (FALSE);
+       }
+
+       /*
+        * Check for all possible Fixed Events and dispatch those that are active
+        */
+       for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
+
+               /* Both the status and enable bits must be on for this event */
+
+               if ((in_status & acpi_gbl_fixed_event_info[i].status_bit_mask) &&
+                   (in_enable & acpi_gbl_fixed_event_info[i].enable_bit_mask)) {
+                       return (TRUE);
+               }
+       }
+
+       return (FALSE);
+}
+
 #endif                         /* !ACPI_REDUCED_HARDWARE */
index 152f7fc..e5f9592 100644 (file)
@@ -1006,6 +1006,13 @@ static bool acpi_s2idle_wake(void)
                        return true;
 
                /*
+                * If the status bit of any enabled fixed event is set, the
+                * wakeup is regarded as valid.
+                */
+               if (acpi_any_fixed_event_status_set())
+                       return true;
+
+               /*
                 * If there are no EC events to process and at least one of the
                 * other enabled GPEs is active, the wakeup is regarded as a
                 * genuine one.
index 5867777..8e8be98 100644 (file)
@@ -753,6 +753,7 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void))
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void))
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_wakeup_gpes(void))
 ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_gpe_status_set(void))
+ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_fixed_event_status_set(void))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
                                acpi_get_gpe_device(u32 gpe_index,