From: Jonathan Cameron <jic23@kernel.org>
To: Jean-Baptiste Maneyrol via B4 Relay
<devnull+jean-baptiste.maneyrol.tdk.com@kernel.org>
Cc: jean-baptiste.maneyrol@tdk.com,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Jean-Baptiste Maneyrol" <jmaneyrol@invensense.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] iio: imu: inv_icm42600: fix timestamping by limiting FIFO reading
Date: Fri, 3 Jul 2026 20:04:55 +0100 [thread overview]
Message-ID: <20260703200455.5fa70e5b@jic23-huawei> (raw)
In-Reply-To: <20260629-inv-icm42600-fix-watermark-fifo-reading-v2-1-967e375db7b3@tdk.com>
On Mon, 29 Jun 2026 21:51:55 +0200
Jean-Baptiste Maneyrol via B4 Relay <devnull+jean-baptiste.maneyrol.tdk.com@kernel.org> wrote:
> From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
>
> Timestamps are made by measuring the chip clock using the watermark
> interrupts. If we read more than watermark samples as done today, we
> are reducing the period between interrupts and distort the time
> measurement. Fix that by reading only watermark samples in the
> interrupt case.
>
> Fixes: 7f85e42a6c54 ("iio: imu: inv_icm42600: add buffer support in iio devices")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
> ---
> Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
That's not confusing at all :)
I've applied with the invensense one only - shout if you want something else.
Thanks,
Jonathan
> ---
> Changes in v2:
> - Delete watermark computation rework, keep only FIFO read fix.
> - Link to v1: https://patch.msgid.link/20260623-inv-icm42600-fix-watermark-fifo-reading-v1-1-f3f5694a818a@tdk.com
>
> To: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
> To: Jonathan Cameron <jic23@kernel.org>
> To: David Lechner <dlechner@baylibre.com>
> To: Nuno Sá <nuno.sa@analog.com>
> To: Andy Shevchenko <andy@kernel.org>
> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
> Cc: linux-iio@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
> drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 9 +++++----
> drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h | 1 +
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
> index 68a395758031..5c3840acf085 100644
> --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
> +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
> @@ -248,6 +248,7 @@ int inv_icm42600_buffer_update_watermark(struct inv_icm42600_state *st)
>
> /* compute watermark value in bytes */
> wm_size = watermark * packet_size;
> + st->fifo.watermark.value = watermark;
>
> /* changing FIFO watermark requires to turn off watermark interrupt */
> ret = regmap_update_bits_check(st->map, INV_ICM42600_REG_INT_SOURCE0,
> @@ -454,11 +455,10 @@ int inv_icm42600_buffer_fifo_read(struct inv_icm42600_state *st,
> st->fifo.nb.accel = 0;
> st->fifo.nb.total = 0;
>
> - /* compute maximum FIFO read size */
> + /* compute maximum FIFO read size (watermark for max = 0 interrupt case) */
> if (max == 0)
> - max_count = sizeof(st->fifo.data);
> - else
> - max_count = max * inv_icm42600_get_packet_size(st->fifo.en);
> + max = st->fifo.watermark.value;
> + max_count = max * inv_icm42600_get_packet_size(st->fifo.en);
>
> /* read FIFO count value */
> raw_fifo_count = (__be16 *)st->buffer;
> @@ -574,6 +574,7 @@ int inv_icm42600_buffer_init(struct inv_icm42600_state *st)
>
> st->fifo.watermark.eff_gyro = 1;
> st->fifo.watermark.eff_accel = 1;
> + st->fifo.watermark.value = 1;
>
> /*
> * Default FIFO configuration (bits 7 to 5)
> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h
> index ffca4da1e249..88b8b9f780af 100644
> --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h
> +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h
> @@ -34,6 +34,7 @@ struct inv_icm42600_fifo {
> unsigned int accel;
> unsigned int eff_gyro;
> unsigned int eff_accel;
> + unsigned int value;
> } watermark;
> size_t count;
> struct {
>
> ---
> base-commit: cc746297b23e89bd5df9f91f3a0ca209e8991763
> change-id: 20260623-inv-icm42600-fix-watermark-fifo-reading-624caf080754
>
> Best regards,
> --
> Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
>
>
>
next prev parent reply other threads:[~2026-07-03 19:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 19:51 [PATCH v2] iio: imu: inv_icm42600: fix timestamping by limiting FIFO reading Jean-Baptiste Maneyrol via B4 Relay
2026-07-03 19:04 ` Jonathan Cameron [this message]
2026-07-04 11:48 ` Andy Shevchenko
2026-07-04 23:02 ` Jonathan Cameron
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=20260703200455.5fa70e5b@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=devnull+jean-baptiste.maneyrol.tdk.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jean-baptiste.maneyrol@tdk.com \
--cc=jmaneyrol@invensense.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=stable@vger.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