Subject: Avoiding ps/2 mice reset threads
To: None <tech-kern@NetBSD.org>
From: Martin Husemann <martin@duskware.de>
List: tech-kern
Date: 06/10/2004 12:13:21
--FL5UXtIhxfXey3p5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Many notebooks nowadays have a builtin touchpad, that hides as a PS/2
mouse device (pms* at pckbport...), but no external PS/2 connector.
On this machines, having a pms0 thread waiting for the touchpad to go
away and maybe come back, reseting it when it comes back, does not make
mouch sense to me.

Furthermore I've been told some of these devices get confused by being
reset often - which might point to another bug, but given the fragility
of our pms timeout/reset code and the (obvious) hardware dependence
I don't like to dig in there deeper.

The attached patch adds an option PMS_NOT_PLUGGABLE to globally disable
this threads (saving a kernel thread, as a side effect).

Another thing I'm going to try is to identify touchpad devices. For hardware
from Synaptics there is a special command sequence check wether a given
PS/2 device is a Synaptics touchpad or something else. If pms positively
identifies a touchpad, it could avoid the pms reset thread automatically
for just this device, while external mice still would have that feature.

I'm not sure how many different touchpads or similar devices are out there.

Is this all a good idea? What do you think?

Martin


--FL5UXtIhxfXey3p5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch

Index: files.pckbport
===================================================================
RCS file: /cvsroot/src/sys/dev/pckbport/files.pckbport,v
retrieving revision 1.1
diff -u -p -r1.1 files.pckbport
--- files.pckbport	13 Mar 2004 17:31:33 -0000	1.1
+++ files.pckbport	10 Jun 2004 09:54:42 -0000
@@ -13,3 +13,4 @@ defparam PCKBD_LAYOUT
 device	pms: wsmousedev
 attach	pms at pckbport
 file	dev/pckbport/pms.c		pms
+defflag opt_pms.h			PMS_NOT_PLUGGABLE PMS_DISABLE_POWERHOOK
Index: pms.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pckbport/pms.c,v
retrieving revision 1.2
diff -u -p -r1.2 pms.c
--- pms.c	18 Mar 2004 21:05:19 -0000	1.2
+++ pms.c	10 Jun 2004 09:54:42 -0000
@@ -42,6 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.2 
 #include <dev/wscons/wsconsio.h>
 #include <dev/wscons/wsmousevar.h>
 
+#include "opt_pms.h"
+
 #ifdef PMSDEBUG
 int pmsdebug = 1;
 #define DPRINTF(x)      if (pmsdebug) printf x
@@ -81,10 +83,13 @@ struct pms_softc {		/* driver status inf
 	u_int buttons;		/* mouse button status */
 	enum pms_type protocol;
 	unsigned char packet[4];
-	struct timeval last, current;
 
 	struct device *sc_wsmousedev;
+
+#ifndef PMS_NOT_PLUGGABLE
+	struct timeval last, current;
 	struct proc *sc_event_thread;
+#endif
 };
 
 int pmsprobe(struct device *, struct cfdata *, void *);
@@ -97,8 +102,10 @@ CFATTACH_DECL(pms, sizeof(struct pms_sof
 static int	pms_protocol(pckbport_tag_t, pckbport_slot_t);
 static void	do_enable(struct pms_softc *);
 static void	do_disable(struct pms_softc *);
+#ifndef PMS_NOT_PLUGGABLE
 static void	pms_reset_thread(void*);
 static void	pms_spawn_reset_thread(void*);
+#endif
 int	pms_enable(void *);
 int	pms_ioctl(void *, u_long, caddr_t, int, struct proc *);
 void	pms_disable(void *);
@@ -234,7 +241,9 @@ pmsattach(struct device *parent, struct 
 		printf("pmsattach: disable error\n");
 	pckbport_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0);
 
+#ifndef PMS_NOT_PLUGGABLE
 	kthread_create(pms_spawn_reset_thread, sc);
+#endif
 
 #ifndef PMS_DISABLE_POWERHOOK
 	sc->sc_powerhook = powerhook_establish(pms_power, sc);
@@ -399,6 +408,7 @@ pms_ioctl(void *v, u_long cmd, caddr_t d
 	return 0;
 }
 
+#ifndef PMS_NOT_PLUGGABLE
 static void
 pms_spawn_reset_thread(void *arg)
 {
@@ -465,6 +475,7 @@ pms_reset_thread(void *arg)
 		}
 	}
 }
+#endif /* PMS_NOT_PLUGGABLE */
 
 /* Masks for the first byte of a packet */
 #define PMS_LBUTMASK 0x01
@@ -480,13 +491,16 @@ pmsinput(void *vsc, int data)
 	u_int changed;
 	int dx, dy, dz = 0;
 	int newbuttons = 0;
+#ifndef PMS_NOT_PLUGGABLE
 	int s;
+#endif
 
 	if (!sc->sc_enabled) {
 		/* Interrupts are not expected.	 Discard the byte. */
 		return;
 	}
 
+#ifndef PMS_NOT_PLUGGABLE
 	s = splclock();
 	sc->current = mono_time;
 	splx(s);
@@ -517,6 +531,7 @@ pmsinput(void *vsc, int data)
 		}
 	}
 	sc->last = sc->current;
+#endif
 
 	if (sc->inputstate == 0) {
 		/*

--FL5UXtIhxfXey3p5--