Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/dev Pull up following revision(s) (requested by mrg i...



details:   https://anonhg.NetBSD.org/src/rev/56de63111fa2
branches:  netbsd-6
changeset: 774045:56de63111fa2
user:      riz <riz%NetBSD.org@localhost>
date:      Mon May 07 03:03:18 2012 +0000

description:
Pull up following revision(s) (requested by mrg in ticket #205):
        sys/dev/audio.c: revision 1.260
don't hold the thread lock while calling allocm() or freem().  fixes PR#46121

diffstat:

 sys/dev/audio.c |  28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diffs (86 lines):

diff -r ba48d9ff7c34 -r 56de63111fa2 sys/dev/audio.c
--- a/sys/dev/audio.c   Mon May 07 03:01:12 2012 +0000
+++ b/sys/dev/audio.c   Mon May 07 03:03:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.257.2.2 2012/04/09 17:46:58 riz Exp $      */
+/*     $NetBSD: audio.c,v 1.257.2.3 2012/05/07 03:03:18 riz Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -155,7 +155,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.257.2.2 2012/04/09 17:46:58 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.257.2.3 2012/05/07 03:03:18 riz Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -390,6 +390,7 @@
        mixer_devinfo_t mi;
        int iclass, mclass, oclass, rclass, props;
        int record_master_found, record_source_found;
+       bool can_capture, can_playback;
 
        sc = device_private(self);
        sc->dev = self;
@@ -452,32 +453,27 @@
        aprint_naive("\n");
        aprint_normal("\n");
 
-       /*
-        * XXX  Would like to not hold the sc_lock around this whole block
-        * escpially for audio_alloc_ring(), except that the latter calls
-        * ->round_blocksize() which demands the thread lock to be taken.
-        *
-        * Revisit.
-        */
        mutex_enter(sc->sc_lock);
-       if (audio_can_playback(sc)) {
+       can_playback = audio_can_playback(sc);
+       can_capture = audio_can_capture(sc);
+       mutex_exit(sc->sc_lock);
+
+       if (can_playback) {
                error = audio_alloc_ring(sc, &sc->sc_pr,
                    AUMODE_PLAY, AU_RING_SIZE);
                if (error) {
                        sc->hw_if = NULL;
-                       mutex_exit(sc->sc_lock);
                        aprint_error("audio: could not allocate play buffer\n");
                        return;
                }
        }
-       if (audio_can_capture(sc)) {
+       if (can_capture) {
                error = audio_alloc_ring(sc, &sc->sc_rr,
                    AUMODE_RECORD, AU_RING_SIZE);
                if (error) {
                        if (sc->sc_pr.s.start != 0)
                                audio_free_ring(sc, &sc->sc_pr);
                        sc->hw_if = NULL;
-                       mutex_exit(sc->sc_lock);
                        aprint_error("audio: could not allocate record buffer\n");
                        return;
                }
@@ -485,6 +481,7 @@
 
        sc->sc_lastgain = 128;
 
+       mutex_enter(sc->sc_lock);
        error = audio_set_defaults(sc, 0);
        mutex_exit(sc->sc_lock);
        if (error != 0) {
@@ -885,8 +882,11 @@
        if (bufsize < AUMINBUF)
                bufsize = AUMINBUF;
        ROUNDSIZE(bufsize);
-       if (hw->round_buffersize)
+       if (hw->round_buffersize) {
+               mutex_enter(sc->sc_lock);
                bufsize = hw->round_buffersize(hdl, direction, bufsize);
+               mutex_exit(sc->sc_lock);
+       }
        if (hw->allocm)
                r->s.start = hw->allocm(hdl, direction, bufsize);
        else



Home | Main Index | Thread Index | Old Index