git: 5541489df676 - stable/15 - snd_dummy: Do not use dummy_chan_io() as mpu401's interrupt handler

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Fri, 20 Nov 2026 09:49:04 UTC
The branch stable/15 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=5541489df676c9723cac2d665bb4e6705cc3ce53

commit 5541489df676c9723cac2d665bb4e6705cc3ce53
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2026-11-10 13:02:13 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-11-20 09:46:39 +0000

    snd_dummy: Do not use dummy_chan_io() as mpu401's interrupt handler
    
    dummy_chan_io() runs with sc->lock held, but mpu401 calls its handler
    from a callout with no mutex associated with it, so writing to the MIDI
    device node caused a panic.
    
    Give mpu401 its own handler, and leave MIDI to mpu401's timer instead of
    the PCM callout.
    
    Fixes:          e963472ef853 ("snd_dummy: Initial MIDI support")
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit c8d1c94741231d95964b91910880769019478854)
---
 sys/dev/sound/dummy.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sys/dev/sound/dummy.c b/sys/dev/sound/dummy.c
index 7b456884040e..47bd0c825561 100644
--- a/sys/dev/sound/dummy.c
+++ b/sys/dev/sound/dummy.c
@@ -98,9 +98,6 @@ dummy_chan_io(void *arg)
 	struct dummy_chan *ch;
 	int i = 0;
 
-	if (sc->mpu_intr)
-		(sc->mpu_intr)(sc->mpu);
-
 	if (sc->stopped)
 		return;
 
@@ -324,6 +321,15 @@ dummy_mpu_uninit(struct mpu401 *arg, void *cookie)
 	return (0);
 }
 
+static void
+dummy_mpu_intr(void *arg)
+{
+	struct dummy_softc *sc = arg;
+
+	if (sc->mpu_intr != NULL)
+		(sc->mpu_intr)(sc->mpu);
+}
+
 static kobj_method_t dummy_mpu_methods[] = {
 	KOBJMETHOD(mpufoi_read,		dummy_mpu_read),
 	KOBJMETHOD(mpufoi_write,	dummy_mpu_write),
@@ -393,7 +399,7 @@ dummy_attach(device_t dev)
 	 */
 	make_dev_alias(sc->info.dsp_dev, "dsp.dummy");
 
-	sc->mpu = mpu401_init(&dummy_mpu_class, sc, dummy_chan_io,
+	sc->mpu = mpu401_init(&dummy_mpu_class, sc, dummy_mpu_intr,
 	    &sc->mpu_intr);
 	if (sc->mpu == NULL)
 		return (ENXIO);