Date: Thu, 10 Jul 2008 08:43:24 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 144997 for review Message-ID: <200807100843.m6A8hO5k068587@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144997 Change 144997 by hselasky@hselasky_laptop001 on 2008/07/10 08:43:16 Resolve locking issues in the sound subsystem with regard to USB. Affected files ... .. //depot/projects/usb/src/sys/dev/sound/pcm/channel.c#6 edit .. //depot/projects/usb/src/sys/dev/sound/pcm/channel.h#4 edit .. //depot/projects/usb/src/sys/dev/sound/pcm/sound.c#7 edit Differences ... ==== //depot/projects/usb/src/sys/dev/sound/pcm/channel.c#6 (text+ko) ==== @@ -570,13 +570,26 @@ void chn_intr(struct pcm_channel *c) { - CHN_LOCK(c); + uint8_t do_unlock; + if (CHN_LOCK_OWNED(c)) { + /* + * Allow sound drivers to call this function with + * "CHN_LOCK()" locked: + */ + do_unlock = 0; + } else { + do_unlock = 1; + CHN_LOCK(c); + } c->interrupts++; if (c->direction == PCMDIR_PLAY) chn_wrintr(c); else chn_rdintr(c); - CHN_UNLOCK(c); + if (do_unlock) { + CHN_UNLOCK(c); + } + return; } u_int32_t ==== //depot/projects/usb/src/sys/dev/sound/pcm/channel.h#4 (text+ko) ==== @@ -258,11 +258,13 @@ #endif #ifdef USING_MUTEX +#define CHN_LOCK_OWNED(c) mtx_owned((struct mtx *)((c)->lock)) #define CHN_LOCK(c) mtx_lock((struct mtx *)((c)->lock)) #define CHN_UNLOCK(c) mtx_unlock((struct mtx *)((c)->lock)) #define CHN_TRYLOCK(c) mtx_trylock((struct mtx *)((c)->lock)) #define CHN_LOCKASSERT(c) mtx_assert((struct mtx *)((c)->lock), MA_OWNED) #else +#define CHN_LOCK_OWNED(c) 0 #define CHN_LOCK(c) #define CHN_UNLOCK(c) #define CHN_TRYLOCK(c) ==== //depot/projects/usb/src/sys/dev/sound/pcm/sound.c#7 (text+ko) ==== @@ -82,7 +82,7 @@ struct mtx *m; m = malloc(sizeof(*m), M_DEVBUF, M_WAITOK | M_ZERO); - mtx_init(m, desc, type, MTX_DEF|MTX_RECURSE); + mtx_init(m, desc, type, MTX_DEF); return m; #else return (void *)0xcafebabe;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807100843.m6A8hO5k068587>