clockevents/clocksource fixes for 4.8-rc3
Subsystems (4)
Hi Thomas, Ingo,
this is the second round of fixes for 4.8-rc3.
- Add the mck clock enablement for the ETM/ETB driver (Alexandre Belloni)
- Clear the interrupts after stopping the timer in order to prevent
spurious interrupt at init time (Chen-Yu Tsai)
- Fix a memory corruption on pistachio by replacing a reference to
pointer by the pointer itself (Marcin Nowakowski)
Thanks !
-- Daniel
The following changes since commit aa8c0f1ad7e862147f4efb32bbb71ff66eb38caa:
clocksource/drivers/pxa: Fix include files for compilation (2016-08-24
11:16:38 +0200)
are available in the git repository at:
http://git.linaro.org/people/daniel.lezcano/linux.git
clockevents/4.8-fixes
for you to fetch changes up to b53e7d000d9e6e9fd2c6eb6b82d2783c67fd599e:
clocksource/drivers/sun4i: Clear interrupts after stopping timer in
probe function (2016-08-26 15:56:01 +0200)
----------------------------------------------------------------
Alexandre Belloni (1):
clocksource/drivers/timer-atmel-pit: Enable mck clock
Chen-Yu Tsai (1):
clocksource/drivers/sun4i: Clear interrupts after stopping timer
in probe function
Marcin Nowakowski (1):
drivers/clocksource/pistachio: Fix memory corruption in init
drivers/clocksource/sun4i_timer.c | 9 ++++++++- drivers/clocksource/time-pistachio.c | 8 ++++---- drivers/clocksource/timer-atmel-pit.c | 6 ++++++ 3 files changed, 18 insertions(+), 5 deletions(-)
Signature · 5 lines
<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
PATCH 1/3 clocksource/drivers/timer-atmel-pit: Enable mck clock
From: Alexandre Belloni <[email protected]>
mck is needed to get the PIT working. Explicitly prepare_enable it instead of assuming it is enabled.
This solves an issue where the system is freezing when the ETM/ETB drivers are enabled.
--- drivers/clocksource/timer-atmel-pit.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/clocksource/timer-atmel-pit.c +6 -0
@@ -261,6 +261,12 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)return PTR_ERR (data->mck); } + ret =clk_prepare_enable (data->mck); +if (ret) { +pr_err ("Unable to enable mck\n" ); +return ret; + } +/* Get the interrupts property */ data->irq =irq_of_parse_and_map (node,0 );if (!data->irq) {
Signature · 1 line
1.9.1
PATCH 2/3 drivers/clocksource/pistachio: Fix memory corruption in init
From: Marcin Nowakowski <[email protected]>
Driver init code incorrectly uses the block base address and as a result clears clocksource structure's fields instead of the hardware registers.
Commit 09a998201649 ("timekeeping: Lift clocksource cacheline restriction") has changed the offsets within pistachio_clocksource structure and what has previously gone unnoticed now leads to a kernel panic during boot.
--- drivers/clocksource/time-pistachio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clocksource/time-pistachio.c +4 -4
@@ -202,10 +202,10 @@ static int __init pistachio_clksrc_of_init(struct device_node *node) rate =clk_get_rate (fast_clk);/* Disable irq's for clocksource usage */ -gpt_writel (&pcs_gpt.base,0 ,TIMER_IRQ_MASK ,0 ); -gpt_writel (&pcs_gpt.base,0 ,TIMER_IRQ_MASK ,1 ); -gpt_writel (&pcs_gpt.base,0 ,TIMER_IRQ_MASK ,2 ); -gpt_writel (&pcs_gpt.base,0 ,TIMER_IRQ_MASK ,3 ); +gpt_writel (pcs_gpt.base,0 ,TIMER_IRQ_MASK ,0 ); +gpt_writel (pcs_gpt.base,0 ,TIMER_IRQ_MASK ,1 ); +gpt_writel (pcs_gpt.base,0 ,TIMER_IRQ_MASK ,2 ); +gpt_writel (pcs_gpt.base,0 ,TIMER_IRQ_MASK ,3 );/* Enable timer block */ writel (TIMER_ME_GLOBAL , pcs_gpt.base);
Signature · 1 line
1.9.1
PATCH 3/3 clocksource/drivers/sun4i: Clear interrupts after stopping timer in probe function
In reply to Daniel LezcanoFrom: Chen-Yu Tsai <[email protected]>
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.
--- drivers/clocksource/sun4i_timer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clocksource/sun4i_timer.c +8 -1
@@ -123,12 +123,16 @@ static struct clock_event_device sun4i_clockevent = { .set_next_event = sun4i_clkevt_next_event, }; +static void sun4i_timer_clear_interrupt (void ) +{ +writel (TIMER_IRQ_EN (0 ), timer_base +TIMER_IRQ_ST_REG ); +}static irqreturn_t sun4i_timer_interrupt (int irq,void *dev_id) {struct clock_event_device *evt = (struct clock_event_device *)dev_id; -writel (0x1 , timer_base +TIMER_IRQ_ST_REG ); +sun4i_timer_clear_interrupt (); evt->event_handler (evt);return IRQ_HANDLED ;
@@ -208,6 +212,9 @@ static int __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 */ +sun4i_timer_clear_interrupt (); + sun4i_clockevent.cpumask = cpu_possible_mask; sun4i_clockevent.irq = irq;
Signature · 1 line
1.9.1
Re: [PATCH 1/3] clocksource/drivers/timer-atmel-pit: Enable mck clock
In reply to Daniel LezcanoHi,
Quoted 22 lines · Daniel Lezcano
From: Alexandre Belloni <[email protected]>
mck is needed to get the PIT working. Explicitly
prepare_enableit instead of assuming it is enabled.This solves an issue where the system is freezing when the ETM/ETB drivers are enabled.
Reported-by Olivier Schonken <[email protected]>Reviewed-by Boris Brezillon <[email protected]>Acked-by Nicolas Ferre <[email protected]>Signed-off-by Alexandre Belloni <[email protected]>Signed-off-by Daniel Lezcano <[email protected]>--- drivers/clocksource/timer-atmel-pit.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/clocksource/timer-atmel-pit.c +0
-0
drivers/clocksource/timer-atmel-pit.c static int __init at91sam926x_pit_dt_init(struct device_node *node) · line 269
Quoted 9 lines
drivers/clocksource/timer-atmel-pit.c +6
-0@@ -261,6 +261,12 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)return PTR_ERR (data->mck); } + ret =clk_prepare_enable (data->mck); +if (ret) { +pr_err ("Unable to enable mck\n" ); +return ret; + } +
Apologies if the below is a duplicate report.
When building v4.8-rc4 multi_v7_defconfig, I get:
[mark at leverpostej:~/src/linux]% uselinaro 15.08 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j10 -s drivers/clocksource/timer-atmel-pit.c: In function 'at91sam926x_pit_dt_init':drivers/clocksource/timer-atmel-pit.c:264:2: error: 'ret' undeclared (first use in this function)
ret = clk_prepare_enable(data->mck);
^drivers/clocksource/timer-atmel-pit.c:264:2: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [drivers/clocksource/timer-atmel-pit.o] Error 1
make[1]: *** [drivers/clocksource] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [drivers] Error 2
As far as I can see, there's no local 'ret' variable. Locally I've fixed this up with:
----8----
drivers/clocksource/timer-atmel-pit.c +1 -0
@@ -240,6 +240,7 @@ static int __init at91sam926x_pit_common_init(struct pit_data *data)static int __init at91sam926x_pit_dt_init (struct device_node *node) {struct pit_data *data; +int ret; data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)
---->8----
Thanks,
Mark.
Re: [PATCH 1/3] clocksource/drivers/timer-atmel-pit: Enable mck clock
Quoted 17 lines · Mark Rutland
Hi,
Quoted 14 lines · Daniel Lezcano
From: Alexandre Belloni <[email protected]>
mck is needed to get the PIT working. Explicitly
prepare_enableit instead of assuming it is enabled.This solves an issue where the system is freezing when the ETM/ETB drivers are enabled.
Reported-by Olivier Schonken <[email protected]>Reviewed-by Boris Brezillon <[email protected]>Acked-by Nicolas Ferre <[email protected]>Signed-off-by Alexandre Belloni <[email protected]>Signed-off-by Daniel Lezcano <[email protected]>---
Hi Mark,
It is fixed.
Thanks for reporting the issue and for the fix.
-- Daniel
Signature · 5 lines
<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