linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: linux-input@vger.kernel.org
Cc: Arjan van de Ven <arjan@infradead.org>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: [patch 1/2] input: introduce a tougher i8042.reset
Date: Wed, 4 Feb 2009 19:16:31 -0800	[thread overview]
Message-ID: <20090204191631.21783c62@infradead.org> (raw)
In-Reply-To: <20090204191540.2d6abd87@infradead.org>


>From 2c5ccde448ae5f4062802bcd6002f856acbd268f Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
Date: Tue, 3 Feb 2009 16:26:16 -0800
Subject: [PATCH] input: introduce a tougher i8042.reset

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....

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 Documentation/kernel-parameters.txt |    2 ++
 drivers/input/serio/i8042.c         |   33 ++++++++++++++++++++++++---------
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index ac613a6..a43e3bd 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -855,6 +855,8 @@ and is between 256 and 4096 characters. It is defined in the file
 			[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]
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 170f71e..2473a9a 100644
--- a/drivers/input/serio/i8042.c
+++ b/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.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

  reply	other threads:[~2009-02-05  3:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-05  3:15 [patch 0/2] Make the touchpad on the MSI Wind netbook work Arjan van de Ven
2009-02-05  3:16 ` Arjan van de Ven [this message]
2009-02-05 21:52   ` [patch 1/2] input: introduce a tougher i8042.reset Andrew Morton
2009-02-06  0:35     ` Arjan van de Ven
2009-02-05  3:17 ` [patch 2/2] input: add a DMI table for the i8042.reset option; make MSI Wind U-100 work Arjan van de Ven
2009-02-06  0:21   ` Andrew Morton
2009-02-10 20:25 ` [patch 0/2] Make the touchpad on the MSI Wind netbook work Pavel Machek
2009-02-10 22:00   ` Rafael J. Wysocki
2009-02-11  1:00     ` Jiri Kosina
2009-02-11  1:13       ` Arjan van de Ven
2009-02-11  1:18         ` Jiri Kosina
2009-02-11  9:50       ` Rafael J. Wysocki
2009-02-10 23:06   ` Arjan van de Ven
2009-02-11  1:45 ` Matthew Garrett
2009-02-11 12:17   ` Jiri Kosina
2009-02-11 13:28     ` Andy Whitcroft

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090204191631.21783c62@infradead.org \
    --to=arjan@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).