From owner-p4-projects@FreeBSD.ORG Thu Jul 10 08:43:25 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 55963106568B; Thu, 10 Jul 2008 08:43:25 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 19A131065687 for ; Thu, 10 Jul 2008 08:43:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 079298FC13 for ; Thu, 10 Jul 2008 08:43:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m6A8hOIH068589 for ; Thu, 10 Jul 2008 08:43:24 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m6A8hO5k068587 for perforce@freebsd.org; Thu, 10 Jul 2008 08:43:24 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 10 Jul 2008 08:43:24 GMT Message-Id: <200807100843.m6A8hO5k068587@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 144997 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jul 2008 08:43:25 -0000 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;