]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
clockevents/drivers/mtk: Fix spurious interrupt leading to crash
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 24 Aug 2015 13:14:30 +0000 (15:14 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Thu, 15 Oct 2015 15:41:56 +0000 (17:41 +0200)
After analysis done by Yingjoe Chen, the timer appears to have a pending
interrupt when it is enabled.

Fix this by acknowledging the pending interrupt when enabling the timer
interrupt.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
drivers/clocksource/mtk_timer.c

index 50f0641c65b6f30cd890240aca4f6febd5f4a6e8..c8badc427eec29e49bf29fd4fd62b7a1b179b3a0 100644 (file)
@@ -141,14 +141,6 @@ static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static void mtk_timer_global_reset(struct mtk_clock_event_device *evt)
-{
-       /* Disable all interrupts */
-       writel(0x0, evt->gpt_base + GPT_IRQ_EN_REG);
-       /* Acknowledge all interrupts */
-       writel(0x3f, evt->gpt_base + GPT_IRQ_ACK_REG);
-}
-
 static void
 mtk_timer_setup(struct mtk_clock_event_device *evt, u8 timer, u8 option)
 {
@@ -168,6 +160,12 @@ static void mtk_timer_enable_irq(struct mtk_clock_event_device *evt, u8 timer)
 {
        u32 val;
 
+       /* Disable all interrupts */
+       writel(0x0, evt->gpt_base + GPT_IRQ_EN_REG);
+
+       /* Acknowledge all spurious pending interrupts */
+       writel(0x3f, evt->gpt_base + GPT_IRQ_ACK_REG);
+
        val = readl(evt->gpt_base + GPT_IRQ_EN_REG);
        writel(val | GPT_IRQ_ENABLE(timer),
                        evt->gpt_base + GPT_IRQ_EN_REG);
@@ -220,8 +218,6 @@ static void __init mtk_timer_init(struct device_node *node)
        }
        rate = clk_get_rate(clk);
 
-       mtk_timer_global_reset(evt);
-
        if (request_irq(evt->dev.irq, mtk_timer_interrupt,
                        IRQF_TIMER | IRQF_IRQPOLL, "mtk_timer", evt)) {
                pr_warn("failed to setup irq %d\n", evt->dev.irq);