Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Chris Morgan" <macroalpha82@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH V19 6/9] iio: imu: inv_icm42607: Add Accelerometer for icm42607
Date: Wed, 22 Jul 2026 16:01:30 +0000	[thread overview]
Message-ID: <20260722160130.DEC2D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722153942.144387-7-macroalpha82@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Sensor data read immediately after power-on fails with -EINVAL for low ODRs due to insufficient wait time.
- [Medium] A race condition during device removal leaves the hardware permanently powered on because devm-based IIO unregistration occurs after the driver's custom remove callback.
--

--- Patch [6]: [PATCH V19 6/9] iio: imu: inv_icm42607: Add Accelerometer for icm42607 ---
commit d5a95e354010c482038057c3ba35322667609d59
Author: Chris Morgan <macromorgan@hotmail.com>

iio: imu: inv_icm42607: Add Accelerometer for icm42607
    
Add icm42607 accelerometer sensor for icm42607.

> diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c b/drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c
> new file mode 100644
> index 0000000000000..f563c77084201
> --- /dev/null
> +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_accel.c

[ ... ]

> @@ -288,21 +288,21 @@ struct iio_dev *inv_icm42607_accel_init(struct inv_icm42607_state *st)
> +	indio_dev->name = name;
> +	indio_dev->info = &inv_icm42607_accel_info;
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +	indio_dev->channels = inv_icm42607_accel_channels;
> +	indio_dev->num_channels = ARRAY_SIZE(inv_icm42607_accel_channels);
> +	iio_device_set_drvdata(indio_dev, st);
> +
> +	ret = devm_iio_device_register(dev, indio_dev);

[Severity: Medium]
Could this lead to the hardware being left permanently powered on
during device removal?

During driver unbind, the custom remove callback (inv_icm42607_sensors_off)
will run before the devm cleanup unregisters this IIO device.

If a concurrent userspace sysfs read re-enables the sensor via runtime PM
before the devm IIO unregistration occurs:

sysfs read
  pm_runtime_get... (powers device on)
  inv_icm42607_read_sensor()
  pm_runtime_put_autosuspend... (queues async suspend)

Will the subsequent devm cleanup of runtime PM cancel the async suspend
and leave the device powered on indefinitely?

> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	return indio_dev;
> +}

> diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c b/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> index d85eaedef0706..c1648f5c35389 100644
> --- a/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c

[ ... ]

> @@ -355,18 +364,18 @@ int inv_icm42607_read_sensor(struct iio_dev *indio_dev,
> +	/* read sensor register data */
> +	ret = regmap_bulk_read(st->map, reg, &data, sizeof(data));
> +	if (ret)
> +		return ret;
> +
> +	*val = be16_to_cpu(data);
> +	if (*val == INV_ICM42607_DATA_INVALID)
> +		return -EINVAL;

[Severity: Medium]
Can this return -EINVAL during normal sysfs reads at low ODRs?

When the device is in autosuspend and a sysfs read occurs at a low ODR
(e.g., 1.5625 Hz), the driver wakes up the sensor and waits for 
INV_ICM42607_ACCEL_STARTUP_TIME_US (10ms).

Since the first sample at such a low ODR can take much longer (e.g., ~640ms)
to be ready, will the hardware return INV_ICM42607_DATA_INVALID here,
causing the read to fail rather than blocking until data is ready?

> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260722153942.144387-1-macroalpha82@gmail.com?part=6

  reply	other threads:[~2026-07-22 16:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 15:39 [PATCH V19 0/9] Add Invensense ICM42607 Chris Morgan
2026-07-22 15:39 ` [PATCH V19 1/9] dt-bindings: iio: imu: icm42600: Add mount-matrix Chris Morgan
2026-07-22 15:39 ` [PATCH V19 2/9] dt-bindings: iio: imu: icm42600: Add icm42607 Chris Morgan
2026-07-22 15:39 ` [PATCH V19 3/9] iio: imu: inv_icm42607: Add inv_icm42607 Core Driver Chris Morgan
2026-07-22 15:53   ` sashiko-bot
2026-07-22 15:39 ` [PATCH V19 4/9] iio: imu: inv_icm42607: Add SPI For icm42607 Chris Morgan
2026-07-22 15:39 ` [PATCH V19 5/9] iio: imu: inv_icm42607: Add PM support for icm42607 Chris Morgan
2026-07-22 16:07   ` sashiko-bot
2026-07-22 15:39 ` [PATCH V19 6/9] iio: imu: inv_icm42607: Add Accelerometer " Chris Morgan
2026-07-22 16:01   ` sashiko-bot [this message]
2026-07-22 15:39 ` [PATCH V19 7/9] iio: imu: inv_icm42607: Add Gyroscope to icm42607 Chris Morgan
2026-07-22 15:39 ` [PATCH V19 8/9] iio: imu: inv_icm42607: Add Temp Support in icm42607 Chris Morgan
2026-07-22 15:39 ` [PATCH V19 9/9] arm64: dts: rockchip: Add icm42607p IMU for RG-DS Chris Morgan
2026-07-22 15:59   ` sashiko-bot

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=20260722160130.DEC2D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=macroalpha82@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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