psmouse: Patch to reset when lost synchronization throwing bytes away

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

I have made a quick patch for psmouse, that solves a problem I have had
with certain KVM switches.

Windows XP is surprisingly decent at resetting the mouse when an error
or desynchronization occurs.  This seems like an acceptable recovery
strategy, as the only drawback will be loss of mouse responsiveness for
0.5 seconds or so.

In Linux, however, the psmouse driver will clear the buffer but not do
a reset.  This doesn't solve the problem, as the block boundaries have
already been lost and any mouse input will be seen as garbage data.
The result is the infamous "teleporting mouse" bug, where the mouse
pointer jumps around the screen and phantom button presses start
happening.  In this age of GUI context menus for right-clicks, Bad
Things can start to happen very easily, resulting in *much* user
frustration....

The workaround now is to switch to a text-only VC, become root, rmmod
psmouse, and modprobe psmouse again.  This patch makes this behaviour
happen automatically, by asking the mouse to reset itself when the
driver detects a loss of synchronization.


diff -urN OLD-linux-source-2.6.12/drivers/input/mouse/psmouse-base.c NEW-linux-source-2.6.12/drivers/input/mouse/psmouse-base.c
--- OLD-linux-source-2.6.12/drivers/input/mouse/psmouse-base.c	2005-06-17 12:48:29.000000000 -0700
+++ NEW-linux-source-2.6.12/drivers/input/mouse/psmouse-base.c	2005-11-08 03:36:46.000000000 -0800
@@ -175,9 +175,14 @@

 	if (psmouse->state == PSMOUSE_ACTIVATED &&
 	    psmouse->pktcnt && time_after(jiffies, psmouse->last + HZ/2)) {
-		printk(KERN_WARNING "psmouse.c: %s at %s lost synchronization, throwing %d bytes away.\n",
+		printk(KERN_WARNING "psmouse.c: %s at %s lost synchronization, throwing %d bytes away and resetting.\n",
 		       psmouse->name, psmouse->phys, psmouse->pktcnt);
 		psmouse->pktcnt = 0;
+
+		/* [email protected]: Now resetting the mouse when this happens, in order to avoid continuing with garbaged input */
+		psmouse->state = PSMOUSE_IGNORE;
+		serio_reconnect(psmouse->ps2dev.serio);
+		goto out;
 	}

 	psmouse->last = jiffies;


Opinions/comments on this?

Thanks!
Josh

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux