Commit b27c187f authored by Nishanth Aravamudan's avatar Nishanth Aravamudan Committed by Jaroslav Kysela

[ALSA] Fix-up sleeping in sound/usb

USB generic driver,USB USX2Y
Description: Fix-up sleeping in sound/usb. Replace big_mdelay() with
msleep() to guarantee the task delays as expected. This also involved
replacing/removing custom sleep functions.

Patch is compile-tested.
Signed-off-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 989a0b24
...@@ -792,7 +792,7 @@ static int start_urbs(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime) ...@@ -792,7 +792,7 @@ static int start_urbs(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime)
*/ */
static int wait_clear_urbs(snd_usb_substream_t *subs) static int wait_clear_urbs(snd_usb_substream_t *subs)
{ {
int timeout = HZ; unsigned long end_time = jiffies + msecs_to_jiffies(1000);
unsigned int i; unsigned int i;
int alive; int alive;
...@@ -812,7 +812,7 @@ static int wait_clear_urbs(snd_usb_substream_t *subs) ...@@ -812,7 +812,7 @@ static int wait_clear_urbs(snd_usb_substream_t *subs)
break; break;
set_current_state(TASK_UNINTERRUPTIBLE); set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(1); schedule_timeout(1);
} while (--timeout > 0); } while (time_before(jiffies, end_time));
if (alive) if (alive)
snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive); snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive);
return 0; return 0;
......
...@@ -232,8 +232,7 @@ static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) ...@@ -232,8 +232,7 @@ static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp)
if (err) if (err)
return err; return err;
if (dsp->index == 1) { if (dsp->index == 1) {
set_current_state(TASK_UNINTERRUPTIBLE); msleep(250); // give the device some time
schedule_timeout(HZ/4); // give the device some time
err = usX2Y_AsyncSeq04_init(priv); err = usX2Y_AsyncSeq04_init(priv);
if (err) { if (err) {
snd_printk("usX2Y_AsyncSeq04_init error \n"); snd_printk("usX2Y_AsyncSeq04_init error \n");
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
Currently rawusb dma pcm buffer transport (this file) is only available to snd-usb-usx2y. Currently rawusb dma pcm buffer transport (this file) is only available to snd-usb-usx2y.
*/ */
#include <linux/delay.h>
#include "usbusx2yaudio.c" #include "usbusx2yaudio.c"
#if defined(USX2Y_NRPACKS_VARIABLE) || (!defined(USX2Y_NRPACKS_VARIABLE) && USX2Y_NRPACKS == 1) #if defined(USX2Y_NRPACKS_VARIABLE) || (!defined(USX2Y_NRPACKS_VARIABLE) && USX2Y_NRPACKS == 1)
...@@ -520,11 +521,8 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) ...@@ -520,11 +521,8 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream)
usX2Y->hwdep_pcm_shm->playback_iso_start = -1; usX2Y->hwdep_pcm_shm->playback_iso_start = -1;
if (atomic_read(&subs->state) < state_PREPARED) { if (atomic_read(&subs->state) < state_PREPARED) {
while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) { while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) {
signed long timeout;
snd_printd("Wait: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames); snd_printd("Wait: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames);
set_current_state(TASK_INTERRUPTIBLE); if (msleep_interruptible(10)) {
timeout = schedule_timeout(HZ/100 + 1);
if (signal_pending(current)) {
err = -ERESTARTSYS; err = -ERESTARTSYS;
goto up_prepare_mutex; goto up_prepare_mutex;
} }
......
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