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: Thu, 28 May 2020 23:07:11 +0200 [thread overview]
Message-ID: <20200528210711.GD5419@localhost.localdomain> (raw)
In-Reply-To: <54cb146d-e54e-acae-e89c-075521b8e7dc@geanix.com>
[-- Attachment #1: Type: text/plain, Size: 4130 bytes --]
> Hi,
Hi Sean,
>
> I don't know if it's normal behavior or maybe just a problem related to the
> buffered reads in st_lsm6dsx.
>
> But when we have the buffered reads enabled and suspending for x amount of
> time. The iio timestamps is, x amount of time is delayed. As seen here:
>
> https://gist.github.com/sknsean/60e20c2fa3a3c6d69ef128c703ed43fc
>
> From your own software (but I'm able to reproduce with libiio/iio_readdev)
>
> First col is system time,
> Second timestamp is the iio timestamp
>
> Could a solution, be to call st_lsm6dsx_reset_hw_ts() in st_lsm6dsx_resume()
> ?
yes, I think so. Could you please try to patch below? Thanks.
Regards,
Lorenzo
>
> /Sean
From f4ea9019d3b6fb1ad80747cf378bf1fbdebd3dd8 Mon Sep 17 00:00:00 2001
Message-Id: <f4ea9019d3b6fb1ad80747cf378bf1fbdebd3dd8.1590699935.git.lorenzo@kernel.org>
From: Lorenzo Bianconi <lorenzo@kernel.org>
Date: Thu, 28 May 2020 23:05:16 +0200
Subject: [PATCH] iio: imu: st_lsm6dsx: reset hw ts after resume
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 +--
.../iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 23 ++++++++++++-------
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +-
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index b56df409ed0f..529970195b39 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -436,8 +436,7 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor,
u16 watermark);
int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable);
int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw);
-int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
- enum st_lsm6dsx_fifo_mode fifo_mode);
+int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw);
int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw);
int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw);
int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u32 odr, u8 *val);
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index afd00daeefb2..7de10bd636ea 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -184,8 +184,8 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
return err;
}
-int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
- enum st_lsm6dsx_fifo_mode fifo_mode)
+static int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
+ enum st_lsm6dsx_fifo_mode fifo_mode)
{
unsigned int data;
@@ -302,6 +302,18 @@ static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw)
return 0;
}
+int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw)
+{
+ int err;
+
+ /* reset hw ts counter */
+ err = st_lsm6dsx_reset_hw_ts(hw);
+ if (err < 0)
+ return err;
+
+ return st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
+}
+
/*
* Set max bulk read to ST_LSM6DSX_MAX_WORD_LEN/ST_LSM6DSX_MAX_TAGGED_WORD_LEN
* in order to avoid a kmalloc for each bus access
@@ -675,12 +687,7 @@ int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable)
goto out;
if (fifo_mask) {
- /* reset hw ts counter */
- err = st_lsm6dsx_reset_hw_ts(hw);
- if (err < 0)
- goto out;
-
- err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
+ err = st_lsm6dsx_resume_fifo(hw);
if (err < 0)
goto out;
}
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 0b776cb91928..b3a08e3e2359 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2458,7 +2458,7 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev)
}
if (hw->fifo_mask)
- err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
+ err = st_lsm6dsx_resume_fifo(hw);
return err;
}
--
2.26.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2020-05-28 21:07 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 [this message]
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
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=20200528210711.GD5419@localhost.localdomain \
--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 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).