From: jgunthorpe@obsidianresearch.com (Jason Gunthorpe)
To: linux-arm-kernel@lists.infradead.org
Subject: On NTP, RTCs and accurately setting their time
Date: Wed, 20 Sep 2017 10:22:08 -0600 [thread overview]
Message-ID: <20170920162208.GB536@obsidianresearch.com> (raw)
In-Reply-To: <20170920112152.GL20805@n2100.armlinux.org.uk>
On Wed, Sep 20, 2017 at 12:21:52PM +0100, Russell King - ARM Linux wrote:
> However, assumptions are made about the RTC:
>
> 1. kernel/time/ntp.c assumes that all RTCs want to be told to set the
> time at around 500ms into the second.
>
> 2. drivers/rtc/systohc.c assumes that if the time being set is >= 500ms,
> then we want to set the _next_ second.
I looked at these issues when I did the sys to HC patches and I
concluced the first problem was that the RTC read functions generally
did not return sub second resolution, either in sense of directly
returning ts_nsec, or the sense of delaying the read until a clock
tick over event.
Eg if I repeatedly booted my various embedded ARM/PPC systems, and
recorded the time offset from NTP, I got a fairly random distribution
of offsets.
Given that we couldn't seem to read back sub second resolution on my
systems, storing it more accurately did not seem important.
I think we also did some experiments with a few of the RTCs we were
using and some of them did not adjust the seconds clock phase on
write, so they seemed incapable of storing sub second data anyhow.
So.. My feeling was that we'd need driver support in each RTC driver
to enable sub section resolution.
Do you know differently?
Our pragmatic solution in our products was to have the initial time
sync from NTP step the clock even if the offset is small.
> So, the question is... how should these differences in rtc requirements
> be handled?
I think patch wise, this is something I would rather see handled
internally via the drivers and perhaps with input from DT, not via
sysctl knobs.
The HW driver should know how to read and write with sub second
resolution. If it works best with a certain value in the ts_nsec
field, then it should set something inside rtc_chip that causes the
systohc code to try and call it with that tv_nsec.
It would probably also make sense to add new ntp ops for sub second
get/set that includes the full timespec. This way the RTC driver can
provide the right adjustments and we can get rid of the +1 in
rtc_set_ntp_time and the +0.5 in rtc_hctosys for sub sec aware
drivers..
Jason
next prev parent reply other threads:[~2017-09-20 16:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 11:21 On NTP, RTCs and accurately setting their time Russell King - ARM Linux
2017-09-20 13:23 ` Russell King - ARM Linux
2017-09-20 16:22 ` Jason Gunthorpe [this message]
2017-09-20 16:51 ` Russell King - ARM Linux
2017-09-20 17:16 ` Jason Gunthorpe
2017-09-20 22:45 ` Jason Gunthorpe
2017-09-21 7:59 ` Russell King - ARM Linux
2017-09-21 9:32 ` Russell King - ARM Linux
2017-09-21 11:30 ` Russell King - ARM Linux
2017-09-21 22:05 ` Jason Gunthorpe
2017-09-21 22:45 ` Russell King - ARM Linux
2017-09-21 23:20 ` Jason Gunthorpe
2017-09-22 9:57 ` Russell King - ARM Linux
2017-09-22 12:24 ` Russell King - ARM Linux
2017-09-22 16:28 ` Russell King - ARM Linux
2017-09-22 16:48 ` Jason Gunthorpe
2017-09-22 17:20 ` Russell King - ARM Linux
2017-09-22 18:24 ` Jason Gunthorpe
2017-09-23 18:23 ` Russell King - ARM Linux
2017-09-23 19:05 ` Russell King - ARM Linux
2017-09-24 1:30 ` Jason Gunthorpe
2017-09-21 9:46 ` Russell King - ARM Linux
2017-09-21 11:29 ` Russell King - ARM Linux
2017-09-21 12:28 ` Russell King - ARM Linux
2017-09-26 11:58 ` Alexandre Belloni
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=20170920162208.GB536@obsidianresearch.com \
--to=jgunthorpe@obsidianresearch.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.