• Alexandre Belloni's avatar
    clockevents/tcb_clksrc: Prevent disabling an already disabled clock · f02b4b72
    Alexandre Belloni authored
    clockevents_exchange_device is calling clockevents_shutdown() on the new
    clockenvents device but it may have never been enabled in the first place.
    This results in the tcb clock being disabled without being enabled first:
    
    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:680 clk_disable+0x28/0x34()
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper Not tainted 4.4.0+ #6
    Hardware name: Atmel AT91SAM9
    [<c000f2b8>] (unwind_backtrace) from [<c000d01c>] (show_stack+0x10/0x14)
    [<c000d01c>] (show_stack) from [<c00172f0>] (warn_slowpath_common+0x78/0xa0)
    [<c00172f0>] (warn_slowpath_common) from [<c00173a8>] (warn_slowpath_null+0x18/0x20)
    [<c00173a8>] (warn_slowpath_null) from [<c0361528>] (clk_disable+0x28/0x34)
    [<c0361528>] (clk_disable) from [<c034d560>] (tc_shutdown+0x38/0x4c)
    [<c034d560>] (tc_shutdown) from [<c0059ad4>] (clockevents_switch_state+0x38/0x6c)
    [<c0059ad4>] (clockevents_switch_state) from [<c0059b18>] (clockevents_shutdown+0x10/0x24)
    [<c0059b18>] (clockevents_shutdown) from [<c005a458>] (tick_check_new_device+0x84/0xac)
    [<c005a458>] (tick_check_new_device) from [<c0059660>] (clockevents_register_device+0x7c/0x108)
    [<c0059660>] (clockevents_register_device) from [<c06b5a68>] (tcb_clksrc_init+0x390/0x3e8)
    [<c06b5a68>] (tcb_clksrc_init) from [<c00097cc>] (do_one_initcall+0x114/0x1d4)
    [<c00097cc>] (do_one_initcall) from [<c069bd54>] (kernel_init_freeable+0xfc/0x1b8)
    [<c069bd54>] (kernel_init_freeable) from [<c04c3818>] (kernel_init+0x8/0xe0)
    [<c04c3818>] (kernel_init) from [<c000a410>] (ret_from_fork+0x14/0x24)
    ---[ end trace 0000000000000001 ]---
    
    Check what state we were in before trying to disable the clock.
    
    Fixes: cf4541c1 ("clockevents/drivers/tcb_clksrc: Migrate to new 'set-state' interface")
    Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
    Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
    Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
    Cc: stable@vger.kernel.org
    Link: http://lkml.kernel.org/r/1452854061-30370-1-git-send-email-alexandre.belloni@free-electrons.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    f02b4b72
tcb_clksrc.c 10.3 KB