From 500d33fe9aa569672b89c61927760dcc74a96594 Mon Sep 17 00:00:00 2001 From: Jian Xu Date: Wed, 7 Nov 2018 22:00:44 +0800 Subject: [PATCH] audio: fix audio driver del_timer BUG_ON crash issue [1/1] PD#SWPL-972 Problem: audio crash when ATV switch channel long time burning test Solution: there is a risk to fetch the timer lock. when input stop, stop_timer will call del_timer, at the same time the function "aml_i2s_hrtimer_callback" is waiting for the timer lock,after stop_timer release the lock,"aml_i2s_hrtimer_callback" get the lock and call mod_timer again, which will set the timer to pending status. It will cause the next "start input" stage,add_timer will trigger BUG_ON.Now we put the lock before the active status checking then we will not touch the timer. Verify: Need burning test Change-Id: I1fb66903a4d31e9491ac0533e477e1597575d4cf Signed-off-by: Jian Xu --- sound/soc/amlogic/meson/i2s.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/amlogic/meson/i2s.c b/sound/soc/amlogic/meson/i2s.c index 4ee75a0..461fe03 100644 --- a/sound/soc/amlogic/meson/i2s.c +++ b/sound/soc/amlogic/meson/i2s.c @@ -412,13 +412,12 @@ static enum hrtimer_restart aml_i2s_hrtimer_callback(struct hrtimer *timer) struct audio_stream *s = &prtd->s; unsigned int last_ptr, size; unsigned long flags = 0; - + spin_lock_irqsave(&prtd->timer_lock, flags); if (prtd->active == 0) { hrtimer_forward_now(timer, prtd->wakeups_per_second); + spin_unlock_irqrestore(&prtd->timer_lock, flags); return HRTIMER_RESTART; } - - spin_lock_irqsave(&prtd->timer_lock, flags); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { last_ptr = read_i2s_rd_ptr(); if (last_ptr < s->last_ptr) -- 2.7.4