audio: fix audio driver del_timer BUG_ON crash issue [1/1]
authorJian Xu <jian.xu@amlogic.com>
Wed, 7 Nov 2018 14:00:44 +0000 (22:00 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Tue, 13 Nov 2018 08:53:12 +0000 (01:53 -0700)
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 <jian.xu@amlogic.com>
sound/soc/amlogic/meson/i2s.c

index 4ee75a0..461fe03 100644 (file)
@@ -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)