From d6df3576e6b4bcf765f5ace69915b4fa4a7ee1c3 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Tue, 20 Oct 2015 16:02:34 +0800 Subject: clocksource/drivers/arm_global_timer: Prevent ftrace recursion Currently arm_global_timer can be used as a scheduler clock. We properly marked gt_sched_clock_read() as notrace but we then call another function gt_counter_read() that _wasn't_ notrace. Having a traceable function in the sched_clock() path leads to a recursion within ftrace and a kernel crash. Fix this by adding an extra notrace function to keep other users of gt_counter_read() traceable. Signed-off-by: Jisheng Zhang Signed-off-by: Daniel Lezcano --- drivers/clocksource/arm_global_timer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c index 29ea50ac366a..a2cb6fae9295 100644 --- a/drivers/clocksource/arm_global_timer.c +++ b/drivers/clocksource/arm_global_timer.c @@ -60,7 +60,7 @@ static struct clock_event_device __percpu *gt_evt; * different to the 32-bit upper value read previously, go back to step 2. * Otherwise the 64-bit timer counter value is correct. */ -static u64 gt_counter_read(void) +static u64 notrace _gt_counter_read(void) { u64 counter; u32 lower; @@ -79,6 +79,11 @@ static u64 gt_counter_read(void) return counter; } +static u64 gt_counter_read(void) +{ + return _gt_counter_read(); +} + /** * To ensure that updates to comparator value register do not set the * Interrupt Status Register proceed as follows: @@ -201,7 +206,7 @@ static struct clocksource gt_clocksource = { #ifdef CONFIG_CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK static u64 notrace gt_sched_clock_read(void) { - return gt_counter_read(); + return _gt_counter_read(); } #endif -- cgit v1.2.3 From f8af0e9c644caf64d0f42dce816c18346c744a9f Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Tue, 20 Oct 2015 16:02:36 +0800 Subject: clocksource/drivers/pistachio: Prevent ftrace recursion Currently pistachio can be used as a scheduler clock. We properly marked pistachio_read_sched_clock() as notrace but we then call another function pistachio_clocksource_read_cycles() that _wasn't_ notrace. Having a traceable function in the sched_clock() path leads to a recursion within ftrace and a kernel crash. Fix this by adding notrace attribute to the pistachio_clocksource_read_cycles() function. Signed-off-by: Jisheng Zhang Signed-off-by: Daniel Lezcano --- drivers/clocksource/time-pistachio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/clocksource/time-pistachio.c b/drivers/clocksource/time-pistachio.c index 18d4266c2986..bba679900054 100644 --- a/drivers/clocksource/time-pistachio.c +++ b/drivers/clocksource/time-pistachio.c @@ -67,7 +67,8 @@ static inline void gpt_writel(void __iomem *base, u32 value, u32 offset, writel(value, base + 0x20 * gpt_id + offset); } -static cycle_t pistachio_clocksource_read_cycles(struct clocksource *cs) +static cycle_t notrace +pistachio_clocksource_read_cycles(struct clocksource *cs) { struct pistachio_clocksource *pcs = to_pistachio_clocksource(cs); u32 counter, overflw; -- cgit v1.2.3 From b8725dab66f0b2d57affb33a7f6ca094d9f1f8dd Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Tue, 20 Oct 2015 16:02:35 +0800 Subject: clocksource/drivers/samsung_pwm_timer: Prevent ftrace recursion Currently samsung_pwm_timer can be used as a scheduler clock. We properly marked samsung_read_sched_clock() as notrace but we then call another function samsung_clocksource_read() that _wasn't_ notrace. Having a traceable function in the sched_clock() path leads to a recursion within ftrace and a kernel crash. Fix this by adding notrace attribute to the samsung_clocksource_read() function. Signed-off-by: Jisheng Zhang Signed-off-by: Daniel Lezcano --- drivers/clocksource/samsung_pwm_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c index bc90e13338cc..9502bc4c3f6d 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c @@ -307,7 +307,7 @@ static void samsung_clocksource_resume(struct clocksource *cs) samsung_time_start(pwm.source_id, true); } -static cycle_t samsung_clocksource_read(struct clocksource *c) +static cycle_t notrace samsung_clocksource_read(struct clocksource *c) { return ~readl_relaxed(pwm.source_reg); } -- cgit v1.2.3 From cdc68ec01853baf3558c6d25f19c869add4a6888 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Tue, 20 Oct 2015 16:02:37 +0800 Subject: clocksource/drivers/prima2: Prevent ftrace recursion Currently prima2 timer can be used as a scheduler clock. We properly marked sirfsoc_read_sched_clock() as notrace but we then call another function sirfsoc_timer_read() that _wasn't_ notrace. Having a traceable function in the sched_clock() path leads to a recursion within ftrace and a kernel crash. Fix this by adding notrace attribute to the sirfsoc_timer_read() function. Signed-off-by: Jisheng Zhang Signed-off-by: Daniel Lezcano --- drivers/clocksource/timer-prima2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/clocksource/timer-prima2.c b/drivers/clocksource/timer-prima2.c index 78de982cc640..2854c663e8b5 100644 --- a/drivers/clocksource/timer-prima2.c +++ b/drivers/clocksource/timer-prima2.c @@ -73,7 +73,7 @@ static irqreturn_t sirfsoc_timer_interrupt(int irq, void *dev_id) } /* read 64-bit timer counter */ -static cycle_t sirfsoc_timer_read(struct clocksource *cs) +static cycle_t notrace sirfsoc_timer_read(struct clocksource *cs) { u64 cycles; -- cgit v1.2.3 From 36361abc8bc14e80f6b4db561665e5e15249c181 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Tue, 20 Oct 2015 16:02:38 +0800 Subject: clocksource/drivers/vf_pit_timer: Prevent ftrace recursion Having a traceable function in the sched_clock() path leads to a recursion within ftrace and a kernel crash. We should not trace the pit_read_sched_clock() function. Fix this by adding a notrace attribute to this function. Signed-off-by: Jisheng Zhang Signed-off-by: Daniel Lezcano --- drivers/clocksource/vf_pit_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/clocksource/vf_pit_timer.c b/drivers/clocksource/vf_pit_timer.c index f07ba9932171..a0e6c68536a1 100644 --- a/drivers/clocksource/vf_pit_timer.c +++ b/drivers/clocksource/vf_pit_timer.c @@ -52,7 +52,7 @@ static inline void pit_irq_acknowledge(void) __raw_writel(PITTFLG_TIF, clkevt_base + PITTFLG); } -static u64 pit_read_sched_clock(void) +static u64 notrace pit_read_sched_clock(void) { return ~__raw_readl(clksrc_base + PITCVAL); } -- cgit v1.2.3 From bd859a44b2f6749fd82e89dabbaa37f2c8aa33fe Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Tue, 20 Oct 2015 16:02:40 +0800 Subject: clocksource/drivers/fsl_ftm_timer: Prevent ftrace recursion Having a traceable function in the sched_clock() path leads to a recursion within ftrace and a kernel crash. We should not trace the ftm_read_sched_clock() function. Fix this by adding the notrace attribute to this function. Signed-off-by: Jisheng Zhang Signed-off-by: Daniel Lezcano --- drivers/clocksource/fsl_ftm_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/clocksource/fsl_ftm_timer.c b/drivers/clocksource/fsl_ftm_timer.c index ef434699c80a..10202f1fdfd7 100644 --- a/drivers/clocksource/fsl_ftm_timer.c +++ b/drivers/clocksource/fsl_ftm_timer.c @@ -118,7 +118,7 @@ static inline void ftm_reset_counter(void __iomem *base) ftm_writel(0x00, base + FTM_CNT); } -static u64 ftm_read_sched_clock(void) +static u64 notrace ftm_read_sched_clock(void) { return ftm_readl(priv->clksrc_base + FTM_CNT); } -- cgit v1.2.3 From 76b1ba7feda533a74c5874a1d15bb4039083efc8 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Tue, 20 Oct 2015 16:02:39 +0800 Subject: clocksource/drivers/digicolor: Prevent ftrace recursion Having a traceable function in the sched_clock() path leads to a recursion within ftrace and a kernel crash. We should not trace digicolor_timer_sched_read() function. Fix this by adding the notrace attribute to this function. Signed-off-by: Jisheng Zhang Acked-by: Baruch Siach Signed-off-by: Daniel Lezcano --- drivers/clocksource/timer-digicolor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/clocksource/timer-digicolor.c b/drivers/clocksource/timer-digicolor.c index e73947f0f86d..a536eeb634d8 100644 --- a/drivers/clocksource/timer-digicolor.c +++ b/drivers/clocksource/timer-digicolor.c @@ -143,7 +143,7 @@ static irqreturn_t digicolor_timer_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static u64 digicolor_timer_sched_read(void) +static u64 notrace digicolor_timer_sched_read(void) { return ~readl(dc_timer_dev.base + COUNT(TIMER_B)); } -- cgit v1.2.3 From fe326c5cc07cd265abad29c35c142cfae09889e4 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 28 Oct 2015 10:43:23 +0900 Subject: clocksource/drivers/sh_mtu2: Fix multiple shutdown call issue On the r7s72100 Genmai board the MTU2 driver currently triggers a common clock framework WARN_ON(enable_count) when disabling the clock due to the MTU2 driver after recent callback rework may call ->set_state_shutdown() multiple times. A similar issue was spotted for the TMU driver and fixed in: 452b132 clocksource/drivers/sh_tmu: Fix traceback spotted in -next On r7s72100 Genmai v4.3-rc7 built with shmobile_defconfig spits out the following during boot: sh_mtu2 fcff0000.timer: ch0: used for clock events ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:675 clk_core_disable+0x2c/0x6c() CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.3.0-rc7 #1 Hardware name: Generic R7S72100 (Flattened Device Tree) Backtrace: [] (dump_backtrace) from [] (show_stack+0x18/0x1c) [] (show_stack) from [] (dump_stack+0x74/0x90) [] (dump_stack) from [] (warn_slowpath_common+0x88/0xb4) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x24/0x2c) [] (warn_slowpath_null) from [] (clk_core_disable+0x2c/0x6c) [] (clk_core_disable) from [] (clk_disable+0x40/0x4c) [] (clk_disable) from [] (sh_mtu2_disable+0x24/0x50) [] (sh_mtu2_disable) from [] (sh_mtu2_clock_event_shutdown+0x14/0x1c) [] (sh_mtu2_clock_event_shutdown) from [] (clockevents_switch_state+0xc8/0x114) [] (clockevents_switch_state) from [] (clockevents_shutdown+0x18/0x28) [] (clockevents_shutdown) from [] (clockevents_exchange_device+0x70/0x78) [] (clockevents_exchange_device) from [] (tick_check_new_device+0x88/0xe0) [] (tick_check_new_device) from [] (clockevents_register_device+0xac/0x120) [] (clockevents_register_device) from [] (sh_mtu2_probe+0x230/0x350) [] (sh_mtu2_probe) from [] (platform_drv_probe+0x50/0x98) Reported-by: Chris Brandt Fixes: 19a9ffb ("clockevents/drivers/sh_mtu2: Migrate to new 'set-state' interface") Cc: Viresh Kumar Cc: Laurent Pinchart Signed-off-by: Magnus Damm Signed-off-by: Daniel Lezcano Reviewed-by: Viresh Kumar --- drivers/clocksource/sh_mtu2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index f1985da8113f..53aa7e92a7d7 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -280,7 +280,9 @@ static int sh_mtu2_clock_event_shutdown(struct clock_event_device *ced) { struct sh_mtu2_channel *ch = ced_to_sh_mtu2(ced); - sh_mtu2_disable(ch); + if (clockevent_state_periodic(ced)) + sh_mtu2_disable(ch); + return 0; } -- cgit v1.2.3