All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Sean Nyekjaer <sean@geanix.com>
Cc: linux-iio <linux-iio@vger.kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: IIO timestamp get skewed when suspending (st_lsm6dsx)
Date: Wed, 3 Jun 2020 10:06:19 +0200	[thread overview]
Message-ID: <20200603080619.GA544784@lore-desk.lan> (raw)
In-Reply-To: <e9964fda-3b83-2e23-299a-7ab7d50529af@geanix.com>

[-- Attachment #1: Type: text/plain, Size: 1976 bytes --]

> 
> 
> On 02/06/2020 15.39, Sean Nyekjaer wrote:
> > > > are these values from the hw FIFO? can you please add
> > > > sensor->ts_ref to the trace and
> > > > a log into st_lsm6dsx_reset_hw_ts?
> > > > 
> > > 
> > > Hi,
> > > 
> > > This certainly looks weird,
> > > 
> > > https://gist.github.com/sknsean/b32bae140008cf446a8fea58e305da47
> > > 
> > > Seems like the ts_ref is updated and used but not read/used in
> > > userspace...
> > > 
> > > /Sean
> > 
> > added to st_lsm6dsx_read_fifo :
> > 
> > printk("ts_ref %lld, ts %lld, sample_time %lld\n", acc_sensor->ts_ref,
> > ts, acc_sensor->ts_ref + ts);
> > 
> > https://gist.github.com/sknsean/3ad1e9e05cb0e2ef811a3c83492a1980
> > 
> > Suspend again was 15sec
> > 
> > /Sean
> 
> Hi,
> 
> Some more findings :)
> https://gist.github.com/sknsean/d31e48b65515361309cd238dcf68600f
> 
> To me it looks like ktime_get_real_ns() isn't ready or updated when we are
> calling iio_get_time_ns().
> If we look in the trace ktime_get_real_ns() it's ready when we are getting
> the first sample after suspend.
> 
> Running with this patch:
> https://gist.github.com/sknsean/415d1b9c34f20db4419a0c61a58eb188
> +
> The first from this thread.
> 
> /Sean

Hi Sean,

looking at the logs I guess we should not reset the sensor hw ts. Could you
please try the below patch?

Regards,
Lorenzo

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 0b776cb91928..4f8a9bcee77b 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2445,6 +2445,8 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev)
 		if (!(hw->suspend_mask & BIT(sensor->id)))
 			continue;
 
+		sensor->ts_ref = iio_get_time_ns(hw->iio_devs[i]);
+
 		if (sensor->id == ST_LSM6DSX_ID_EXT0 ||
 		    sensor->id == ST_LSM6DSX_ID_EXT1 ||
 		    sensor->id == ST_LSM6DSX_ID_EXT2)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2020-06-03  8:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 18:01 IIO timestamp get skewed when suspending (st_lsm6dsx) Sean Nyekjaer
2020-05-28 21:07 ` Lorenzo Bianconi
2020-05-29  7:32   ` Sean Nyekjaer
2020-05-29  7:44     ` Lorenzo Bianconi
2020-05-29  8:33       ` Sean Nyekjaer
2020-05-29  8:50         ` Lorenzo Bianconi
2020-05-29 11:19           ` Sean Nyekjaer
2020-05-29 12:16             ` Lorenzo Bianconi
2020-05-29 12:29               ` Sean Nyekjaer
2020-06-02 11:48               ` Sean Nyekjaer
2020-06-02 13:39                 ` Sean Nyekjaer
2020-06-02 18:02                   ` Sean Nyekjaer
2020-06-03  8:06                     ` Lorenzo Bianconi [this message]
2020-06-03 10:05                       ` Sean Nyekjaer
2020-06-03 10:28                         ` Lorenzo Bianconi
2020-06-03 10:37                           ` Sean Nyekjaer
2020-06-03 10:51                             ` Lorenzo Bianconi
2020-06-03 11:29                               ` Sean Nyekjaer
2020-06-03 12:12                                 ` Lorenzo Bianconi
2020-06-03 12:49                                   ` Sean Nyekjaer
2020-06-03 12:56                                     ` Lorenzo Bianconi
2020-06-03 13:15                                       ` Sean Nyekjaer
2020-06-03 13:40                                         ` Lorenzo Bianconi
2020-06-03 14:10                                           ` Sean Nyekjaer
2020-06-08 12:20                                             ` Sean Nyekjaer
2020-06-08 14:09                                               ` Thomas Gleixner
2020-07-10 12:10   ` Sean Nyekjaer
2020-07-10 13:20     ` Lorenzo Bianconi

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=20200603080619.GA544784@lore-desk.lan \
    --to=lorenzo@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --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 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.