[PATCH] Input: psmouse - disable non-wakeup armed PS/2 mouse when s2dile

From: Aaron Ma
Date: Tue Aug 10 2021 - 23:50:31 EST


After commit 684bec1092b6 ("Input: i8042 - enable keyboard wakeups by
default when s2idle is used"), kdb is enabled to wakeup laptops.
Kbd fails to wakeup when touchpad/trackpoint is used on ThinkPad.
The touchpad is not set to wakeup, and it shares buffer with kbd.
Send disable command to PS/2 mouse when s2idle, make it clean for
kdb to wakeup.
Enable PS/2 mouse when wakeup enabled.

Signed-off-by: Aaron Ma <aaron.ma@xxxxxxxxxxxxx>
---
drivers/input/mouse/psmouse-base.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 0b4a3039f312..85dc9810d6ec 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -21,6 +21,7 @@
#include <linux/libps2.h>
#include <linux/mutex.h>
#include <linux/types.h>
+#include <linux/suspend.h>

#include "psmouse.h"
#include "synaptics.h"
@@ -1457,11 +1458,13 @@ static void psmouse_cleanup(struct serio *serio)
*/
ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);

- /*
- * Some boxes, such as HP nx7400, get terribly confused if mouse
- * is not fully enabled before suspending/shutting down.
- */
- ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
+ if (!pm_suspend_default_s2idle() || device_may_wakeup(&serio->dev)) {
+ /*
+ * Some boxes, such as HP nx7400, get terribly confused if mouse
+ * is not fully enabled before suspending/shutting down.
+ */
+ ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
+ }

if (parent) {
if (parent->pt_deactivate)
--
2.30.2