Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212537
Fixes: 537b0dd4729e ("platform/x86: intel-hid: Add support for SW_TABLET_MODE")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Elia Devito <eliadevito@gmail.com>
Link: https://lore.kernel.org/r/20210404143831.25173-1-hdegoede@redhat.com

+9 -7
+9 -7
drivers/platform/x86/intel-hid.c
··· 483 483 goto wakeup; 484 484 485 485 /* 486 - * Switch events will wake the device and report the new switch 487 - * position to the input subsystem. 486 + * Some devices send (duplicate) tablet-mode events when moved 487 + * around even though the mode has not changed; and they do this 488 + * even when suspended. 489 + * Update the switch state in case it changed and then return 490 + * without waking up to avoid spurious wakeups. 488 491 */ 489 - if (priv->switches && (event == 0xcc || event == 0xcd)) 490 - goto wakeup; 492 + if (event == 0xcc || event == 0xcd) { 493 + report_tablet_mode_event(priv->switches, event); 494 + return; 495 + } 491 496 492 497 /* Wake up on 5-button array events only. */ 493 498 if (event == 0xc0 || !priv->array) ··· 505 500 506 501 wakeup: 507 502 pm_wakeup_hard_event(&device->dev); 508 - 509 - if (report_tablet_mode_event(priv->switches, event)) 510 - return; 511 503 512 504 return; 513 505 }