Input: i8042 - add forcenorestore quirk to leave controller untouched even on s3
authorWerner Sembach <wse@tuxedocomputers.com>
Thu, 4 Jan 2024 18:31:17 +0000 (19:31 +0100)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 19 Aug 2024 04:28:23 +0000 (21:28 -0700)
On s3 resume the i8042 driver tries to restore the controller to a known
state by reinitializing things, however this can confuse the controller
with different effects. Mostly occasionally unresponsive keyboards after
resume.

These issues do not rise on s0ix resume as here the controller is assumed
to preserved its state from before suspend.

This patch adds a quirk for devices where the reinitialization on s3 resume
is not needed and might be harmful as described above. It does this by
using the s0ix resume code path at selected locations.

This new quirk goes beyond what the preexisting reset=never quirk does,
which only skips some reinitialization steps.

Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240104183118.779778-2-wse@tuxedocomputers.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/serio/i8042-acpipnpio.h
drivers/input/serio/i8042.c

index 78e5c9c60b8b3ab9b13ad600b0b9f760f7201956..00e8043010887276571a51246be342ac432ed0a3 100644 (file)
@@ -83,6 +83,7 @@ static inline void i8042_write_command(int val)
 #define SERIO_QUIRK_KBDRESET           BIT(12)
 #define SERIO_QUIRK_DRITEK             BIT(13)
 #define SERIO_QUIRK_NOPNP              BIT(14)
+#define SERIO_QUIRK_FORCENORESTORE     BIT(15)
 
 /* Quirk table for different mainboards. Options similar or identical to i8042
  * module parameters.
@@ -1694,6 +1695,8 @@ static void __init i8042_check_quirks(void)
        if (quirks & SERIO_QUIRK_NOPNP)
                i8042_nopnp = true;
 #endif
+       if (quirks & SERIO_QUIRK_FORCENORESTORE)
+               i8042_forcenorestore = true;
 }
 #else
 static inline void i8042_check_quirks(void) {}
@@ -1727,7 +1730,7 @@ static int __init i8042_platform_init(void)
 
        i8042_check_quirks();
 
-       pr_debug("Active quirks (empty means none):%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+       pr_debug("Active quirks (empty means none):%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
                i8042_nokbd ? " nokbd" : "",
                i8042_noaux ? " noaux" : "",
                i8042_nomux ? " nomux" : "",
@@ -1747,10 +1750,11 @@ static int __init i8042_platform_init(void)
                "",
 #endif
 #ifdef CONFIG_PNP
-               i8042_nopnp ? " nopnp" : "");
+               i8042_nopnp ? " nopnp" : "",
 #else
-               "");
+               "",
 #endif
+               i8042_forcenorestore ? " forcenorestore" : "");
 
        retval = i8042_pnp_init();
        if (retval)
index e0fb1db653b7355705d7fb0f35dba9106e5a674c..8ec4872b447145ba750bb6e6e3b6b5933c05f1ff 100644 (file)
@@ -115,6 +115,10 @@ module_param_named(nopnp, i8042_nopnp, bool, 0);
 MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
 #endif
 
+static bool i8042_forcenorestore;
+module_param_named(forcenorestore, i8042_forcenorestore, bool, 0);
+MODULE_PARM_DESC(forcenorestore, "Force no restore on s3 resume, copying s2idle behaviour");
+
 #define DEBUG
 #ifdef DEBUG
 static bool i8042_debug;
@@ -1232,7 +1236,7 @@ static int i8042_pm_suspend(struct device *dev)
 {
        int i;
 
-       if (pm_suspend_via_firmware())
+       if (!i8042_forcenorestore && pm_suspend_via_firmware())
                i8042_controller_reset(true);
 
        /* Set up serio interrupts for system wakeup. */
@@ -1248,7 +1252,7 @@ static int i8042_pm_suspend(struct device *dev)
 
 static int i8042_pm_resume_noirq(struct device *dev)
 {
-       if (!pm_resume_via_firmware())
+       if (i8042_forcenorestore || !pm_resume_via_firmware())
                i8042_interrupt(0, NULL);
 
        return 0;
@@ -1271,7 +1275,7 @@ static int i8042_pm_resume(struct device *dev)
         * not restore the controller state to whatever it had been at boot
         * time, so we do not need to do anything.
         */
-       if (!pm_suspend_via_firmware())
+       if (i8042_forcenorestore || !pm_suspend_via_firmware())
                return 0;
 
        /*