aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/syscons/sysmouse.c
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2008-08-24 15:20:44 +0000
committerEd Schouten <ed@FreeBSD.org>2008-08-24 15:20:44 +0000
commitdd63e2a189c1ed26fd19f9aabe7db686b14d14b7 (patch)
treee275d30a75e5c9ee45dc8593e8b169fcfd044361 /sys/dev/syscons/sysmouse.c
parentc87ba3b18ca22a5791febf63f5ca7ace5110ac56 (diff)
downloadsrc-dd63e2a189c1ed26fd19f9aabe7db686b14d14b7.tar.gz
src-dd63e2a189c1ed26fd19f9aabe7db686b14d14b7.zip
Make sysmouse(4) use its own locks, instead of using Giant.
When I changed syscons(4) to work with the MPSAFE TTY code, I just locked all device nodes down using the compatibility feature that allows you to override the TTY's lock (Giant in this case). Upon closer inspection, it seems sysmouse(4) only has two internal variables that need locking: mouse_level and mouse_status. I haven't done any performance benchmarks on this, though I think it won't have any dramatic improvements on the system. It is good to get rid of Giant here, because the third argument of tty_alloc() has only been added to ease migration to MPSAFE TTY. It should not be used when not needed. While there, remove SC_MOUSE, which is a leftover from the MPSAFE TTY import.
Notes
Notes: svn path=/head/; revision=182109
Diffstat (limited to 'sys/dev/syscons/sysmouse.c')
-rw-r--r--sys/dev/syscons/sysmouse.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/sys/dev/syscons/sysmouse.c b/sys/dev/syscons/sysmouse.c
index 9d926b88924b..99232cb9d26a 100644
--- a/sys/dev/syscons/sysmouse.c
+++ b/sys/dev/syscons/sysmouse.c
@@ -43,8 +43,6 @@ __FBSDID("$FreeBSD$");
#ifndef SC_NO_SYSMOUSE
-#define SC_MOUSE 128 /* minor number */
-
/* local variables */
static struct tty *sysmouse_tty;
static int mouse_level; /* sysmouse protocol level */
@@ -61,7 +59,6 @@ smdev_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
{
mousehw_t *hw;
mousemode_t *mode;
- int s;
switch (cmd) {
@@ -121,14 +118,12 @@ smdev_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
return 0;
case MOUSE_GETSTATUS: /* get accumulated mouse events */
- s = spltty();
*(mousestatus_t *)data = mouse_status;
mouse_status.flags = 0;
mouse_status.obutton = mouse_status.button;
mouse_status.dx = 0;
mouse_status.dy = 0;
mouse_status.dz = 0;
- splx(s);
return 0;
#ifdef notyet
@@ -169,7 +164,7 @@ static struct ttydevsw smdev_ttydevsw = {
static void
sm_attach_mouse(void *unused)
{
- sysmouse_tty = tty_alloc(&smdev_ttydevsw, NULL, &Giant);
+ sysmouse_tty = tty_alloc(&smdev_ttydevsw, NULL, NULL);
tty_makedev(sysmouse_tty, NULL, "sysmouse");
}
@@ -191,7 +186,9 @@ sysmouse_event(mouse_info_t *info)
};
u_char buf[8];
int x, y, z;
- int i;
+ int i, flags = 0;
+
+ tty_lock(sysmouse_tty);
switch (info->operation) {
case MOUSE_ACTION:
@@ -210,7 +207,7 @@ sysmouse_event(mouse_info_t *info)
mouse_status.button &= ~info->u.event.id;
break;
default:
- return 0;
+ goto done;
}
mouse_status.dx += x;
@@ -218,11 +215,9 @@ sysmouse_event(mouse_info_t *info)
mouse_status.dz += z;
mouse_status.flags |= ((x || y || z) ? MOUSE_POSCHANGED : 0)
| (mouse_status.obutton ^ mouse_status.button);
- if (mouse_status.flags == 0)
- return 0;
-
- if ((sysmouse_tty == NULL) || !tty_opened(sysmouse_tty))
- return mouse_status.flags;
+ flags = mouse_status.flags;
+ if (flags == 0 || !tty_opened(sysmouse_tty))
+ goto done;
/* the first five bytes are compatible with MouseSystems' */
buf[0] = MOUSE_MSC_SYNC
@@ -247,7 +242,8 @@ sysmouse_event(mouse_info_t *info)
}
ttydisc_rint_done(sysmouse_tty);
- return mouse_status.flags;
+done: tty_unlock(sysmouse_tty);
+ return (flags);
}
#endif /* !SC_NO_SYSMOUSE */