linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: nicolas.ferre@atmel.com (Nicolas Ferre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clockevents: tcb_clksrc: stop disabling an already disabled clock
Date: Fri, 15 Jan 2016 11:54:20 +0100	[thread overview]
Message-ID: <5698CFDC.2090304@atmel.com> (raw)
In-Reply-To: <1452854061-30370-1-git-send-email-alexandre.belloni@free-electrons.com>

Le 15/01/2016 11:34, Alexandre Belloni a ?crit :
> 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: cf4541c101ea ("clockevents/drivers/tcb_clksrc: Migrate to new 'set-state' interface")
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Thanks!

> ---
>  drivers/clocksource/tcb_clksrc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
> index 6ee91401918e..4da2af9694a2 100644
> --- a/drivers/clocksource/tcb_clksrc.c
> +++ b/drivers/clocksource/tcb_clksrc.c
> @@ -98,7 +98,8 @@ static int tc_shutdown(struct clock_event_device *d)
>  
>  	__raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
>  	__raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
> -	clk_disable(tcd->clk);
> +	if (!clockevent_state_detached(d))
> +		clk_disable(tcd->clk);
>  
>  	return 0;
>  }
> 


-- 
Nicolas Ferre

      reply	other threads:[~2016-01-15 10:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-15 10:34 [PATCH] clockevents: tcb_clksrc: stop disabling an already disabled clock Alexandre Belloni
2016-01-15 10:54 ` Nicolas Ferre [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5698CFDC.2090304@atmel.com \
    --to=nicolas.ferre@atmel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).