Commit e026d85d authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[sound/oss i810] fix wait queue race in drain_dac

This particular one fixes a textbook race condition in drain_dac
that causes it to timeout when it shouldn't.
parent 3d29f7cb
...@@ -1241,6 +1241,17 @@ static int drain_dac(struct i810_state *state, int signals_allowed) ...@@ -1241,6 +1241,17 @@ static int drain_dac(struct i810_state *state, int signals_allowed)
spin_lock_irqsave(&state->card->lock, flags); spin_lock_irqsave(&state->card->lock, flags);
i810_update_ptr(state); i810_update_ptr(state);
count = dmabuf->count; 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); spin_unlock_irqrestore(&state->card->lock, flags);
if (count <= 0) if (count <= 0)
...@@ -1260,16 +1271,6 @@ static int drain_dac(struct i810_state *state, int signals_allowed) ...@@ -1260,16 +1271,6 @@ static int drain_dac(struct i810_state *state, int signals_allowed)
break; 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* * set the timeout to significantly longer than it *should*
* take for the DAC to drain the DMA buffer * take for the DAC to drain the DMA buffer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment