* [PATCH] clocksource: sun4i: Clear interrupts after stopping timer in probe function
@ 2016-07-26 3:01 Chen-Yu Tsai
2016-07-26 5:49 ` Maxime Ripard
0 siblings, 1 reply; 4+ messages in thread
From: Chen-Yu Tsai @ 2016-07-26 3:01 UTC (permalink / raw)
To: linux-arm-kernel
The bootloader (U-boot) sometimes uses this timer for various delays.
It uses it as a ongoing counter, and does comparisons on the current
counter value. The timer counter is never stopped.
In some cases when the user interacts with the bootloader, or lets
it idle for some time before loading Linux, the timer may expire,
and an interrupt will be pending. This results in an unexpected
interrupt when the timer interrupt is enabled by the kernel, at
which point the event_handler isn't set yet. This results in a NULL
pointer dereference exception, panic, and no way to reboot.
Clear any pending interrupts after we stop the timer in the probe
function to avoid this.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
I've run into this many times while working on U-boot. Finally
made time to figure it out.
---
drivers/clocksource/sun4i_timer.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c
index 6f3719d73390..d5725c82401d 100644
--- a/drivers/clocksource/sun4i_timer.c
+++ b/drivers/clocksource/sun4i_timer.c
@@ -193,6 +193,9 @@ static void __init sun4i_timer_init(struct device_node *node)
/* Make sure timer is stopped before playing with interrupts */
sun4i_clkevt_time_stop(0);
+ /* clear timer0 interrupt */
+ writel(0x1, timer_base + TIMER_IRQ_ST_REG);
+
sun4i_clockevent.cpumask = cpu_possible_mask;
sun4i_clockevent.irq = irq;
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] clocksource: sun4i: Clear interrupts after stopping timer in probe function
2016-07-26 3:01 [PATCH] clocksource: sun4i: Clear interrupts after stopping timer in probe function Chen-Yu Tsai
@ 2016-07-26 5:49 ` Maxime Ripard
2016-07-26 6:42 ` Chen-Yu Tsai
0 siblings, 1 reply; 4+ messages in thread
From: Maxime Ripard @ 2016-07-26 5:49 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jul 26, 2016 at 11:01:59AM +0800, Chen-Yu Tsai wrote:
> The bootloader (U-boot) sometimes uses this timer for various delays.
> It uses it as a ongoing counter, and does comparisons on the current
> counter value. The timer counter is never stopped.
>
> In some cases when the user interacts with the bootloader, or lets
> it idle for some time before loading Linux, the timer may expire,
> and an interrupt will be pending. This results in an unexpected
> interrupt when the timer interrupt is enabled by the kernel, at
> which point the event_handler isn't set yet. This results in a NULL
> pointer dereference exception, panic, and no way to reboot.
>
> Clear any pending interrupts after we stop the timer in the probe
> function to avoid this.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Awesome, thanks!
You should put stable in Cc though for this kind of patches.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160726/2725019d/attachment.sig>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] clocksource: sun4i: Clear interrupts after stopping timer in probe function
2016-07-26 5:49 ` Maxime Ripard
@ 2016-07-26 6:42 ` Chen-Yu Tsai
2016-07-26 9:07 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Chen-Yu Tsai @ 2016-07-26 6:42 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jul 26, 2016 at 1:49 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Tue, Jul 26, 2016 at 11:01:59AM +0800, Chen-Yu Tsai wrote:
>> The bootloader (U-boot) sometimes uses this timer for various delays.
>> It uses it as a ongoing counter, and does comparisons on the current
>> counter value. The timer counter is never stopped.
>>
>> In some cases when the user interacts with the bootloader, or lets
>> it idle for some time before loading Linux, the timer may expire,
>> and an interrupt will be pending. This results in an unexpected
>> interrupt when the timer interrupt is enabled by the kernel, at
>> which point the event_handler isn't set yet. This results in a NULL
>> pointer dereference exception, panic, and no way to reboot.
>>
>> Clear any pending interrupts after we stop the timer in the probe
>> function to avoid this.
>>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>
> Awesome, thanks!
>
> You should put stable in Cc though for this kind of patches.
AFAIK some maintainers prefer to add it themselves. Not sure about
clocksource so I left it out.
ChenYu
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] clocksource: sun4i: Clear interrupts after stopping timer in probe function
2016-07-26 6:42 ` Chen-Yu Tsai
@ 2016-07-26 9:07 ` Thomas Gleixner
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2016-07-26 9:07 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, 26 Jul 2016, Chen-Yu Tsai wrote:
> On Tue, Jul 26, 2016 at 1:49 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > On Tue, Jul 26, 2016 at 11:01:59AM +0800, Chen-Yu Tsai wrote:
> >> The bootloader (U-boot) sometimes uses this timer for various delays.
> >> It uses it as a ongoing counter, and does comparisons on the current
> >> counter value. The timer counter is never stopped.
> >>
> >> In some cases when the user interacts with the bootloader, or lets
> >> it idle for some time before loading Linux, the timer may expire,
> >> and an interrupt will be pending. This results in an unexpected
> >> interrupt when the timer interrupt is enabled by the kernel, at
> >> which point the event_handler isn't set yet. This results in a NULL
> >> pointer dereference exception, panic, and no way to reboot.
> >>
> >> Clear any pending interrupts after we stop the timer in the probe
> >> function to avoid this.
> >>
> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> >
> > Awesome, thanks!
> >
> > You should put stable in Cc though for this kind of patches.
>
> AFAIK some maintainers prefer to add it themselves. Not sure about
> clocksource so I left it out.
At least you should tell the maintainer, that you consider this to be stable
material. It's not an obvious stable candidate.
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-26 9:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-26 3:01 [PATCH] clocksource: sun4i: Clear interrupts after stopping timer in probe function Chen-Yu Tsai
2016-07-26 5:49 ` Maxime Ripard
2016-07-26 6:42 ` Chen-Yu Tsai
2016-07-26 9:07 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox