* clocksource with changing frequency?
@ 2013-06-21 0:01 Sören Brinkmann
2013-06-21 0:15 ` John Stultz
0 siblings, 1 reply; 4+ messages in thread
From: Sören Brinkmann @ 2013-06-21 0:01 UTC (permalink / raw)
To: John Stultz, Thomas Gleixner
Cc: Sören Brinkmann, linux-kernel, linux-arm-kernel,
Michal Simek
Hi all,
I have a question/problem with a clocksource whose input frequency can
change.
On Zynq we use the cadece_ttc timer as clocksource. Its input clock is
tightly coupled to the CPU clock. I.e. it changes when cpufreq scales
the CPU clocks.
To compensate this, I added a clock notifier doing this on a frequency
change:
clocksource_unregister(&ttccs->cs);
clocksource_register_hz(&ttccs->cs, ndata->new_rate / PRESCALE);
This just seems not to be the most elegant way, a heavy weight operation
and results in a couple of locking errors in combination with
suspend/hotplug.
Is there a sane solution for such a case? E.g. for clockevent devices
there is a 'clockevents_update_freq()' to adjust to changing
frequencies.
I assume the sanest solution is an external oscillator as clock input,
but I think our platforms don't provide that :(
Thanks,
Sören
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: clocksource with changing frequency?
2013-06-21 0:01 clocksource with changing frequency? Sören Brinkmann
@ 2013-06-21 0:15 ` John Stultz
2013-06-21 8:12 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: John Stultz @ 2013-06-21 0:15 UTC (permalink / raw)
To: Sören Brinkmann
Cc: Thomas Gleixner, linux-kernel, linux-arm-kernel, Michal Simek
On 06/20/2013 05:01 PM, Sören Brinkmann wrote:
> Hi all,
>
> I have a question/problem with a clocksource whose input frequency can
> change.
That behavior isn't supported by the clocksource core. We expect
frequency changing clocksources to be detected and disqualified (as we
do w/ freq changing TSCs on older laptops).
> On Zynq we use the cadece_ttc timer as clocksource. Its input clock is
> tightly coupled to the CPU clock. I.e. it changes when cpufreq scales
> the CPU clocks.
> To compensate this, I added a clock notifier doing this on a frequency
> change:
> clocksource_unregister(&ttccs->cs);
> clocksource_register_hz(&ttccs->cs, ndata->new_rate / PRESCALE);
This will definitely have problems if this is the only high-res capable
clocksource.
> This just seems not to be the most elegant way, a heavy weight operation
> and results in a couple of locking errors in combination with
> suspend/hotplug.
>
> Is there a sane solution for such a case? E.g. for clockevent devices
> there is a 'clockevents_update_freq()' to adjust to changing
> frequencies.
If you want to experiment with things, my suggestion would be to try to
fake a constant frequency clocksource in the clocksource driver(tracking
the change intervals and multiplying them up as needed). However, I
worry the quality of timekeeping won't be very good, as any latency in
the detection of the freq change will cause time error.
> I assume the sanest solution is an external oscillator as clock input,
> but I think our platforms don't provide that :(
I suspect your best bet, if there really is no other consistent clocks,
would be to disable highres timers and use the jiffies clocksource for
timekeeping, allowing you to change cpufreq to save power or increase
performance as you need. This will result in coarse timekeeping and
larger timer latency. But the only other approach is to fix the cpu freq
so the clocksource freq doesn't change (at the cost of cpu performance
or battery life - both of which I suspect are bigger issues then coarse
time).
thanks
-john
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: clocksource with changing frequency?
2013-06-21 0:15 ` John Stultz
@ 2013-06-21 8:12 ` Thomas Gleixner
2013-06-21 22:00 ` Sören Brinkmann
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2013-06-21 8:12 UTC (permalink / raw)
To: John Stultz
Cc: Sören Brinkmann, linux-kernel, linux-arm-kernel,
Michal Simek
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1029 bytes --]
On Thu, 20 Jun 2013, John Stultz wrote:
> On 06/20/2013 05:01 PM, Sören Brinkmann wrote:
> > Hi all,
> >
> > I have a question/problem with a clocksource whose input frequency can
> > change.
>
> That behavior isn't supported by the clocksource core. We expect frequency
> changing clocksources to be detected and disqualified (as we do w/ freq
> changing TSCs on older laptops).
>
>
> > On Zynq we use the cadece_ttc timer as clocksource. Its input clock is
> > tightly coupled to the CPU clock. I.e. it changes when cpufreq scales
> > the CPU clocks.
> > To compensate this, I added a clock notifier doing this on a frequency
> > change:
> > clocksource_unregister(&ttccs->cs);
> > clocksource_register_hz(&ttccs->cs, ndata->new_rate / PRESCALE);
>
> This will definitely have problems if this is the only high-res capable
> clocksource.
And starting with 3.11 it will be not longer possible to unregister
the only high-res capable clocksource exactly to prevent the wreckage
you are talking about :)
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-21 22:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-21 0:01 clocksource with changing frequency? Sören Brinkmann
2013-06-21 0:15 ` John Stultz
2013-06-21 8:12 ` Thomas Gleixner
2013-06-21 22:00 ` Sören Brinkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox