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