Linux IIO development
 help / color / mirror / Atom feed
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>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jean-Baptiste Maneyrol" <jmaneyrol@invensense.com>
Subject: Re: [PATCH 1/4] iio: imu: inv_icm42600: sleep before enabling FIFO data
Date: Fri, 21 Aug 2026 01:06:23 +0100	[thread overview]
Message-ID: <20260821010623.4d064f8c@jic23-huawei> (raw)
In-Reply-To: <20260820-inv-icm42600-enhacements-v1-1-075a881db557@tdk.com>

On Thu, 20 Aug 2026 21:02:37 +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>
> 
> When turning accel or gyro on, a sleep is required for letting the
> mechanical part stabilize before reporting correct data. Do the sleep
> before enabling FIFO data to prevent push of incorrect data. This is
> required if the FIFO is already on because a sensor is already running.
> 
> Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

I would like a note in here on why the lock dance is
useful. What sort of actions will be waiting on that lock and
make sense in the interval?

Other than that looks fine to me and does indeed seem logical to 
do this before the fifo starts

Jonathan


> ---
>  drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 12 ++++++++----
>  drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c  | 12 ++++++++----
>  2 files changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
> index 4b0e3cd8a506..d889c1dceec1 100644
> --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
> +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
> @@ -254,15 +254,19 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
>  		fifo_en |= INV_ICM42600_SENSOR_ACCEL;
>  	}
>  
> +	/* sleep maximum required time */
> +	sleep = max(sleep_accel, sleep_temp);
> +	if (sleep) {
> +		mutex_unlock(&st->lock);
> +		msleep(sleep);
> +		mutex_lock(&st->lock);
> +	}
> +
>  	/* update data FIFO write */
>  	ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
>  
>  out_unlock:
>  	mutex_unlock(&st->lock);
> -	/* sleep maximum required time */
> -	sleep = max(sleep_accel, sleep_temp);
> -	if (sleep)
> -		msleep(sleep);
>  	return ret;
>  }
>  
> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
> index 253bf571439d..34037b9c1f82 100644
> --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
> +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
> @@ -126,15 +126,19 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev,
>  		fifo_en |= INV_ICM42600_SENSOR_GYRO;
>  	}
>  
> +	/* sleep maximum required time */
> +	sleep = max(sleep_gyro, sleep_temp);
> +	if (sleep) {
> +		mutex_unlock(&st->lock);
> +		msleep(sleep);
> +		mutex_lock(&st->lock);
> +	}
> +
>  	/* update data FIFO write */
>  	ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
>  
>  out_unlock:
>  	mutex_unlock(&st->lock);
> -	/* sleep maximum required time */
> -	sleep = max(sleep_gyro, sleep_temp);
> -	if (sleep)
> -		msleep(sleep);
>  	return ret;
>  }
>  
> 


  reply	other threads:[~2026-08-21  0:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 19:02 [PATCH 0/4] inv_icm42600 driver enhancements Jean-Baptiste Maneyrol via B4 Relay
2026-08-20 19:02 ` [PATCH 1/4] iio: imu: inv_icm42600: sleep before enabling FIFO data Jean-Baptiste Maneyrol via B4 Relay
2026-08-21  0:06   ` Jonathan Cameron [this message]
2026-08-21 12:39     ` Jean-Baptiste Maneyrol
2026-08-21 11:15   ` Andy Shevchenko
2026-08-21 12:50     ` Jean-Baptiste Maneyrol
2026-08-21 13:21       ` Andy Shevchenko
2026-08-20 19:02 ` [PATCH 2/4] iio: imu: inv_icm42600: use 2 sensors fixed packet size of 16 bytes Jean-Baptiste Maneyrol via B4 Relay
2026-08-21  0:09   ` Jonathan Cameron
2026-08-21 12:59     ` Jean-Baptiste Maneyrol
2026-08-20 19:02 ` [PATCH 3/4] iio: imu: inv_icm42600: simplify watermark computation by using gcd Jean-Baptiste Maneyrol via B4 Relay
2026-08-21  0:14   ` Jonathan Cameron
2026-08-21 13:01     ` Jean-Baptiste Maneyrol
2026-08-20 19:02 ` [PATCH 4/4] iio: imu: inv_icm42600: do not read FIFO count for watermark it Jean-Baptiste Maneyrol via B4 Relay
2026-08-21  0:28   ` Jonathan Cameron
2026-08-21 13:09     ` Jean-Baptiste Maneyrol
2026-08-23  1:13       ` 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=20260821010623.4d064f8c@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 \
    /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