Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev deal with PR#46232: ensure locking around audio_cle...



details:   https://anonhg.NetBSD.org/src/rev/c4bb0385032a
branches:  trunk
changeset: 778443:c4bb0385032a
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Mar 26 18:26:10 2012 +0000

description:
deal with PR#46232:  ensure locking around audio_clear() is handled
consistently and avoid locking against self.

diffstat:

 sys/dev/audio.c |  30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diffs (121 lines):

diff -r a2248d9e554e -r c4bb0385032a sys/dev/audio.c
--- a/sys/dev/audio.c   Mon Mar 26 16:28:08 2012 +0000
+++ b/sys/dev/audio.c   Mon Mar 26 18:26:10 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.258 2012/02/21 20:53:34 nonaka Exp $       */
+/*     $NetBSD: audio.c,v 1.259 2012/03/26 18:26:10 mrg Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -155,7 +155,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.258 2012/02/21 20:53:34 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.259 2012/03/26 18:26:10 mrg Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -241,6 +241,7 @@
 void   audio_calcwater(struct audio_softc *);
 int    audio_drain(struct audio_softc *);
 void   audio_clear(struct audio_softc *);
+void   audio_clear_intr_unlocked(struct audio_softc *sc);
 static inline void audio_pint_silence
        (struct audio_softc *, struct audio_ringbuffer *, uint8_t *, int);
 
@@ -1992,7 +1993,6 @@
 
        KASSERT(mutex_owned(sc->sc_lock));
 
-       mutex_enter(sc->sc_intr_lock);
        if (sc->sc_rbus) {
                cv_broadcast(&sc->sc_rchan);
                sc->hw_if->halt_input(sc->hw_hdl);
@@ -2005,6 +2005,14 @@
                sc->sc_pbus = false;
                sc->sc_pr.pause = false;
        }
+}
+
+void
+audio_clear_intr_unlocked(struct audio_softc *sc)
+{
+
+       mutex_enter(sc->sc_intr_lock);
+       audio_clear(sc);
        mutex_exit(sc->sc_intr_lock);
 }
 
@@ -3643,7 +3651,7 @@
        setmode = 0;
        if (nr > 0) {
                if (!cleared) {
-                       audio_clear(sc);
+                       audio_clear_intr_unlocked(sc);
                        cleared = true;
                }
                modechange = true;
@@ -3651,7 +3659,7 @@
        }
        if (np > 0) {
                if (!cleared) {
-                       audio_clear(sc);
+                       audio_clear_intr_unlocked(sc);
                        cleared = true;
                }
                modechange = true;
@@ -3660,7 +3668,7 @@
 
        if (SPECIFIED(ai->mode)) {
                if (!cleared) {
-                       audio_clear(sc);
+                       audio_clear_intr_unlocked(sc);
                        cleared = true;
                }
                modechange = true;
@@ -3754,7 +3762,7 @@
 
        if (SPECIFIED(p->port)) {
                if (!cleared) {
-                       audio_clear(sc);
+                       audio_clear_intr_unlocked(sc);
                        cleared = true;
                }
                error = au_set_port(sc, &sc->sc_outports, p->port);
@@ -3763,7 +3771,7 @@
        }
        if (SPECIFIED(r->port)) {
                if (!cleared) {
-                       audio_clear(sc);
+                       audio_clear_intr_unlocked(sc);
                        cleared = true;
                }
                error = au_set_port(sc, &sc->sc_inports, r->port);
@@ -3825,7 +3833,7 @@
                /* Block size specified explicitly. */
                if (ai->blocksize == 0) {
                        if (!cleared) {
-                               audio_clear(sc);
+                               audio_clear_intr_unlocked(sc);
                                cleared = true;
                        }
                        sc->sc_blkset = false;
@@ -3836,7 +3844,7 @@
                        /* check whether new blocksize changes actually */
                        if (hw->round_blocksize == NULL) {
                                if (!cleared) {
-                                       audio_clear(sc);
+                                       audio_clear_intr_unlocked(sc);
                                        cleared = true;
                                }
                                sc->sc_pr.blksize = ai->blocksize;
@@ -3849,7 +3857,7 @@
                                if (pblksize != sc->sc_pr.blksize ||
                                    rblksize != sc->sc_rr.blksize) {
                                        if (!cleared) {
-                                               audio_clear(sc);
+                                               audio_clear_intr_unlocked(sc);
                                                cleared = true;
                                        }
                                        sc->sc_pr.blksize = ai->blocksize;



Home | Main Index | Thread Index | Old Index