From: "Li.Xiubo@freescale.com" <Li.Xiubo@freescale.com>
To: Stephen Boyd <sboyd@codeaurora.org>
Cc: Marc Zyngier <Marc.Zyngier@arm.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: RE: [PATCH] clocksource: arch_arm_timer: Fix timecounter initialization
Date: Thu, 12 Jun 2014 07:45:36 +0000 [thread overview]
Message-ID: <bce193f3fc264abf82ff52ef69f0b86a@BY2PR03MB505.namprd03.prod.outlook.com> (raw)
In-Reply-To: <5398A7B2.6030807@codeaurora.org>
> > drivers/clocksource/arm_arch_timer.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/clocksource/arm_arch_timer.c
> b/drivers/clocksource/arm_arch_timer.c
> > index 5163ec1..6c3cfd8 100644
> > --- a/drivers/clocksource/arm_arch_timer.c
> > +++ b/drivers/clocksource/arm_arch_timer.c
> > @@ -426,7 +426,7 @@ struct timecounter *arch_timer_get_timecounter(void)
> >
> > static void __init arch_counter_register(unsigned type)
> > {
> > - u64 start_count;
> > + u64 start_count, start_ns;
> >
> > /* Register the CP15 based counter if we have one */
> > if (type & ARCH_CP15_TIMER)
> > @@ -438,7 +438,8 @@ static void __init arch_counter_register(unsigned type)
> > clocksource_register_hz(&clocksource_counter, arch_timer_rate);
> > cyclecounter.mult = clocksource_counter.mult;
> > cyclecounter.shift = clocksource_counter.shift;
> > - timecounter_init(&timecounter, &cyclecounter, start_count);
> > + start_ns = cyclecounter_cyc2ns(&cyclecounter, start_count);
> > + timecounter_init(&timecounter, &cyclecounter, start_ns);
> >
> > /* 56 bits minimum, so we assume worst case rollover */
> > sched_clock_register(arch_timer_read_counter, 56, arch_timer_rate);
>
> This doesn't make much sense. We're converting start_count, which could
> be a very large number, into nanoseconds. It looks like we're assuming
> the counter always starts at 0 which is not always true if you sit in a
> bootloader for a long time.
Yes, the counter here may usually start counting at bootloader time from zero.
> Perhaps it would be better to just do
>
> timecounter_init(&timecounter, &cyclecounter, 0);
>
> or
>
> timecounter_init(&timecounter, &cyclecounter,
> ktime_to_ns(ktime_get_real()));
>
Here the ktime_get_real() will always return 0, before setting the system clock,
Like:
"rtc-ds3232 1-0068: setting system clock to 2014-06-12 13:01:24 UTC (1402578084)"
And if so, why not just set it to 0 ? And by the way, 0 is must here ?
Thanks,
BRs
Xiubo
next prev parent reply other threads:[~2014-06-12 7:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 8:37 Xiubo Li
2014-06-11 19:02 ` Stephen Boyd
2014-06-12 7:45 ` Li.Xiubo [this message]
2014-06-12 17:58 ` Stephen Boyd
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=bce193f3fc264abf82ff52ef69f0b86a@BY2PR03MB505.namprd03.prod.outlook.com \
--to=li.xiubo@freescale.com \
--cc=Marc.Zyngier@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sboyd@codeaurora.org \
--cc=tglx@linutronix.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
all inboxes | Powered by JetHome®