From 15555d3e6f7a2de458002fb16e136c6155d5f57a Mon Sep 17 00:00:00 2001 From: Preetam Singh Ranawat Date: Tue, 17 Jan 2017 16:24:40 +0530 Subject: [PATCH] ALSA: pcm: fix blocking while loop in snd_pcm_update_hw_ptr0() When period interrupts are disabled, while loop in snd_pcm_update_hw_ptr0() results in the machine locking up if runtime->hw_ptr_buffer_jiffies is 0. Validate runtime->hw_ptr_buffer_jiffies value before while loop to avoid delta check. CRs-Fixed: 1109229 Change-Id: Ib20b71c70aa4a8bee2837d1f3b5a91ad4ce083da Signed-off-by: Preetam Singh Ranawat --- sound/core/pcm_lib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 2236b5e0c1f2..cb97292b4758 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -341,7 +341,12 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, * the elapsed time to detect xruns. */ jdelta = curr_jiffies - runtime->hw_ptr_jiffies; +#ifdef CONFIG_AUDIO_QGKI + if ((jdelta < runtime->hw_ptr_buffer_jiffies / 2) || + (runtime->hw_ptr_buffer_jiffies <= 0)) +#else if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) +#endif goto no_delta_check; hdelta = jdelta - delta * HZ / runtime->rate; xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1;