PERFORCE change 144997 for review

Hans Petter Selasky hselasky at FreeBSD.org
Thu Jul 10 08:43:25 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=144997

Change 144997 by hselasky at 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;


More information about the p4-projects mailing list