Tue Dec 13 12:26:32 2011 UTC ()
- convert the audio softintr's to SOFTINT_SERIAL.  right now they're on
  the same priority level as USB and if an audio softintr is blocked
  waiting for a usb event, they'll dead lock.  also, audio being higher
  priority is a fine idea.

- revert the previous audio.c changes as they were unsafe and this change
  obviates the need for them.

XXX:  convert the audio softint's to use a high priority thread or a
XXX:  workqueue would be better again.


(mrg)
diff -r1.256 -r1.257 src/sys/dev/audio.c
diff -r1.125 -r1.126 src/sys/dev/usb/uaudio.c

cvs diff -r1.256 -r1.257 src/sys/dev/Attic/audio.c (expand / switch to unified diff)

--- src/sys/dev/Attic/audio.c 2011/12/09 05:08:25 1.256
+++ src/sys/dev/Attic/audio.c 2011/12/13 12:26:32 1.257
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: audio.c,v 1.256 2011/12/09 05:08:25 mrg Exp $ */ 1/* $NetBSD: audio.c,v 1.257 2011/12/13 12:26:32 mrg Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -145,27 +145,27 @@ @@ -145,27 +145,27 @@
145 * query_devinfo - x 145 * query_devinfo - x
146 * allocm - - Called at attach time 146 * allocm - - Called at attach time
147 * freem - - Called at attach time 147 * freem - - Called at attach time
148 * round_buffersize - x 148 * round_buffersize - x
149 * mappage - - Mem. unchanged after attach 149 * mappage - - Mem. unchanged after attach
150 * get_props - x 150 * get_props - x
151 * trigger_output x x 151 * trigger_output x x
152 * trigger_input x x 152 * trigger_input x x
153 * dev_ioctl - x 153 * dev_ioctl - x
154 * get_locks - - Called at attach time 154 * get_locks - - Called at attach time
155 */ 155 */
156 156
157#include <sys/cdefs.h> 157#include <sys/cdefs.h>
158__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.256 2011/12/09 05:08:25 mrg Exp $"); 158__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.257 2011/12/13 12:26:32 mrg Exp $");
159 159
160#include "audio.h" 160#include "audio.h"
161#if NAUDIO > 0 161#if NAUDIO > 0
162 162
163#include <sys/param.h> 163#include <sys/param.h>
164#include <sys/ioctl.h> 164#include <sys/ioctl.h>
165#include <sys/fcntl.h> 165#include <sys/fcntl.h>
166#include <sys/vnode.h> 166#include <sys/vnode.h>
167#include <sys/select.h> 167#include <sys/select.h>
168#include <sys/poll.h> 168#include <sys/poll.h>
169#include <sys/kmem.h> 169#include <sys/kmem.h>
170#include <sys/malloc.h> 170#include <sys/malloc.h>
171#include <sys/proc.h> 171#include <sys/proc.h>
@@ -482,29 +482,29 @@ audioattach(device_t parent, device_t se @@ -482,29 +482,29 @@ audioattach(device_t parent, device_t se
482 } 482 }
483 } 483 }
484 484
485 sc->sc_lastgain = 128; 485 sc->sc_lastgain = 128;
486 486
487 error = audio_set_defaults(sc, 0); 487 error = audio_set_defaults(sc, 0);
488 mutex_exit(sc->sc_lock); 488 mutex_exit(sc->sc_lock);
489 if (error != 0) { 489 if (error != 0) {
490 aprint_error("audioattach: audio_set_defaults() failed\n"); 490 aprint_error("audioattach: audio_set_defaults() failed\n");
491 sc->hw_if = NULL; 491 sc->hw_if = NULL;
492 return; 492 return;
493 } 493 }
494 494
495 sc->sc_sih_rd = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE, 495 sc->sc_sih_rd = softint_establish(SOFTINT_SERIAL | SOFTINT_MPSAFE,
496 audio_softintr_rd, sc); 496 audio_softintr_rd, sc);
497 sc->sc_sih_wr = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE, 497 sc->sc_sih_wr = softint_establish(SOFTINT_SERIAL | SOFTINT_MPSAFE,
498 audio_softintr_wr, sc); 498 audio_softintr_wr, sc);
499 499
500 iclass = mclass = oclass = rclass = -1; 500 iclass = mclass = oclass = rclass = -1;
501 sc->sc_inports.index = -1; 501 sc->sc_inports.index = -1;
502 sc->sc_inports.master = -1; 502 sc->sc_inports.master = -1;
503 sc->sc_inports.nports = 0; 503 sc->sc_inports.nports = 0;
504 sc->sc_inports.isenum = false; 504 sc->sc_inports.isenum = false;
505 sc->sc_inports.allports = 0; 505 sc->sc_inports.allports = 0;
506 sc->sc_inports.isdual = false; 506 sc->sc_inports.isdual = false;
507 sc->sc_inports.mixerout = -1; 507 sc->sc_inports.mixerout = -1;
508 sc->sc_inports.cur_port = -1; 508 sc->sc_inports.cur_port = -1;
509 sc->sc_outports.index = -1; 509 sc->sc_outports.index = -1;
510 sc->sc_outports.master = -1; 510 sc->sc_outports.master = -1;

cvs diff -r1.125 -r1.126 src/sys/dev/usb/uaudio.c (expand / switch to unified diff)

