Module Name:    src
Committed By:   isaki
Date:           Sun Dec 13 05:29:20 UTC 2020

Modified Files:
        src/sys/dev/audio: audio.c

Log Message:
Avoid a dead lock in audiodetach, since rev 1.63.
audio_unlink() must be called without exlock held (and
audio_mixer_destroy() must be called with exlock held).
This makes unplugging during playing/recording work (again).
Reported by Julian Coleman on current-users:
 http://mail-index.netbsd.org/current-users/2020/12/10/msg040050.html


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/audio/audio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.82 src/sys/dev/audio/audio.c:1.83
--- src/sys/dev/audio/audio.c:1.82	Sun Dec 13 05:21:12 2020
+++ src/sys/dev/audio/audio.c	Sun Dec 13 05:29:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.82 2020/12/13 05:21:12 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.83 2020/12/13 05:29:19 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.82 2020/12/13 05:21:12 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.83 2020/12/13 05:29:19 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1331,7 +1331,6 @@ audiodetach(device_t self, int flags)
 	 * that hold sc, and any new calls with files that were for sc will
 	 * fail.  Thus, we now have exclusive access to the softc.
 	 */
-	sc->sc_exlock = 1;
 
 	/*
 	 * Nuke all open instances.
@@ -1357,6 +1356,7 @@ audiodetach(device_t self, int flags)
 	pmf_device_deregister(self);
 
 	/* Free resources */
+	sc->sc_exlock = 1;
 	if (sc->sc_pmixer) {
 		audio_mixer_destroy(sc, sc->sc_pmixer);
 		kmem_free(sc->sc_pmixer, sizeof(*sc->sc_pmixer));

Reply via email to