Skip to contentSkip to conversation

platform/x86: intel-hid: Fix spurious wakeups caused by tablet-mode events during suspend

PATCH In review Hans de Goede 2 participants 3 messages Apr 4, 2021 – Apr 6, 2021 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: intel-hid: Fix spurious wakeups caused by tablet-mode events during suspend

Some devices send (duplicate) tablet-mode events when moved around even though the mode has not changed; and they do this even when suspended.

Change the tablet-mode event handling when priv->wakeup_mode is set to update the switch state in case it changed and then return immediately (without calling pm_wakeup_hard_event()) to avoid spurious wakeups.

Fixes 537b0dd4729e ("platform/x86: intel-hid: Add support for SW_TABLET_MODE")
---
 drivers/platform/x86/intel-hid.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/platform/x86/intel-hid.c +9 -7
index 57cc92891a57..078648a9201b 100644
@@ -483,11 +483,16 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 			goto wakeup;
 
 		/*
-		 * Switch events will wake the device and report the new switch
-		 * position to the input subsystem.
+		 * Some devices send (duplicate) tablet-mode events when moved
+		 * around even though the mode has not changed; and they do this
+		 * even when suspended.
+		 * Update the switch state in case it changed and then return
+		 * without waking up to avoid spurious wakeups.
 		 */
-		if (priv->switches && (event == 0xcc || event == 0xcd))
-			goto wakeup;
+		if (event == 0xcc || event == 0xcd) {
+			report_tablet_mode_event(priv->switches, event);
+			return;
+		}
 
 		/* Wake up on 5-button array events only. */
 		if (event == 0xc0 || !priv->array)
@@ -501,9 +506,6 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 wakeup:
 		pm_wakeup_hard_event(&device->dev);
 
-		if (report_tablet_mode_event(priv->switches, event))
-			return;
-
 		return;
 	}
 
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw

Hi Hans,

Quoted 49 lines

Some devices send (duplicate) tablet-mode events when moved around even though the mode has not changed; and they do this even when suspended.

Change the tablet-mode event handling when priv->wakeup_mode is set to update the switch state in case it changed and then return immediately (without calling pm_wakeup_hard_event()) to avoid spurious wakeups.

Fixes 537b0dd4729e ("platform/x86: intel-hid: Add support for

SW_TABLET_MODE")

---
 drivers/platform/x86/intel-hid.c | 16 +++++++++-------

 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/platform/x86/intel-hid.c +0 -0
index 57cc92891a57..078648a9201b 100644
@@ -483,11 +483,16 @@ static void notify_handler(acpi_handle handle,
 u32 event, void *context)
                         goto wakeup;


                /*
-                * Switch events will wake the device and report the new switch
-                * position to the input subsystem.
+                * Some devices send (duplicate) tablet-mode events when moved
+                * around even though the mode has not changed; and they do this
+                * even when suspended.
+                * Update the switch state in case it changed and then return
+                * without waking up to avoid spurious wakeups. */
-               if (priv->switches && (event == 0xcc || event == 0xcd)) -                       goto wakeup;
+               if (event == 0xcc || event == 0xcd) {
+                       report_tablet_mode_event(priv->switches, event);
+                       return;
+               }

                /* Wake up on 5-button array events only. */ if (event == 0xc0 || !priv->array)

drivers/platform/x86/intel-hid.c +0 -0
@@ -501,9 +506,6 @@ static void notify_handler(acpi_handle handle, u32
 event, void *context)
Quoted 9 lines

 wakeup:
                pm_wakeup_hard_event(&device->dev);

-               if (report_tablet_mode_event(priv->switches, event)) -                       return;
-
                return;
        }

No regression noted on HP Spectre x360 15-df0xxx.

Regards,
Elia

#2 lore raw

Hi,

Quoted 62 lines · Elia Devito

Hi Hans,

Quoted 49 lines

Some devices send (duplicate) tablet-mode events when moved around even though the mode has not changed; and they do this even when suspended.

Change the tablet-mode event handling when priv->wakeup_mode is set to update the switch state in case it changed and then return immediately (without calling pm_wakeup_hard_event()) to avoid spurious wakeups.

Fixes 537b0dd4729e ("platform/x86: intel-hid: Add support for

SW_TABLET_MODE")

---
 drivers/platform/x86/intel-hid.c | 16 +++++++++-------

 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/platform/x86/intel-hid.c +0 -0
index 57cc92891a57..078648a9201b 100644
@@ -483,11 +483,16 @@ static void notify_handler(acpi_handle handle,
 u32 event, void *context)
                         goto wakeup;


                /*
-                * Switch events will wake the device and report the new switch
-                * position to the input subsystem.
+                * Some devices send (duplicate) tablet-mode events when moved
+                * around even though the mode has not changed; and they do this
+                * even when suspended.
+                * Update the switch state in case it changed and then return
+                * without waking up to avoid spurious wakeups. */
-               if (priv->switches && (event == 0xcc || event == 0xcd)) -                       goto wakeup;
+               if (event == 0xcc || event == 0xcd) {
+                       report_tablet_mode_event(priv->switches, event);
+                       return;
+               }

                /* Wake up on 5-button array events only. */ if (event == 0xc0 || !priv->array)

drivers/platform/x86/intel-hid.c +0 -0
@@ -501,9 +506,6 @@ static void notify_handler(acpi_handle handle, u32
 event, void *context)
Quoted 9 lines

 wakeup:
                pm_wakeup_hard_event(&device->dev);

-               if (report_tablet_mode_event(priv->switches, event)) -                       return;
-
                return;
        }

No regression noted on HP Spectre x360 15-df0xxx.

Quoted 1 line

Thank you for the testing and the review. I'll push this out to the for-next and fixes branches.

Regards,

Hans