All of lore.kernel.org
 help / color / mirror / Atom feed
From: JoSH Lehan <krellan@krellan.com>
To: linux-kernel@vger.kernel.org
Subject: psmouse: Patch to reset when lost synchronization throwing bytes away
Date: Wed, 09 Nov 2005 02:52:16 -0800	[thread overview]
Message-ID: <4371D4E0.50901@krellan.com> (raw)

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;
+
+		/* linux@krellan.com: 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


                 reply	other threads:[~2005-11-09 10:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4371D4E0.50901@krellan.com \
    --to=krellan@krellan.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.