Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Sean Nyekjaer <sean@geanix.com>
Cc: <linux-iio@vger.kernel.org>, Jonathan Cameron <jic23@kernel.org>
Subject: Re: fxls8962af: RTC and NTP
Date: Mon, 9 Jan 2023 15:39:55 +0000	[thread overview]
Message-ID: <20230109153955.000032ae@Huawei.com> (raw)
In-Reply-To: <3b268231-7115-d354-4258-9e928c2fa15e@geanix.com>

On Mon, 9 Jan 2023 08:54:05 +0100
Sean Nyekjaer <sean@geanix.com> wrote:

> Hi Jonathan and list,
> 
> We are getting some weird timestamps (with fxls8962af) in the iio 
> buffers when time is set back by NTP.
> 
> Here I have dumped old_timestamp, timestamp from the 
> fxls8962af_fifo_flush():
> old_timestamp 1673008488434717043, timestamp 1673008489457042043
> *old_timestamp 1673008489457042043, timestamp 1673008485198504719*
> old_timestamp 1673008485198504719, timestamp 1673008486220571510
> 
> Time is set back in the middle data set, so the sample timestamp looks like:
> tstamp0 3091988802491735451
> tstamp1 4510969115526428858
> tstamp2 5929949428561122265
> tstamp3 7348929741595815672
> tstamp4 8767910054630509079
> tstamp5 -8259853706044349130
> tstamp6 -6840873393009655723
> tstamp7 -5421893079974962316
> tstamp8 -4002912766940268909
> tstamp9 -2583932453905575502
> tstamp10 -1164952140870882095
> tstamp11 254028172163811312
> tstamp12 1673008485198504719
> 
> Possible solutions?
> Could we store the sample time from the last collected data set?
> And use that if old_timestamp > timestamp?

Ah. I guess this is the timestamp interpolation code going wrong.
It should be possible to make that code 'sort of cope' with negatives
though it would be a slightly nasty heuristic.
You would make it go backwards a little for each fifo entry..

> 
> Or do you have any other idea's?

This mess is a side effect of me picking a silly default clock
a long time back (can't fix that as it's ABI...)

We could smooth it in the driver, but if you have
the option, I'd just change the default clock from userspace.
Take a look at current_timestamp_clock in sysfs.
You should be fine with "monotonic" 

> 
> /Sean


  reply	other threads:[~2023-01-09 15:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09  7:54 fxls8962af: RTC and NTP Sean Nyekjaer
2023-01-09 15:39 ` Jonathan Cameron [this message]
2023-01-10 13:26   ` Sean Nyekjaer

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=20230109153955.000032ae@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=sean@geanix.com \
    /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