ALSA: pcm: Allow drivers to set R/W wait time.
authorLiam Girdwood <liam.r.girdwood@linux.intel.com>
Fri, 6 Jul 2018 12:50:36 +0000 (13:50 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 6 Jul 2018 13:00:25 +0000 (15:00 +0200)
Currently ALSA core blocks userspace for about 10 seconds for PCM R/W IO.
This needs to be configurable for modern hardware like DSPs where no
pointer update in milliseconds can indicate terminal DSP errors.

Add a substream variable to set the wait time in ms. This allows userspace
and drivers to recover more quickly from terminal DSP errors.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/pcm.h
sound/core/pcm_lib.c

index e054c58..fcdf358 100644 (file)
@@ -462,6 +462,7 @@ struct snd_pcm_substream {
         /* -- timer section -- */
        struct snd_timer *timer;                /* timer */
        unsigned timer_running: 1;      /* time is running */
+       long wait_time; /* time in ms for R/W to wait for avail */
        /* -- next substream -- */
        struct snd_pcm_substream *next;
        /* -- linked substreams -- */
index c1d2e8e..5736860 100644 (file)
@@ -1833,12 +1833,19 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
        if (runtime->no_period_wakeup)
                wait_time = MAX_SCHEDULE_TIMEOUT;
        else {
-               wait_time = 10;
-               if (runtime->rate) {
-                       long t = runtime->period_size * 2 / runtime->rate;
-                       wait_time = max(t, wait_time);
+               /* use wait time from substream if available */
+               if (substream->wait_time) {
+                       wait_time = substream->wait_time;
+               } else {
+                       wait_time = 10;
+
+                       if (runtime->rate) {
+                               long t = runtime->period_size * 2 /
+                                        runtime->rate;
+                               wait_time = max(t, wait_time);
+                       }
+                       wait_time = msecs_to_jiffies(wait_time * 1000);
                }
-               wait_time = msecs_to_jiffies(wait_time * 1000);
        }
 
        for (;;) {