--- src/sys/dev/usb/uaudio.c 2011/12/09 05:03:18 1.125
+++ src/sys/dev/usb/uaudio.c 2011/12/13 12:26:32 1.126
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uaudio.c,v 1.125 2011/12/09 05:03:18 mrg Exp $ */ 1/* $NetBSD: uaudio.c,v 1.126 2011/12/13 12:26:32 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) at 8 * by Lennart Augustsson (lennart@augustsson.net) at
9 * Carlstedt Research & Technology. 9 * Carlstedt Research & Technology.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * USB audio specs: http://www.usb.org/developers/devclass_docs/audio10.pdf 34 * USB audio specs: http://www.usb.org/developers/devclass_docs/audio10.pdf
35 * http://www.usb.org/developers/devclass_docs/frmts10.pdf 35 * http://www.usb.org/developers/devclass_docs/frmts10.pdf
36 * http://www.usb.org/developers/devclass_docs/termt10.pdf 36 * http://www.usb.org/developers/devclass_docs/termt10.pdf
37 */ 37 */
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.125 2011/12/09 05:03:18 mrg Exp $"); 40__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.126 2011/12/13 12:26:32 mrg Exp $");
41 41
42#include <sys/param.h> 42#include <sys/param.h>
43#include <sys/systm.h> 43#include <sys/systm.h>
44#include <sys/kernel.h> 44#include <sys/kernel.h>
45#include <sys/malloc.h> 45#include <sys/malloc.h>
46#include <sys/device.h> 46#include <sys/device.h>
47#include <sys/ioctl.h> 47#include <sys/ioctl.h>
48#include <sys/file.h> 48#include <sys/file.h>
49#include <sys/reboot.h> /* for bootverbose */ 49#include <sys/reboot.h> /* for bootverbose */
50#include <sys/select.h> 50#include <sys/select.h>
51#include <sys/proc.h> 51#include <sys/proc.h>
52#include <sys/vnode.h> 52#include <sys/vnode.h>
53#include <sys/poll.h> 53#include <sys/poll.h>
@@ -2455,45 +2455,41 @@ uaudio_bsd2value(struct mixerctl *mc, in @@ -2455,45 +2455,41 @@ uaudio_bsd2value(struct mixerctl *mc, in
2455 val = (val + mc->delta/2) * mc->mul / 255 + mc->minval; 2455 val = (val + mc->delta/2) * mc->mul / 255 + mc->minval;
2456 DPRINTFN_CLEAN(5, "val'=%d\n", val); 2456 DPRINTFN_CLEAN(5, "val'=%d\n", val);
2457 return val; 2457 return val;
2458} 2458}
2459 2459
2460Static int 2460Static int
2461uaudio_ctl_get(struct uaudio_softc *sc, int which, struct mixerctl *mc, 2461uaudio_ctl_get(struct uaudio_softc *sc, int which, struct mixerctl *mc,
2462 int chan) 2462 int chan)
2463{ 2463{
2464 int val; 2464 int val;
2465 2465
2466 DPRINTFN(5,"which=%d chan=%d\n", which, chan); 2466 DPRINTFN(5,"which=%d chan=%d\n", which, chan);
2467 KERNEL_LOCK(1, curlwp); 2467 KERNEL_LOCK(1, curlwp);
2468 mutex_exit(&sc->sc_lock); 
2469 val = uaudio_get(sc, which, UT_READ_CLASS_INTERFACE, mc->wValue[chan], 2468 val = uaudio_get(sc, which, UT_READ_CLASS_INTERFACE, mc->wValue[chan],
2470 mc->wIndex, MIX_SIZE(mc->type)); 2469 mc->wIndex, MIX_SIZE(mc->type));
2471 mutex_enter(&sc->sc_lock); 
2472 KERNEL_UNLOCK_ONE(curlwp); 2470 KERNEL_UNLOCK_ONE(curlwp);
2473 return uaudio_value2bsd(mc, val); 2471 return uaudio_value2bsd(mc, val);
2474} 2472}
2475 2473
2476Static void 2474Static void
2477uaudio_ctl_set(struct uaudio_softc *sc, int which, struct mixerctl *mc, 2475uaudio_ctl_set(struct uaudio_softc *sc, int which, struct mixerctl *mc,
2478 int chan, int val) 2476 int chan, int val)
2479{ 2477{
2480 2478
2481 val = uaudio_bsd2value(mc, val); 2479 val = uaudio_bsd2value(mc, val);
2482 KERNEL_LOCK(1, curlwp); 2480 KERNEL_LOCK(1, curlwp);
2483 mutex_exit(&sc->sc_lock); 
2484 uaudio_set(sc, which, UT_WRITE_CLASS_INTERFACE, mc->wValue[chan], 2481 uaudio_set(sc, which, UT_WRITE_CLASS_INTERFACE, mc->wValue[chan],
2485 mc->wIndex, MIX_SIZE(mc->type), val); 2482 mc->wIndex, MIX_SIZE(mc->type), val);
2486 mutex_enter(&sc->sc_lock); 
2487 KERNEL_UNLOCK_ONE(curlwp); 2483 KERNEL_UNLOCK_ONE(curlwp);
2488} 2484}
2489 2485
2490Static int 2486Static int
2491uaudio_mixer_get_port(void *addr, mixer_ctrl_t *cp) 2487uaudio_mixer_get_port(void *addr, mixer_ctrl_t *cp)
2492{ 2488{
2493 struct uaudio_softc *sc; 2489 struct uaudio_softc *sc;
2494 struct mixerctl *mc; 2490 struct mixerctl *mc;
2495 int i, n, vals[MIX_MAX_CHAN], val; 2491 int i, n, vals[MIX_MAX_CHAN], val;
2496 2492
2497 DPRINTFN(2, "index=%d\n", cp->dev); 2493 DPRINTFN(2, "index=%d\n", cp->dev);
2498 sc = addr; 2494 sc = addr;
2499 if (sc->sc_dying) 2495 if (sc->sc_dying)