diff mbox

[V2] clockevents/drivers/mtk: Fix spurious interrupt leading to crash

Message ID 1440453450-21203-1-git-send-email-daniel.lezcano@linaro.org
State Superseded
Headers show

Commit Message

Daniel Lezcano Aug. 24, 2015, 9:57 p.m. UTC
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>
---
 drivers/clocksource/mtk_timer.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Comments

Daniel Lezcano Aug. 26, 2015, 2:25 p.m. UTC | #1
On 08/25/2015 03:21 PM, Yingjoe Chen wrote:
> Tested-by: Yingjoe Chen<yingjoe.chen@mediatek.com>

Applied to my tree for 4.4.

   -- Daniel
Yingjoe Chen Sept. 4, 2015, 7:15 a.m. UTC | #2
On Wed, 2015-08-26 at 16:25 +0200, Daniel Lezcano wrote:
> On 08/25/2015 03:21 PM, Yingjoe Chen wrote:
> > Tested-by: Yingjoe Chen<yingjoe.chen@mediatek.com>
> 
> Applied to my tree for 4.4.
> 
>    -- Daniel
> 

Hi Daniel,

I can't find this patch in
https://git.linaro.org/people/daniel.lezcano/linux.git
Is this tree public now? Where can I see it?

Also, will you take patch[1] "clocksource: mediatek: Use GPT as sched
clock source" in your tree?

Joe.C

[1]:
http://lists.infradead.org/pipermail/linux-mediatek/2015-July/001547.html


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Daniel Lezcano Sept. 4, 2015, 7:36 a.m. UTC | #3
On 09/04/2015 09:15 AM, Yingjoe Chen wrote:
> On Wed, 2015-08-26 at 16:25 +0200, Daniel Lezcano wrote:
>> On 08/25/2015 03:21 PM, Yingjoe Chen wrote:
>>> Tested-by: Yingjoe Chen<yingjoe.chen@mediatek.com>
>>
>> Applied to my tree for 4.4.
>>
>>     -- Daniel
>>
>
> Hi Daniel,
>
> I can't find this patch in
> https://git.linaro.org/people/daniel.lezcano/linux.git
> Is this tree public now? Where can I see it?
>
> Also, will you take patch[1] "clocksource: mediatek: Use GPT as sched
> clock source" in your tree?

Yep. I did not push my branch. Done.

Note it will be also available for linux-next.

Thanks for the head up.

   -- Daniel
Daniel Lezcano Oct. 27, 2015, 11:23 a.m. UTC | #4
On 10/27/2015 12:11 PM, Matthias Brugger wrote:
> Hi Daniel,

>

> On 26/08/15 16:25, Daniel Lezcano wrote:

>> On 08/25/2015 03:21 PM, Yingjoe Chen wrote:

>>> Tested-by: Yingjoe Chen<yingjoe.chen@mediatek.com>

>>

>> Applied to my tree for 4.4.

>>

>>    -- Daniel

>>

>

> Kevin found a regression in v4.3 which will need this patch to fix it

> [1]. Can you apply it to your clockevents/4.3-fixes branch please.

>

> Thanks,

> Matthias

>

> [1] https://lkml.org/lkml/2015/10/26/211


Hmm, I thought it wasn't impacting 4.3, so it went to 4.4.

Let me look how to backport this fix without introducing a conflict when 
tip/timers/urgent will be merged to tip/timers/core.

-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Daniel Lezcano Oct. 27, 2015, 11:47 a.m. UTC | #5
On 10/27/2015 12:23 PM, Daniel Lezcano wrote:
> On 10/27/2015 12:11 PM, Matthias Brugger wrote:

>> Hi Daniel,

>>

>> On 26/08/15 16:25, Daniel Lezcano wrote:

>>> On 08/25/2015 03:21 PM, Yingjoe Chen wrote:

>>>> Tested-by: Yingjoe Chen<yingjoe.chen@mediatek.com>

>>>

>>> Applied to my tree for 4.4.

>>>

>>>    -- Daniel

>>>

>>

>> Kevin found a regression in v4.3 which will need this patch to fix it

>> [1]. Can you apply it to your clockevents/4.3-fixes branch please.

>>

>> Thanks,

>> Matthias

>>

>> [1] https://lkml.org/lkml/2015/10/26/211

>

> Hmm, I thought it wasn't impacting 4.3, so it went to 4.4.

>

> Let me look how to backport this fix without introducing a conflict when

> tip/timers/urgent will be merged to tip/timers/core.


Thomas,

do you think I can cherry-pick from tip/timers/core or clockevents/4.4 
directly the fix to be pulled into clockevents/4.3-fixes ? That will 
certainly raise a conflict when tip/timers/urgent will be merged to 
tip/timers/core (a trivial conflict actually).

   -- Daniel


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
index 4cd16fb..505f53d 100644
--- a/drivers/clocksource/mtk_timer.c
+++ b/drivers/clocksource/mtk_timer.c
@@ -156,14 +156,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)
 {
@@ -183,6 +175,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);
@@ -232,8 +230,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);