[PATCH] input: handle bad parity PS/2 packets in mouse drivers better

Previous thread: Can I limit the number of tcp connections ? by Mark Jackson on Tuesday, April 13, 2010 - 4:16 am. (1 message)

Next thread: [PATCH] Fix Oops with Atmel SPI by Anders Larsen on Tuesday, April 13, 2010 - 4:31 am. (11 messages)
From: Damjan Jovanovic
Date: Tuesday, April 13, 2010 - 4:29 am

This fixes a regression introduced in Linux 2.6.2 where mice that
sporadically produce bad parity go crazy and start jumping around and
clicking randomly, which never happens in any version of Windows
running on the same hardware. The bugzilla bug is
https://bugzilla.kernel.org/show_bug.cgi?id=6105

The patch works by always accumulating a full PS/2 packet, then
ignoring the packet if any byte had a bad checksum. A month of testing
it against an affected mouse has revealed it works perfectly in
practice.

This is the third resend, also CC'ed to lkml and Andrew Morton this
time, because the previous 2 emails to linux-input@vger.kernel.org and
the input/mouse maintainers from 28 March 2010 were ignored.

Regards
Damjan Jovanovic

Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com>
From: Dmitry Torokhov
Date: Wednesday, April 14, 2010 - 1:59 pm

Hi Damjan,


I am not sure whether we can rely on the mouse and KBC combo to always
finish transmitting entire packet when parity error is detected,
regardless of the protocol involved. However I had a chanceto observe
several versions of the $OTHER_OS in presence of parity errors and
they (at least when used with stock mouse driver) appear to simply
ignore errors and process motion data as usual. Therefore I propose
instead of your patch the patch below.

Could you please try it on your box and see if it helps?

Thanks.

-- 
Dmitry


Input: psmouse - ignore parity error for basic protocols

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Observing behavior of the other OS it appears that parity errors reported
by the keyboard controller are being ignored and the data is processed
as usual. Let's do the same for standard PS/2 protocols (bare, Intellimouse
and Intellimouse Explorer) to provide better compatibility. Thsi should fix
teh following bug:

	https://bugzilla.kernel.org/show_bug.cgi?id=6105

Thanks for Damjan Jovanovic for locating the source of issue and ideas
for the patch.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/mouse/psmouse-base.c |   18 +++++++++++++++---
 drivers/input/mouse/psmouse.h      |    1 +
 2 files changed, 16 insertions(+), 3 deletions(-)


diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index d8c0c8d..cbc8072 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -110,6 +110,7 @@ static struct workqueue_struct *kpsmoused_wq;
 struct psmouse_protocol {
 	enum psmouse_type type;
 	bool maxproto;
+	bool ignore_parity; /* Protocol should ignore parity errors from KBC */
 	const char *name;
 	const char *alias;
 	int (*detect)(struct psmouse *, bool);
@@ -288,7 +289,9 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
 	if (psmouse->state == PSMOUSE_IGNORE)
 		goto out;
 
-	if (flags & (SERIO_PARITY|SERIO_TIMEOUT)) ...
From: Damjan Jovanovic
Date: Saturday, April 17, 2010 - 2:33 am

On Wed, Apr 14, 2010 at 10:59 PM, Dmitry Torokhov

Hi Dmitry and others

This patch works.

Thank you
--

From: Damjan Jovanovic
Date: Monday, May 3, 2010 - 4:31 am

Ping? This patch works, can you please commit it?

Thank you
Damjan
--

From: Dmitry Torokhov
Date: Wednesday, May 5, 2010 - 9:24 am

The patch has been pulled into mainline. Thank you for your efforts and
persistence.

-- 
Dmitry
--

Previous thread: Can I limit the number of tcp connections ? by Mark Jackson on Tuesday, April 13, 2010 - 4:16 am. (1 message)

Next thread: [PATCH] Fix Oops with Atmel SPI by Anders Larsen on Tuesday, April 13, 2010 - 4:31 am. (11 messages)