Skip to contentSkip to conversation

input: introduce a tougher i8042.reset

PATCH Applied [email protected] 3 participants 3 messages Feb 11, 2009 – Feb 13, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 input: introduce a tougher i8042.reset

From: Arjan van de Ven <[email protected]>

Some touchpads don't reset right the first time (MSI Wind U-100 for example). This patch will retry the reset up to 5 times.

In addition, this patch also adds a module parameter to not treat reset failures as fatal to the usage of the device. This prevents a touchpad failure from also disabling the keyboard.

---

 Documentation/kernel-parameters.txt |    2 +
 drivers/input/serio/i8042.c         |   33 ++++++++++++++++++--------
 2 files changed, 26 insertions(+), 9 deletions(-)
Documentation/kernel-parameters.txt renamed from Documentation/kernel-parameters.txt~input-introduce-a-tougher-i8042reset +2 -0
diff -puN Documentation/kernel-parameters.txt~input-introduce-a-tougher-i8042reset Documentation/kernel-parameters.txt
@@ -852,6 +852,8 @@ and is between 256 and 4096 characters. 
 			[HW] Frequency with which keyboard LEDs should blink
 			     when kernel panics (default is 0.5 sec)
 	i8042.reset	[HW] Reset the controller during init and cleanup
+	i8042.nonfatal  [HW] Don't treat i8042.reset failures as fatal for the
+			     device initialization.
 	i8042.unlock	[HW] Unlock (ignore) the keylock
 
 	i810=		[HW,DRM]
drivers/input/serio/i8042.c renamed from drivers/input/serio/i8042.c~input-introduce-a-tougher-i8042reset +24 -9
diff -puN drivers/input/serio/i8042.c~input-introduce-a-tougher-i8042reset drivers/input/serio/i8042.c
@@ -47,6 +47,10 @@ static unsigned int i8042_reset;
 module_param_named(reset, i8042_reset, bool, 0);
 MODULE_PARM_DESC(reset, "Reset controller during init and cleanup.");
 
+static unsigned int i8042_nonfatal;
+module_param_named(nonfatal, i8042_nonfatal, bool, 0);
+MODULE_PARM_DESC(reset, "Treat controller test failures as non-fatal.");
+
 static unsigned int i8042_direct;
 module_param_named(direct, i8042_direct, bool, 0);
 MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode.");
@@ -712,22 +716,33 @@ static int i8042_controller_check(void)
 static int i8042_controller_selftest(void)
 {
 	unsigned char param;
+	int i = 0;
 
 	if (!i8042_reset)
 		return 0;
 
-	if (i8042_command(&param, I8042_CMD_CTL_TEST)) {
-		printk(KERN_ERR "i8042.c: i8042 controller self test timeout.\n");
-		return -ENODEV;
-	}
+	/*
+	 * We try this 5 times; on some really fragile systems this does not
+	 * take the first time...
+	 */
+	do {
+
+		if (i8042_command(&param, I8042_CMD_CTL_TEST)) {
+			printk(KERN_ERR "i8042.c: i8042 controller self test timeout.\n");
+			return -ENODEV;
+		}
+
+		if (param == I8042_RET_CTL_TEST)
+			return 0;
 
-	if (param != I8042_RET_CTL_TEST) {
 		printk(KERN_ERR "i8042.c: i8042 controller selftest failed. (%#x != %#x)\n",
-			 param, I8042_RET_CTL_TEST);
-		return -EIO;
-	}
+			param, I8042_RET_CTL_TEST);
+		msleep(50);
+	} while (i++ < 5);
 
