[PATCH] platform/x86/intel/hid: Ignore power button release in wakeup mode

From: Enrik Berkhan
Date: Mon Apr 01 2024 - 10:06:14 EST


Since commit 0c4cae1bc00d ("PM: hibernate: Avoid missing wakeup events
during hibernation"), the return value of hibernation_platform_enter() is
used. This will, for example, cancel every hibernation attempt if a wakeup
event is registered during the (long) preparation time needed before
entering platform hibernate mode.

As reported in https://bugzilla.kernel.org/show_bug.cgi?id=218634 several
notebooks will fail to hibernate since then, logging "PM: hibernation:
Wakeup event detected during hibernation, rolling back." (Looks like mostly
Dell systems are affected.)

A little investigation has shown that at least one affected device's "Intel
5 button array" sends spurious "Power button release" events (0xCF) in this
case. Most probably, this is completely independent from the
hibernation_platform_enter() change above, and even with kernels before
6.8, the hibernation was probably not fully prepared before halting the
system, i.e., hibernation_platform_enter() may have failed early and the
failure has been ignored.

It ist he spurious "Power button release" event that leads to a wakeup
during the hibernation preparation. Therefore, ignore these events while
the intel-hid driver is in "wakeup mode". "Power button press" will still
be processed as before to not disturb the wakeup from S2Idle.

Only tested on one Dell Inspiron 16 (7640) having BIOS 1.3.0, so far.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=218634
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218634

Signed-off-by: Enrik Berkhan <Enrik.Berkhan@xxxxxxx>
---
drivers/platform/x86/intel/hid.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/platform/x86/intel/hid.c b/drivers/platform/x86/intel/hid.c
index 7457ca2b27a6..9df4a114334a 100644
--- a/drivers/platform/x86/intel/hid.c
+++ b/drivers/platform/x86/intel/hid.c
@@ -528,6 +528,13 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
*/
if (event == 0xce)
goto wakeup;
+ /*
+ * Other platforms may send spurious notifies for power button
+ * release while entering hibernation mode. Ignore these in
+ * wakeup mode.
+ */
+ if (event == 0xcf)
+ return;

/*
* Some devices send (duplicate) tablet-mode events when moved
--
2.44.0