public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [I810_AUDIO] 1/x: Fix wait queue race in drain_dac
@ 2003-11-22  7:09 Herbert Xu
  2003-11-22  7:13 ` [I810_AUDIO] 2/x: " Herbert Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Herbert Xu @ 2003-11-22  7:09 UTC (permalink / raw)
  To: Jeff Garzik, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

Hi:

This is the first of a number of patches to fix DMA bugs in the
OSS i810_audio driver.

This particular one fixes a textbook race condition in drain_dac
that causes it to timeout when it shouldn't.
-- 
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: p1 --]
[-- Type: text/plain, Size: 1771 bytes --]

Index: kernel-source-2.4/drivers/sound/i810_audio.c
===================================================================
RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.4/drivers/sound/i810_audio.c,v
retrieving revision 1.8
diff -u -r1.8 i810_audio.c
--- kernel-source-2.4/drivers/sound/i810_audio.c	3 Sep 2003 10:27:11 -0000	1.8
+++ kernel-source-2.4/drivers/sound/i810_audio.c	21 Nov 2003 11:20:48 -0000
@@ -1231,6 +1231,17 @@
 		spin_lock_irqsave(&state->card->lock, flags);
 		i810_update_ptr(state);
 		count = dmabuf->count;
+
+		/* It seems that we have to set the current state to
+		 * TASK_INTERRUPTIBLE every time to make the process
+		 * really go to sleep.  This also has to be *after* the
+		 * update_ptr() call because update_ptr is likely to
+		 * do a wake_up() which will unset this before we ever
+		 * try to sleep, resuling in a tight loop in this code
+		 * instead of actually sleeping and waiting for an
+		 * interrupt to wake us up!
+		 */
+		__set_current_state(TASK_INTERRUPTIBLE);
 		spin_unlock_irqrestore(&state->card->lock, flags);
 
 		if (count <= 0)
@@ -1250,16 +1261,6 @@
                         break;
                 }
 
-		/* It seems that we have to set the current state to
-		 * TASK_INTERRUPTIBLE every time to make the process
-		 * really go to sleep.  This also has to be *after* the
-		 * update_ptr() call because update_ptr is likely to
-		 * do a wake_up() which will unset this before we ever
-		 * try to sleep, resuling in a tight loop in this code
-		 * instead of actually sleeping and waiting for an
-		 * interrupt to wake us up!
-		 */
-		set_current_state(TASK_INTERRUPTIBLE);
 		/*
 		 * set the timeout to significantly longer than it *should*
 		 * take for the DAC to drain the DMA buffer

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2004-01-17  3:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-22  7:09 [I810_AUDIO] 1/x: Fix wait queue race in drain_dac Herbert Xu
2003-11-22  7:13 ` [I810_AUDIO] 2/x: " Herbert Xu
2003-11-22  7:19   ` [I810_AUDIO] 3/x: Remove bogus CIV_TO_LVI Herbert Xu
2003-11-22  8:22     ` [I810_AUDIO] 4/x: Clean up with macros Herbert Xu
2003-11-22  8:26       ` [I810_AUDIO] 5/x: Fixed partial DMA transfers Herbert Xu
2003-11-22  8:39         ` Herbert Xu
2003-11-22 23:51           ` [I810_AUDIO] 7/x: Fix OSS fragments Herbert Xu
2003-11-22 23:53             ` [I810_AUDIO] 8/x: Remove divides on playback Herbert Xu
2003-11-23  0:02               ` [I810_AUDIO] 9/x: Fix drain_dac loop when signals_allowed == 0 Herbert Xu
2003-11-23 11:04                 ` [I810_AUDIO] 10/x: Fix reads/writes % 4 != 0 Herbert Xu
2004-01-17  3:58                   ` [I810_AUDIO] 11/x: Fix dead lock in drain_dac Herbert Xu
2004-01-11 21:04   ` [I810_AUDIO] 2/x: Fix wait queue race " Jeff Garzik
2003-12-18  7:23 ` [I810_AUDIO] 1/x: " Jeff Garzik
2004-01-11 21:00 ` Jeff Garzik
2004-01-12  9:46   ` Herbert Xu
2004-01-12 21:48     ` Jeff Garzik
2004-01-12 22:26       ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox