]> git.baikalelectronics.ru Git - kernel.git/commit
usb: musb: cppi41: restart hrtimer only if not yet done
authorThomas Gleixner <tglx@linutronix.de>
Thu, 2 Oct 2014 15:32:16 +0000 (17:32 +0200)
committerFelipe Balbi <balbi@ti.com>
Thu, 23 Oct 2014 14:55:41 +0000 (09:55 -0500)
commit677e0f1e9fefab84b22ba1530bfd541d9937c5a4
tree724b0e87ad929226f68b52caeea6442c2d657f59
parent2285e6cad1b851dca4d8307cca316bd89cd530b5
usb: musb: cppi41: restart hrtimer only if not yet done

commit 38ec1b517 ("usb: musb: Ensure that cppi41 timer gets armed on
premature DMA TX irq") fixed hrtimer scheduling bug. There is one left
which does not trigger that often.
The following scenario is still possible:

    lock(&x->lock);
    hrtimer_start(&x->t);
    unlock(&x->lock);

expires:
    t->function();
                                lock(&x->lock);
    lock(&x->lock);             if (!hrtimer_queued(&x->t))
                                        hrtimer_start(&x->t);
                                unlock(&x->lock);

    if (!list_empty(x->early_tx_list))
           ret = HRTIMER_RESTART;
->         hrtimer_forward_now(...)
    } else
           ret = HRTIMER_NORESTART;

    unlock(&x->lock);

and the timer callback returns HRTIMER_RESTART for an armed timer. This
is wrong and we run into the BUG_ON() in __run_hrtimer().
This can happens on SMP or PREEMPT-RT.
The patch fixes the problem by only starting the timer if the timer is
not yet queued.

Cc: stable@vger.kernel.org
Reported-by: Torben Hohn <torbenh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bigeasy: collected information and created a patch + description based
          on it]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/musb/musb_cppi41.c