linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Shawn Guo <shawn.guo@linaro.org>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Andres Salomon <dilinger@queued.net>,
	arm@kernel.org, John Stultz <john.stultz@linaro.org>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>
Subject: BUG: Re: [PATCH v2 3/3] clocksource: use clockevents_config_and_register() where possible
Date: Tue, 23 Apr 2013 15:07:55 +0200	[thread overview]
Message-ID: <517687AB.1040309@pengutronix.de> (raw)
In-Reply-To: <1357991406-22778-4-git-send-email-shawn.guo@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 2538 bytes --]

Hello,

On 01/12/2013 12:50 PM, Shawn Guo wrote:
> The clockevent core is able to figure out the best mult and shift,
> calculate min_delta_ns and max_delta_ns, with the necessary info passed
> into clockevents_config_and_register().  Use this combined configure
> and register function where possible to make the codes less error prone
> and gain some positive diff stat.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> Cc: Andres Salomon <dilinger@queued.net>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

[...]

I just bisected a timer problem down to this commit.

> diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
> index 32cb929..8a61872 100644
> --- a/drivers/clocksource/tcb_clksrc.c
> +++ b/drivers/clocksource/tcb_clksrc.c
> @@ -157,7 +157,6 @@ static struct tc_clkevt_device clkevt = {
>  		.name		= "tc_clkevt",
>  		.features	= CLOCK_EVT_FEAT_PERIODIC
>  					| CLOCK_EVT_FEAT_ONESHOT,
> -		.shift		= 32,
>  		/* Should be lower than at91rm9200's system timer */
>  		.rating		= 125,
>  		.set_next_event	= tc_next_event,
> @@ -196,13 +195,9 @@ static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
>  
>  	timer_clock = clk32k_divisor_idx;
>  
> -	clkevt.clkevt.mult = div_sc(32768, NSEC_PER_SEC, clkevt.clkevt.shift);
> -	clkevt.clkevt.max_delta_ns
> -		= clockevent_delta2ns(0xffff, &clkevt.clkevt);
> -	clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
                                                                           ^^^^^^

With this patch, the "+ 1" gets lost, resulting in a different
"min_delta_ns".

good:
setup_clkevents: shift=32 mult=140737 min=30518 max=1999976422

bad:
setup_clkevents: shift=32 mult=140737 min=30517 max=1999976422

This leads to problems with schedule_delayed_work() with a delay of
"1". These worksqueues seem to be hanging for several seconds. I'll
send a RFC patch.

>  	clkevt.clkevt.cpumask = cpumask_of(0);
>  
> -	clockevents_register_device(&clkevt.clkevt);
> +	clockevents_config_and_register(&clkevt.clkevt, 32768, 1, 0xffff);
>  
>  	setup_irq(irq, &tc_irqaction);
>  }
> 

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  reply	other threads:[~2013-04-23 13:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-12 11:50 [PATCH v2 0/3] Use helper clockevents_config_and_register() Shawn Guo
2013-01-12 11:50 ` [PATCH v2 1/3] clockevents: export clockevents_config_and_register for module use Shawn Guo
2013-01-12 11:50 ` [PATCH v2 2/3] ARM: use clockevents_config_and_register() where possible Shawn Guo
2013-01-12 21:25   ` Jason Cooper
2013-01-12 11:50 ` [PATCH v2 3/3] clocksource: " Shawn Guo
2013-04-23 13:07   ` Marc Kleine-Budde [this message]
2013-04-23 13:08     ` RFC: [PATCH] clocksource: tcb: fix min_delta calculation Marc Kleine-Budde
2013-04-23 13:11       ` Marc Kleine-Budde
2013-04-23 13:44         ` Shawn Guo
2013-04-23 13:50           ` Marc Kleine-Budde
2013-04-25 13:36       ` Marc Kleine-Budde
2013-04-25 14:18         ` Thomas Gleixner
2013-04-25 14:21       ` Thomas Gleixner
2013-04-25 14:53         ` Marc Kleine-Budde
2013-06-20 15:00           ` Marc Kleine-Budde
2013-09-09  8:18             ` Ronald Wahl
2013-09-09 13:56               ` Marc Kleine-Budde
2013-01-12 21:14 ` [PATCH v2 0/3] Use helper clockevents_config_and_register() Arnd Bergmann
2013-01-14 11:23   ` Thomas Gleixner
2013-01-14 18:16     ` Olof Johansson

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=517687AB.1040309@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=arm@kernel.org \
    --cc=dilinger@queued.net \
    --cc=john.stultz@linaro.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=shawn.guo@linaro.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).