From 37151a41df800493cfcbbef4f7208ffe04feb959 Mon Sep 17 00:00:00 2001
From: Yuki Tsunashima <ytsunashima@jp.adit-jv.com>
Date: Mon, 29 Jul 2019 17:10:36 +0200
Subject: [PATCH] ALSA: pcm: fix lost wakeup event scenarios in snd_pcm_drain
Git-commit: 37151a41df800493cfcbbef4f7208ffe04feb959
Patch-mainline: 5.3-rc3
References: bsc#1051510
lost wakeup can occur after enabling irq, therefore put task
into interruptible before enabling interrupts,
without this change, task can be put to sleep and snd_pcm_drain
will delay
Fixes: f2b3614cefb6 ("ALSA: PCM - Don't check DMA time-out too shortly")
Signed-off-by: Yuki Tsunashima <ytsunashima@jp.adit-jv.com>
Signed-off-by: Suresh Udipi <sudipi@jp.adit-jv.com>
[ported from 4.9]
Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/pcm_native.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1730,6 +1730,7 @@ static int snd_pcm_drain(struct snd_pcm_
if (!to_check)
break; /* all drained */
init_waitqueue_entry(&wait, current);
+ set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&to_check->sleep, &wait);
snd_pcm_stream_unlock_irq(substream);
up_read(&snd_pcm_link_rwsem);
@@ -1744,7 +1745,7 @@ static int snd_pcm_drain(struct snd_pcm_
}
tout = msecs_to_jiffies(tout * 1000);
}
- tout = schedule_timeout_interruptible(tout);
+ tout = schedule_timeout(tout);
down_read(&snd_pcm_link_rwsem);
snd_pcm_stream_lock_irq(substream);
remove_wait_queue(&to_check->sleep, &wait);