diff --git a/share/man/man9/pserialize.9 b/share/man/man9/pserialize.9 index 75bd3fa85d61..f6669c306aab 100644 --- a/share/man/man9/pserialize.9 +++ b/share/man/man9/pserialize.9 @@ -67,9 +67,10 @@ Takes the IPL value returned by .It Fn pserialize_perform Perform the passive serialization on the writer side. Passing of this function ensures that no readers are in action. -Writers must be additionally serialized with a separate mechanism, -e.g. -.Xr mutex 9 . +Writers are typically additionally serialized with a separate +mechanism, e.g. +.Xr mutex 9 , +to remove objects used by readers from a published list. Operation blocks and it may only be performed from thread context. .El .\" ----- @@ -152,14 +153,15 @@ readers: break; } } + mutex_exit(&frobbotzim.lock); + /* * Wait for all existing readers to complete. New readers will * not see f because the list no longer points to it. */ pserialize_perform(frobbotzim.psz); - /* Now nobody else can be touching f, so it is safe to free. */ - mutex_exit(&frobbotzim.lock); + /* Now nobody else can be touching f, so it is safe to free. */ if (f != NULL) pool_put(&frotz_pool, f); .Ed diff --git a/sys/dev/audio/audio.c b/sys/dev/audio/audio.c index 23782d26496d..1193aa2ade7a 100644 --- a/sys/dev/audio/audio.c +++ b/sys/dev/audio/audio.c @@ -114,7 +114,7 @@ * halt_output x x + * halt_input x x + * speaker_ctl x x - * getdev - x + * getdev - - * set_port - x + * get_port - x + * query_devinfo - x @@ -1322,6 +1322,7 @@ audiodetach(device_t self, int flags) SLIST_FOREACH(file, &sc->sc_files, entry) { atomic_store_relaxed(&file->dying, true); } + mutex_exit(sc->sc_lock); /* * Wait for existing users to drain. @@ -1331,7 +1332,6 @@ audiodetach(device_t self, int flags) * be psref_released. */ pserialize_perform(sc->sc_psz); - mutex_exit(sc->sc_lock); psref_target_destroy(&sc->sc_psref, audio_psref_class); /* @@ -3113,9 +3113,7 @@ audio_ioctl(dev_t dev, struct audio_softc *sc, u_long cmd, void *addr, int flag, break; case AUDIO_GETDEV: - mutex_enter(sc->sc_lock); error = sc->hw_if->getdev(sc->hw_hdl, (audio_device_t *)addr); - mutex_exit(sc->sc_lock); break; case AUDIO_GETENC: @@ -8291,9 +8289,7 @@ mixer_ioctl(struct audio_softc *sc, u_long cmd, void *addr, int flag, case AUDIO_GETDEV: TRACE(2, "AUDIO_GETDEV"); - mutex_enter(sc->sc_lock); error = sc->hw_if->getdev(sc->hw_hdl, (audio_device_t *)addr); - mutex_exit(sc->sc_lock); break; case AUDIO_MIXER_DEVINFO: diff --git a/sys/kern/subr_pserialize.c b/sys/kern/subr_pserialize.c index 48424385cf77..249c9c58f16c 100644 --- a/sys/kern/subr_pserialize.c +++ b/sys/kern/subr_pserialize.c @@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.17 2019/12/05 03:21:29 riastra #include struct pserialize { - lwp_t * psz_owner; + char psz_dummy; }; static kmutex_t psz_lock __cacheline_aligned; @@ -86,16 +86,13 @@ void pserialize_destroy(pserialize_t psz) { - KASSERT(psz->psz_owner == NULL); kmem_free(psz, sizeof(*psz)); } /* * pserialize_perform: * - * Perform the write side of passive serialization. This operation - * MUST be serialized at a caller level (e.g. with a mutex or by a - * single-threaded use). + * Perform the write side of passive serialization. */ void pserialize_perform(pserialize_t psz) @@ -107,22 +104,17 @@ pserialize_perform(pserialize_t psz) if (__predict_false(panicstr != NULL)) { return; } - KASSERT(psz->psz_owner == NULL); if (__predict_false(mp_online == false)) { psz_ev_excl.ev_count++; return; } - psz->psz_owner = curlwp; - /* * Broadcast a NOP to all CPUs and wait until all of them complete. */ xc_barrier(XC_HIGHPRI); - KASSERT(psz->psz_owner == curlwp); - psz->psz_owner = NULL; mutex_enter(&psz_lock); psz_ev_excl.ev_count++; mutex_exit(&psz_lock);