Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys/dev/usb sc_intr_lock is protecting against usb call...
details: https://anonhg.NetBSD.org/src/rev/fc7ac22eeeb2
branches: nick-nhusb
changeset: 334447:fc7ac22eeeb2
user: skrll <skrll%NetBSD.org@localhost>
date: Wed Mar 23 22:11:20 2016 +0000
description:
sc_intr_lock is protecting against usb callbacks so can be IPL_SOFTUSB
diffstat:
sys/dev/usb/uaudio.c | 48 +++++++++++++++++++++---------------------------
1 files changed, 21 insertions(+), 27 deletions(-)
diffs (183 lines):
diff -r 616fffed6dfd -r fc7ac22eeeb2 sys/dev/usb/uaudio.c
--- a/sys/dev/usb/uaudio.c Wed Mar 23 22:04:18 2016 +0000
+++ b/sys/dev/usb/uaudio.c Wed Mar 23 22:11:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uaudio.c,v 1.140.2.14 2016/03/23 22:04:18 skrll Exp $ */
+/* $NetBSD: uaudio.c,v 1.140.2.15 2016/03/23 22:11:20 skrll Exp $ */
/*
* Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.140.2.14 2016/03/23 22:04:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.140.2.15 2016/03/23 22:11:20 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -177,12 +177,8 @@
};
/*
- * XXX Locking notes:
- *
- * The MI USB audio subsystem is not MP-SAFE. Our strategy here
- * is to ensure we have the kernel lock held when calling into
- * usbd, and, generally, to have dropped the sc_intr_lock during
- * these sections as well since the usb code will sleep.
+ * The MI USB audio subsystem is now MP-SAFE and expects sc_intr_lock to be
+ * held on entry the callbacks passed to uaudio_trigger_{in,out}put
*/
struct uaudio_softc {
device_t sc_dev; /* base device */
@@ -431,7 +427,7 @@
sc->sc_dev = self;
sc->sc_udev = uiaa->uiaa_device;
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
- mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
+ mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
strlcpy(sc->sc_adev.name, "USB audio", sizeof(sc->sc_adev.name));
strlcpy(sc->sc_adev.version, "", sizeof(sc->sc_adev.version));
@@ -2237,14 +2233,14 @@
DPRINTF("%s", "enter\n");
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_exit(&sc->sc_intr_lock);
if (sc->sc_playchan.pipe != NULL) {
uaudio_chan_abort(sc, &sc->sc_playchan);
uaudio_chan_free_buffers(sc, &sc->sc_playchan);
uaudio_chan_close(sc, &sc->sc_playchan);
sc->sc_playchan.intr = NULL;
}
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_enter(&sc->sc_intr_lock);
return 0;
}
@@ -2256,14 +2252,14 @@
DPRINTF("%s", "enter\n");
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_exit(&sc->sc_intr_lock);
if (sc->sc_recchan.pipe != NULL) {
uaudio_chan_abort(sc, &sc->sc_recchan);
uaudio_chan_free_buffers(sc, &sc->sc_recchan);
uaudio_chan_close(sc, &sc->sc_recchan);
sc->sc_recchan.intr = NULL;
}
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_enter(&sc->sc_intr_lock);
return 0;
}
@@ -2605,17 +2601,17 @@
"fraction=0.%03d\n", ch->sample_size, ch->bytes_per_frame,
ch->fraction);
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_exit(&sc->sc_intr_lock);
err = uaudio_chan_open(sc, ch);
if (err) {
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_enter(&sc->sc_intr_lock);
return EIO;
}
err = uaudio_chan_alloc_buffers(sc, ch);
if (err) {
uaudio_chan_close(sc, ch);
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_enter(&sc->sc_intr_lock);
return EIO;
}
@@ -2628,7 +2624,7 @@
uaudio_chan_rtransfer(ch);
}
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_enter(&sc->sc_intr_lock);
return 0;
}
@@ -2655,17 +2651,17 @@
"fraction=0.%03d\n", ch->sample_size, ch->bytes_per_frame,
ch->fraction);
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_exit(&sc->sc_intr_lock);
err = uaudio_chan_open(sc, ch);
if (err) {
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_enter(&sc->sc_intr_lock);
return EIO;
}
err = uaudio_chan_alloc_buffers(sc, ch);
if (err) {
uaudio_chan_close(sc, ch);
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_enter(&sc->sc_intr_lock);
return EIO;
}
@@ -2674,7 +2670,7 @@
for (i = 0; i < UAUDIO_NCHANBUFS-1; i++) /* XXX */
uaudio_chan_ptransfer(ch);
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_enter(&sc->sc_intr_lock);
return 0;
}
@@ -2798,7 +2794,6 @@
usbd_destroy_xfer(ch->chanbufs[i].xfer);
}
-/* Called with USB lock held. */
Static void
uaudio_chan_ptransfer(struct chan *ch)
{
@@ -2887,20 +2882,19 @@
#endif
ch->transferred += cb->size;
- mutex_spin_enter(&ch->sc->sc_intr_lock);
+ mutex_enter(&ch->sc->sc_intr_lock);
/* Call back to upper layer */
while (ch->transferred >= ch->blksize) {
ch->transferred -= ch->blksize;
DPRINTFN(5, "call %p(%p)\n", ch->intr, ch->arg);
ch->intr(ch->arg);
}
- mutex_spin_exit(&ch->sc->sc_intr_lock);
+ mutex_exit(&ch->sc->sc_intr_lock);
/* start next transfer */
uaudio_chan_ptransfer(ch);
}
-/* Called with USB lock held. */
Static void
uaudio_chan_rtransfer(struct chan *ch)
{
@@ -2990,13 +2984,13 @@
/* Call back to upper layer */
ch->transferred += count;
- mutex_spin_enter(&ch->sc->sc_intr_lock);
+ mutex_enter(&ch->sc->sc_intr_lock);
while (ch->transferred >= ch->blksize) {
ch->transferred -= ch->blksize;
DPRINTFN(5, "call %p(%p)\n", ch->intr, ch->arg);
ch->intr(ch->arg);
}
- mutex_spin_exit(&ch->sc->sc_intr_lock);
+ mutex_exit(&ch->sc->sc_intr_lock);
/* start next transfer */
uaudio_chan_rtransfer(ch);
Home |
Main Index |
Thread Index |
Old Index