On Mon, Sep 25, 2023 at 04:58:56PM +0300, Vitaliy Makkoveev wrote: > On Mon, Sep 25, 2023 at 05:39:34AM +0000, Visa Hankala wrote: > > On Sun, Sep 24, 2023 at 11:03:54PM +0300, Vitaliy Makkoveev wrote: > > > Please test this diff, I have no midi(4) devices. > > > > > > midi(4) already uses `audio_lock' mutex(9) for filterops, but they are > > > still kernel locked. Wipe out old selwakeup API and make them MP safe. > > > knote_locked(9) will not grab kernel lock, so call it directly from > > > interrupt handlers instead of scheduling software interrupts. > > > > https://marc.info/?l=openbsd-tech&m=167604232828221 has minor takeaways > > if you pay attention. > > > > The only significant difference is mididetach() where you did not replaced > selwakeup() with knote(). Did I missed something? > > @@ -577,30 +562,20 @@ mididetach(struct device *self, int flag > * in read/write/ioctl, which return EIO. > */ > if (sc->flags) { > - KERNEL_ASSERT_LOCKED(); > - if (sc->flags & FREAD) { > + if (sc->flags & FREAD) > wakeup(&sc->inbuf.blocking); > - mtx_enter(&audio_lock); > - selwakeup(&sc->inbuf.sel); > - mtx_leave(&audio_lock); > - }
IIRC, klist_invalidate() wakes up the process, so the selwakeup() section should be removed. Does this sound correct? This is how audio(4) detaches, BTW.