Download raw body.
Wipe out WSEVENT_MPSAFE stuff
All wsevent_filtops are mp-safe for a long time. We don't need
WSEVENT_MPSAFE logic anymore.
Index: sys/dev/wscons/wsevent.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wsevent.c,v
diff -u -p -r1.29 wsevent.c
--- sys/dev/wscons/wsevent.c 21 Jan 2025 20:13:19 -0000 1.29
+++ sys/dev/wscons/wsevent.c 18 Jul 2025 09:23:36 -0000
@@ -88,44 +88,6 @@ int filt_wseventread(struct knote *, lon
int filt_wseventmodify(struct kevent *, struct knote *);
int filt_wseventprocess(struct knote *, struct kevent *);
-static void
-wsevent_klist_assertlk(void *arg)
-{
- struct wseventvar *ev = arg;
-
- if((ev->ws_flags & WSEVENT_MPSAFE) == 0)
- KERNEL_ASSERT_LOCKED();
- MUTEX_ASSERT_LOCKED(&ev->ws_mtx);
-}
-
-static int
-wsevent_klist_lock(void *arg)
-{
- struct wseventvar *ev = arg;
-
- if((ev->ws_flags & WSEVENT_MPSAFE) == 0)
- KERNEL_LOCK();
- mtx_enter(&ev->ws_mtx);
-
- return (0);
-}
-
-static void
-wsevent_klist_unlock(void *arg, int s)
-{
- struct wseventvar *ev = arg;
-
- mtx_leave(&ev->ws_mtx);
- if ((ev->ws_flags & WSEVENT_MPSAFE) == 0)
- KERNEL_UNLOCK();
-}
-
-static const struct klistops wsevent_klistops = {
- .klo_assertlk = wsevent_klist_assertlk,
- .klo_lock = wsevent_klist_lock,
- .klo_unlock = wsevent_klist_unlock,
-};
-
const struct filterops wsevent_filtops = {
.f_flags = FILTEROP_ISFD | FILTEROP_MPSAFE,
.f_attach = NULL,
@@ -139,7 +101,7 @@ const struct filterops wsevent_filtops =
* Initialize a wscons_event queue.
*/
int
-wsevent_init_flags(struct wseventvar *ev, int flags)
+wsevent_init(struct wseventvar *ev)
{
struct wscons_event *queue;
@@ -155,9 +117,8 @@ wsevent_init_flags(struct wseventvar *ev
}
mtx_init_flags(&ev->ws_mtx, IPL_TTY, "wsmtx", 0);
- klist_init(&ev->ws_klist, &wsevent_klistops, ev);
+ klist_init_mutex(&ev->ws_klist, &ev->ws_mtx);
- ev->ws_flags = flags;
ev->ws_q = queue;
ev->ws_get = ev->ws_put = 0;
@@ -291,8 +252,6 @@ filt_wseventread(struct knote *kn, long
{
struct wseventvar *ev = kn->kn_hook;
- if((ev->ws_flags & WSEVENT_MPSAFE) == 0)
- KERNEL_ASSERT_LOCKED();
MUTEX_ASSERT_LOCKED(&ev->ws_mtx);
if (ev->ws_get == ev->ws_put)
@@ -310,15 +269,11 @@ int
filt_wseventmodify(struct kevent *kev, struct knote *kn)
{
struct wseventvar *ev = kn->kn_hook;
- int active, dolock = ((ev->ws_flags & WSEVENT_MPSAFE) == 0);
+ int active;
- if (dolock)
- KERNEL_LOCK();
mtx_enter(&ev->ws_mtx);
active = knote_modify(kev, kn);
mtx_leave(&ev->ws_mtx);
- if (dolock)
- KERNEL_UNLOCK();
return (active);
}
@@ -327,16 +282,11 @@ int
filt_wseventprocess(struct knote *kn, struct kevent *kev)
{
struct wseventvar *ev = kn->kn_hook;
- int active, dolock = ((ev->ws_flags & WSEVENT_MPSAFE) == 0);
+ int active;
- if (dolock)
- KERNEL_LOCK();
mtx_enter(&ev->ws_mtx);
active = knote_process(kn, kev);
mtx_leave(&ev->ws_mtx);
- if (dolock)
- KERNEL_UNLOCK();
return (active);
-
}
Index: sys/dev/wscons/wseventvar.h
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wseventvar.h,v
diff -u -p -r1.14 wseventvar.h
--- sys/dev/wscons/wseventvar.h 21 Jan 2025 20:13:19 -0000 1.14
+++ sys/dev/wscons/wseventvar.h 18 Jul 2025 09:23:36 -0000
@@ -87,10 +87,6 @@
* m ws_mtx
*/
-/*
- * XXXSMP: Non WSEVENT_MPSAFE wseventvar structures rely on kernel lock
- */
-
/* WSEVENT_QSIZE should be a power of two so that `%' is fast */
#define WSEVENT_QSIZE 256 /* may need tuning; this uses 2k */
@@ -99,7 +95,6 @@ struct wseventvar {
synchronously) */
volatile u_int ws_put; /* [m] put (write) index (modified by
interrupt) */
- int ws_flags; /* [I] flags, see below*/
struct mutex ws_mtx;
struct klist ws_klist; /* [m] list of knotes */
struct sigio_ref ws_sigio; /* async I/O registration */
@@ -109,8 +104,6 @@ struct wseventvar {
events */
};
-#define WSEVENT_MPSAFE 0x0001
-
static inline void
wsevent_wakeup(struct wseventvar *ev)
{
@@ -131,18 +124,10 @@ wsevent_wakeup(struct wseventvar *ev)
pgsigio(&ev->ws_sigio, SIGIO, 0);
}
-#define WSEVENT_WAKEUP(ev) do { wsevent_wakeup(ev); } while (0)
-
-int wsevent_init_flags(struct wseventvar *, int);
+int wsevent_init(struct wseventvar *);
void wsevent_fini(struct wseventvar *);
int wsevent_read(struct wseventvar *, struct uio *, int);
int wsevent_kqfilter(struct wseventvar *, struct knote *);
-
-static inline int
-wsevent_init(struct wseventvar *ev)
-{
- return wsevent_init_flags(ev, 0);
-}
/*
* PWSEVENT is set just above PSOCK, which is just above TTIPRI, on the
Index: sys/dev/wscons/wskbd.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wskbd.c,v
diff -u -p -r1.123 wskbd.c
--- sys/dev/wscons/wskbd.c 14 Feb 2025 13:29:00 -0000 1.123
+++ sys/dev/wscons/wskbd.c 18 Jul 2025 09:23:36 -0000
@@ -866,7 +866,7 @@ wskbdopen(dev_t dev, int flags, int mode
return (EBUSY);
evar = &sc->sc_base.me_evar;
- if (wsevent_init_flags(evar, WSEVENT_MPSAFE))
+ if (wsevent_init(evar))
return (EBUSY);
error = wskbd_do_open(sc, evar);
Index: sys/dev/wscons/wsmouse.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wsmouse.c,v
diff -u -p -r1.75 wsmouse.c
--- sys/dev/wscons/wsmouse.c 30 Jan 2025 08:53:29 -0000 1.75
+++ sys/dev/wscons/wsmouse.c 18 Jul 2025 09:23:36 -0000
@@ -325,7 +325,7 @@ wsmouseopen(dev_t dev, int flags, int mo
return (EBUSY);
evar = &sc->sc_base.me_evar;
- if (wsevent_init_flags(evar, WSEVENT_MPSAFE))
+ if (wsevent_init(evar))
return (EBUSY);
error = wsmousedoopen(sc, evar);
Index: sys/dev/wscons/wsmux.c
===================================================================
RCS file: /cvs/src/sys/dev/wscons/wsmux.c,v
diff -u -p -r1.61 wsmux.c
--- sys/dev/wscons/wsmux.c 22 Jan 2025 15:06:56 -0000 1.61
+++ sys/dev/wscons/wsmux.c 18 Jul 2025 09:23:36 -0000
@@ -208,7 +208,7 @@ wsmuxopen(dev_t dev, int flags, int mode
return (EBUSY);
evar = &sc->sc_base.me_evar;
- if (wsevent_init_flags(evar, WSEVENT_MPSAFE))
+ if (wsevent_init(evar))
return (EBUSY);
#ifdef WSDISPLAY_COMPAT_RAWKBD
sc->sc_rawkbd = 0;
Wipe out WSEVENT_MPSAFE stuff