diff mbox series

Input: i8042 - Fix keyboard failure caused by S4 mouse wakeup

Message ID 20241109094842.1436-1-luyuantao01@163.com (mailing list archive)
State New
Headers show
Series Input: i8042 - Fix keyboard failure caused by S4 mouse wakeup | expand

Commit Message

luyuantao01 Nov. 9, 2024, 9:48 a.m. UTC
From: luyuantao <luyuantao@kylinos.cn>

There is an i8402 keyboard and mouse device on the
ThinkPad P15 laptop.When conducting a wakeup
test on S4, it was found that:

1. Using the keyboard directly can wake up S4.
2. The system failed to wake up using the mouse button first,
and when using the keyboard to wake up again, the system
cannot be woken up and can only be shut down by pressing
the power button.

This issue is that i8042_start() only enables wakeup for the
keyboard.However, because wakeup capability is set for all
devices, the device_may_wakeup() is also true for the mouse,
and the i8042_pm_suspend() enables the wakeup interrupt for the
mouse.The system can respond to mouse wakeup interrupts, but
it cannot handle them and affects keyboard interrupts.

So let the mouse also have wakeup ability to fix it

Signed-off-by: luyuantao <luyuantao@kylinos.cn>
---
 drivers/input/serio/i8042.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 8ec4872b4471..1f9810dfb3d8 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -446,17 +446,16 @@  static int i8042_start(struct serio *serio)
 {
 	struct i8042_port *port = serio->port_data;
 
-	device_set_wakeup_capable(&serio->dev, true);
-
 	/*
-	 * On platforms using suspend-to-idle, allow the keyboard to
-	 * wake up the system from sleep by enabling keyboard wakeups
-	 * by default.  This is consistent with keyboard wakeup
-	 * behavior on many platforms using suspend-to-RAM (ACPI S3)
-	 * by default.
+	 * On platforms using suspend-to-idle
+	 * In fact, people nowadays prefer to wake up systems using
+	 * keyboards or mice.But after the previous code flow
+	 * entered S4, the mouse could not wakeup the system
+	 * and caused the keyboard to fail to wake up.
+	 * So fix it
 	 */
-	if (pm_suspend_default_s2idle() &&
-	    serio == i8042_ports[I8042_KBD_PORT_NO].serio) {
+	if (pm_suspend_default_s2idle()) {
+		device_set_wakeup_capable(&serio->dev, true);
 		device_set_wakeup_enable(&serio->dev, true);
 	}