From: Jonathan Cameron <jic23@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
"Christopher S. Hall" <christopher.s.hall@intel.com>,
netdev <netdev@vger.kernel.org>,
"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
"maintainer\:X86 ARCHITECTURE \(32-BIT AND 64-BIT\)"
<x86@kernel.org>,
jacob.e.keller@intel.com,
Richard Cochran <richardcochran@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Sean V Kelley <sean.v.kelley@intel.com>
Subject: Re: [Intel PMC TGPIO Driver 0/5] Add support for Intel PMC Time GPIO Driver with PHC interface changes to support additional H/W Features
Date: Sun, 8 Mar 2020 19:14:41 +0000 [thread overview]
Message-ID: <20200308191441.1eed786e@archlinux> (raw)
In-Reply-To: <87wo81cvho.fsf@nanos.tec.linutronix.de>
On Tue, 03 Mar 2020 16:24:03 +0100
Thomas Gleixner <tglx@linutronix.de> wrote:
> Linus Walleij <linus.walleij@linaro.org> writes:
> > On Thu, Feb 27, 2020 at 12:06 AM Thomas Gleixner <tglx@linutronix.de> wrote:
> >> "Christopher S. Hall" <christopher.s.hall@intel.com> writes:
> > IIO has a config file in sysfs that lets them select the source of the
> > timestamp like so (drivers/iio/industrialio-core.c):
> >
> > s64 iio_get_time_ns(const struct iio_dev *indio_dev)
> > {
> > struct timespec64 tp;
> >
> > switch (iio_device_get_clock(indio_dev)) {
> > case CLOCK_REALTIME:
> > return ktime_get_real_ns();
> > case CLOCK_MONOTONIC:
> > return ktime_get_ns();
> > case CLOCK_MONOTONIC_RAW:
> > return ktime_get_raw_ns();
> > case CLOCK_REALTIME_COARSE:
> > return ktime_to_ns(ktime_get_coarse_real());
> > case CLOCK_MONOTONIC_COARSE:
> > ktime_get_coarse_ts64(&tp);
> > return timespec64_to_ns(&tp);
> > case CLOCK_BOOTTIME:
> > return ktime_get_boottime_ns();
> > case CLOCK_TAI:
> > return ktime_get_clocktai_ns();
> > default:
> > BUG();
> > }
> > }
>
> That's a nice example of overengineering :)
Yeah. There was some ugly history behind that including some 'ancient'
stupidity from me :( I certainly don't recommend anyone copies it.
We may have overcompensated for having an odd default by allowing
lots of other odd choices.
>
> > After discussion with Arnd we concluded the only timestamp that
> > makes sense is ktime_get_ns(). So in GPIO we just use that, all the
> > userspace I can think of certainly prefers monotonic time.
> > (If tglx does not agree with that I stand corrected to whatever
> > he says, I suppose.)
>
> In general, CLOCK_MONOTONIC is what makes most sense.
>
> The only other interesting clock which makes sense from an application
> POV is CLOCK_TAI which is becoming more popular in terms of network wide
> time coordination and TSN.
>
> CLOCK_REALTIME is a pain to deal with due to leap seconds, daylight
> savings etc.
>
> > Anyway in GPIO we could also make it configurable for users who
> > know what they are doing.
> >
> > HW timestamps would be something more elaborate and
> > nice CLOCK_HW_SPECIFIC or so. Some of the IIO sensors also
> > have that, we just don't expose it as of now.
>
> HW timestamps are just more accurate than the software timestamps which
> we have now and from a portability and interface POV they should just be
> converted converted / mapped to clock MONOTONIC or clock TAI. So your
> existing interface (maybe extended to TAI in the future) is just
> working, but more accurate.
>
> Exposing the HW timestamp itself based on some random and potentially
> unknown clock might still be useful for some specialized applications,
> but that want's to be through a distinct interface so there is no chance
> to confuse it with something generally useful.
Agreed, though it would be nice to actually have some hardware
that supports sane synchronization between a hardware timestamp and
sensible clocks in the system. In IIO we have some nasty filtering in
some drivers to attempt to align hardware timestamps and deal with
jitter in interrupt handling.
Good luck (or maybe you do have a rare sane system!)
Jonathan
>
> Thanks,
>
> tglx
next prev parent reply other threads:[~2020-03-08 19:14 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 21:48 [Intel PMC TGPIO Driver 0/5] Add support for Intel PMC Time GPIO Driver with PHC interface changes to support additional H/W Features christopher.s.hall
2019-12-11 21:48 ` [Intel PMC TGPIO Driver 1/5] drivers/ptp: Add Enhanced handling of reserve fields christopher.s.hall
2020-01-31 16:54 ` Jacob Keller
2020-02-03 1:45 ` Richard Cochran
2020-02-24 23:29 ` Christopher S. Hall
2020-01-31 17:02 ` Jacob Keller
2020-02-03 1:27 ` Richard Cochran
2020-02-24 23:23 ` Christopher S. Hall
2019-12-11 21:48 ` [Intel PMC TGPIO Driver 2/5] drivers/ptp: Add PEROUT2 ioctl frequency adjustment interface christopher.s.hall
2020-02-03 2:14 ` Richard Cochran
2020-02-26 0:20 ` Christopher S. Hall
2019-12-11 21:48 ` [Intel PMC TGPIO Driver 3/5] drivers/ptp: Add user-space input polling interface christopher.s.hall
2020-02-03 2:28 ` Richard Cochran
2019-12-11 21:48 ` [Intel PMC TGPIO Driver 4/5] x86/tsc: Add TSC support functions to support ART driven Time-Aware GPIO christopher.s.hall
2019-12-11 21:48 ` [Intel PMC TGPIO Driver 5/5] drivers/ptp: Add PMC Time-Aware GPIO Driver christopher.s.hall
2020-02-03 2:31 ` Richard Cochran
2020-02-07 17:10 ` Linus Walleij
2020-02-07 17:28 ` Andrew Lunn
2020-02-07 19:49 ` Andy Shevchenko
2020-02-07 19:52 ` Andy Shevchenko
2020-02-24 23:17 ` Christopher S. Hall
2020-01-31 15:08 ` [Intel PMC TGPIO Driver 0/5] Add support for Intel PMC Time GPIO Driver with PHC interface changes to support additional H/W Features Jakub Kicinski
2020-01-31 18:14 ` Thomas Gleixner
2020-02-24 22:40 ` Christopher S. Hall
2020-02-26 23:06 ` Thomas Gleixner
2020-03-03 1:56 ` Christopher S. Hall
2020-03-03 13:00 ` Linus Walleij
2020-03-03 15:23 ` Richard Cochran
2020-03-03 15:24 ` Thomas Gleixner
2020-03-08 19:14 ` Jonathan Cameron [this message]
2020-02-03 4:08 ` Richard Cochran
2020-02-03 18:27 ` Jacob Keller
2020-02-25 23:37 ` Christopher S. Hall
2020-02-26 2:47 ` Richard Cochran
2020-03-03 2:01 ` Christopher S. Hall
2020-02-07 17:17 ` Linus Walleij
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=20200308191441.1eed786e@archlinux \
--to=jic23@kernel.org \
--cc=bgolaszewski@baylibre.com \
--cc=christopher.s.hall@intel.com \
--cc=davem@davemloft.net \
--cc=hpa@zytor.com \
--cc=jacob.e.keller@intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=sean.v.kelley@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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 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).