From: Magnus Damm Date: Wed, 28 Oct 2015 01:43:23 +0000 (+0900) Subject: clocksource/drivers/sh_mtu2: Fix multiple shutdown call issue X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fe326c5cc07cd265abad29c35c142cfae09889e4;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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; }