public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Alexander Holler <holler@ahsoftware.de>
Cc: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: adjusting the monotonic system time (from inside the kernel)
Date: Fri, 07 Jun 2013 16:49:22 -0700	[thread overview]
Message-ID: <51B27182.8010506@linaro.org> (raw)
In-Reply-To: <5187B813.8000907@ahsoftware.de>

On 05/06/2013 07:02 AM, Alexander Holler wrote:
> Hello,
>
> I'm looking at how to adjust the (monotonic) system time from inside 
> the kernel.
>
> Use case is that I have a hw-clock which (not necessarily) regulary 
> sends a timestamp with millisecond precision which I want to use to 
> adjust the system time.
>
> It seems the usual solution to do such, is to use NTP which uses it's 
> own driver (which usually seems to be based on some serial connection):
>
> hw-clock --serial--> kernel --serial-device--> ntpd -> kernel -> 
> system-time
>
> So one solution would be to emulate such a serial device:
>
> hw-clock --> kernel --emulated-serial-device--> ntpd -> kernel -> 
> system-time
>
> Another solution would be to "invent" a ntp-device and write a driver 
> for ntpd to use it:
>
> hw-clock --> kernel --ntp-device--> ntpd -> kernel -> system-time
>
> But I would prefer the following:
>
> hw-clock --> kernel -> system-time
>
> Problem is that the hw-clock in question doesn't offer something like 
> a tick. It just might send a timestamp with millisecond precision 
> whenever it wants.
>
> Because I don't want to reinvent the wheel and because I think there 
> are some people which already have spend some thoughts on similiar 
> things, I'm asking here before I try to implement something which then 
> never might find it's way into the mainline kernel.
>
> Any hints, suggestions, whatever?

Sorry on the delay to reply here, just noticed this in my spam folder 
(hopefully I've trained it not to catch your mails now).

You probably want to check out do_adjtimex() in the kernel. It has a 
number of ways that allow for the clock to be slewed or jumped. 
Otherwise you probably should look into the PPS subsystems to see if it 
could be extended to support your needs.

thanks
-john



  parent reply	other threads:[~2013-06-07 23:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-06 14:02 adjusting the monotonic system time (from inside the kernel) Alexander Holler
2013-05-06 15:05 ` Alexander Holler
2013-06-07 23:49 ` John Stultz [this message]
2013-06-08  8:23   ` [rtc-linux] " Alexander Holler

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=51B27182.8010506@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=holler@ahsoftware.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --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