-	return 0;
+	if (i8042_nonfatal)
+		return 0;
+	return -EIO;
 }
 
 /*

_

#1 lore raw
Quoted 2 lines · On Wed, 11 Feb 2009, [email protected] wrote:

Some touchpads don't reset right the first time (MSI Wind U-100 for example). This patch will retry the reset up to 5 times.

Yes, I agree we should seriously consider this a 2.6.29 material if we want to avoid a lot of repeating bugreports in the future, as more and more people start buying these toys.

In addition to that, I'd propose the patch below also for 2.6.29. Dmitry, what do you think?

From: Andy Whitcroft <[email protected]>
Subject: [PATCH 1/1] psmouse/synaptics: ensure we reset the device on resume

When resuming from suspend newer Synaptics touchpads do not recover correctly. Analysis of the resume sequence as applied in Linux was compared to that of other operating systems. This indicated that the other OSs were resetting the mouse before attempting to detect it (for all Synaptics touchpads, old and new). Applying this same modification fixes these newer Synaptics touchpads and brings the driver into line with common OS reset behaviour.

This patch adds this reset by default providing a module option to restore the previous non-reset behaviour:

psmouse.synaptics_resume_reset=N

Also a message is emmitted on resume hinting as to how to fix a broken touchpad.

---
 drivers/input/mouse/synaptics.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/input/mouse/synaptics.c +10 -0
index d349c4a..5b01c14 100644
@@ -60,11 +60,21 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
 	return 0;
 }
 
+static int synaptics_resume_reset = 1;
+module_param(synaptics_resume_reset, bool, 0);
+MODULE_PARM_DESC(synaptics_resume_reset,
+				"Enable reset on resume for Synaptics");
+
 int synaptics_detect(struct psmouse *psmouse, int set_properties)
 {
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
 	unsigned char param[4];
 
+	if (synaptics_resume_reset) {
+		printk(KERN_CRIT "WARNING: synaptics was reset on resume, see synaptics_resume_reset if you have trouble on resume\n");
+		psmouse_reset(psmouse);
+	}
+
 	param[0] = 0;
 
 	ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
maintainer
#2 lore raw

Hi Jiri, Andrew,

Quoted 9 lines · Jiri Kosina
Quoted 2 lines · On Wed, 11 Feb 2009, [email protected] wrote:

Some touchpads don't reset right the first time (MSI Wind U-100 for example). This patch will retry the reset up to 5 times.

Yes, I agree we should seriously consider this a 2.6.29 material if we want to avoid a lot of repeating bugreports in the future, as more and more people start buying these toys.

We have never reset KBC on x86 leaving BIOS deal with it so that's the first. Is there a bug report or thread I could read a bit more about the problem?

Quoted 3 lines

In addition to that, I'd propose the patch below also for 2.6.29. Dmitry, what do you think?

No, not in the current form. We already have psmouse_reset() on resume (and during ordinary detect). If we need it earlier that is fine but we don't need to do it twice. The option has to go too, since we currently are resetting the device I don't think it is needed.

Quoted 52 lines

From: Andy Whitcroft <[email protected]>
Subject: [PATCH 1/1] psmouse/synaptics: ensure we reset the device on resume

When resuming from suspend newer Synaptics touchpads do not recover correctly. Analysis of the resume sequence as applied in Linux was compared to that of other operating systems. This indicated that the other OSs were resetting the mouse before attempting to detect it (for all Synaptics touchpads, old and new). Applying this same modification fixes these newer Synaptics touchpads and brings the driver into line with common OS reset behaviour.

This patch adds this reset by default providing a module option to restore the previous non-reset behaviour:

psmouse.synaptics_resume_reset=N

Also a message is emmitted on resume hinting as to how to fix a broken touchpad.

---
 drivers/input/mouse/synaptics.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/input/mouse/synaptics.c +10 -0
index d349c4a..5b01c14 100644
@@ -60,11 +60,21 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
 	return 0;
 }
 
+static int synaptics_resume_reset = 1;
+module_param(synaptics_resume_reset, bool, 0);
+MODULE_PARM_DESC(synaptics_resume_reset,
+				"Enable reset on resume for Synaptics");
+
 int synaptics_detect(struct psmouse *psmouse, int set_properties)
 {
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
 	unsigned char param[4];
 
+	if (synaptics_resume_reset) {
+		printk(KERN_CRIT "WARNING: synaptics was reset on resume, see synaptics_resume_reset if you have trouble on resume\n");
+		psmouse_reset(psmouse);
+	}
+
 	param[0] = 0;
 
 	ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
Signature · 1 line
Dmitry