From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Stefan Roese <sr@denx.de>
Cc: linuxppc-dev@ozlabs.org, Anton Blanchard <anton@samba.org>,
Detlev Zundel <dzu@denx.de>
Subject: Re: [PATCH/RFC] powerpc: Fix decrementer setup on 1GHz boards
Date: Fri, 09 Oct 2009 07:12:56 +1100 [thread overview]
Message-ID: <1255032776.2146.7.camel@pasglop> (raw)
In-Reply-To: <1255013362-27135-1-git-send-email-sr@denx.de>
On Thu, 2009-10-08 at 16:49 +0200, Stefan Roese wrote:
> We noticed that recent kernels didn't boot on our 1GHz Canyonlands 460EX
> boards anymore. As it seems, patch 8d165db1 [powerpc: Improve
> decrementer accuracy] introduced this problem. The routine div_sc()
> overflows with shift = 32 resulting in this incorrect setup:
>
> time_init: decrementer frequency = 1000.000012 MHz
> time_init: processor frequency = 1000.000012 MHz
> clocksource: timebase mult[400000] shift[22] registered
> clockevent: decrementer mult[33] shift[32] cpu[0]
>
> This patch now introduces a local div_dc64() version of this function
> so that this overflow doesn't happen anymore.
Ugh ? We never expected that the decrementer would be ticking that fast.
This is too fast actually. Somebody at AMCC must be told to stick a
divider in front of the timebase when reaching such frequencies.
Ben.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Anton Blanchard <anton@samba.org>
> Cc: Detlev Zundel <dzu@denx.de>
> ---
> Ben, Anton, how should we handle this? Is this patch acceptable? Or how
> should this be solved?
>
> arch/powerpc/kernel/time.c | 11 ++++++++++-
> 1 files changed, 10 insertions(+), 1 deletions(-)
>
> diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
> index 92dc844..3ad729f 100644
> --- a/arch/powerpc/kernel/time.c
> +++ b/arch/powerpc/kernel/time.c
> @@ -882,12 +882,21 @@ static void decrementer_set_mode(enum clock_event_mode mode,
> decrementer_set_next_event(DECREMENTER_MAX, dev);
> }
>
> +static inline uint64_t div_sc64(unsigned long ticks, unsigned long nsec,
> + int shift)
> +{
> + uint64_t tmp = ((uint64_t)ticks) << shift;
> +
> + do_div(tmp, nsec);
> + return tmp;
> +}
> +
> static void __init setup_clockevent_multiplier(unsigned long hz)
> {
> u64 mult, shift = 32;
>
> while (1) {
> - mult = div_sc(hz, NSEC_PER_SEC, shift);
> + mult = div_sc64(hz, NSEC_PER_SEC, shift);
> if (mult && (mult >> 32UL) == 0UL)
> break;
>
next prev parent reply other threads:[~2009-10-08 20:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-08 14:49 [PATCH/RFC] powerpc: Fix decrementer setup on 1GHz boards Stefan Roese
2009-10-08 20:12 ` Benjamin Herrenschmidt [this message]
2009-10-09 5:28 ` Stefan Roese
2009-10-09 6:27 ` Benjamin Herrenschmidt
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=1255032776.2146.7.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=anton@samba.org \
--cc=dzu@denx.de \
--cc=linuxppc-dev@ozlabs.org \
--cc=sr@denx.de \
/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).