From: sashiko-bot@kernel.org
To: "Kanak Shilledar" <kanak.shilledar@axis.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 6/8] iio: imu: inv_icm42607: Implement MREGx register access
Date: Tue, 01 Sep 2026 14:47:31 +0000 [thread overview]
Message-ID: <20260901144731.AA53A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901-b4-inv_icm42370p-v3-6-77cc31642115@axis.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Resource leak: The RC oscillator is forced on for MREG access but never explicitly turned off.
- [Medium] Unintended power state regression: default accelerometer mode for ICM42370 changed to LOW_POWER.
--
commit 5e054b5c4e067c471755e5889343bfd30cf9d57a
Author: Kanak Shilledar <kanak.shilledar@axis.com>
iio: imu: inv_icm42607: Implement MREGx register access
This commit implements indirect register access to different banks (MREGx)
for the inv_icm42607 IMU driver. This allows accessing registers configured
via the user and implementing buffer support. It also alters the default
accelerometer configuration for the ICM42370.
Datasheet: https://www.invensense.tdk.com/en-us/products/3-axis/icm-42370-p
Datasheet: https://www.lcsc.com/product-detail/C5129967.html
> diff --git a/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c b/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> index e77d72e0f7bc6..6e514b8682a0e 100644
> --- a/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
> +++ b/drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
[ ... ]
> @@ -96,7 +99,7 @@ static const struct inv_icm42607_conf inv_icm42607_default_conf = {
> static const struct inv_icm42607_conf inv_icm42370_default_conf = {
> .gyro = { },
> .accel = {
> - .mode = INV_ICM42607_SENSOR_MODE_OFF,
> + .mode = INV_ICM42607_SENSOR_MODE_LOW_POWER,
[Severity: Medium]
Does this unintentionally cause the accelerometer to consume power immediately
upon probe?
During driver probe, inv_icm42607_set_init_conf() writes this initial state
to the hardware. This undocumented change forces the accelerometer to turn on
immediately at boot.
While runtime PM will eventually suspend the device and turn it off after a
2-second delay, it introduces an unnecessary power spike at boot and leaves
the software defaults in an inconsistent state.
> .fs = INV_ICM42607_ACCEL_FS_4G,
> .odr = INV_ICM42607_ODR_100HZ,
> .filter = INV_ICM42607_FILTER_BW_25HZ,
[ ... ]
> @@ -352,6 +355,107 @@ int inv_icm42607_set_sensor_conf(struct inv_icm42607_state *st,
> }
> }
>
> +static int inv_icm42607_mreg_check(struct inv_icm42607_state *st)
> +{
> + struct regmap *map = st->map;
> + unsigned int val;
> + int ret;
> +
> + ret = regmap_read(map, INV_ICM42607_REG_MCLK_RDY, &val);
> + if (ret)
> + return ret;
> +
> + if (val & INV_ICM42607_MCLK_RDY_BIT)
> + return 0;
> +
> + /*
> + * Clock isn't running: we're either in Sleep mode or Accel LP
> + * mode with WUOSC. Force the RC oscillator on via IDLE, then
> + * wait for MCLK_RDY.
> + */
> + ret = regmap_set_bits(map, INV_ICM42607_REG_PWR_MGMT0,
> + INV_ICM42607_PWR_MGMT0_IDLE);
[Severity: Medium]
Does this code leak power by leaving the RC oscillator running indefinitely?
inv_icm42607_mreg_check() sets the INV_ICM42607_PWR_MGMT0_IDLE bit to force
the RC oscillator on when accessing MREGs while the sensor is in OFF or
LOW_POWER mode. The datasheet explicitly requires this bit to be cleared
after MREG access is complete to save power.
Neither inv_icm42607_mreg_check() nor the read/write sequences clear this
bit. Although runtime PM autosuspend (after a 2-second delay) will
coincidentally overwrite PWR_MGMT0 and clear the bit, this still leaves the
oscillator running needlessly for 2 seconds per access, or indefinitely if
runtime PM is disabled, causing a persistent power leak.
> + if (ret)
> + return ret;
> +
> + /*
> + * After setting the IDLE bit to 1 in PWR_MGMT0 register, wait for anywhere between
> + * 10us to 200us which are the ACCEL_STARTUP time and accelerometer transition time
> + * from OFF respectively.
> + */
> + return regmap_read_poll_timeout(map, INV_ICM42607_REG_MCLK_RDY, val,
> + val & INV_ICM42607_MCLK_RDY_BIT, 10, 200);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-b4-inv_icm42370p-v3-0-77cc31642115@axis.com?part=6
next prev parent reply other threads:[~2026-09-01 14:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 14:35 [PATCH v3 0/8] Add support for InvenSense ICM-42370-P accelerometer Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 1/8] dt-bindings: Add InvenSense ICM-42370-p accelerometer Kanak Shilledar
2026-09-01 14:42 ` sashiko-bot
2026-09-01 14:35 ` [PATCH v3 2/8] iio: imu: inv_icm42607: Update IIO channel macros Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 3/8] iio: imu: inv_icm42607: Update _odr_to_period_us formatting Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 4/8] iio: imu: inv_icm42607: Switch to little endian Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 5/8] iio: imu: inv_icm42607: Add support for ICM-42370-P Kanak Shilledar
2026-09-01 14:35 ` [PATCH v3 6/8] iio: imu: inv_icm42607: Implement MREGx register access Kanak Shilledar
2026-09-01 14:47 ` sashiko-bot [this message]
2026-09-01 14:36 ` [PATCH v3 7/8] iio: imu: inv_icm42607: Add accelerometer calibbias support Kanak Shilledar
2026-09-01 14:49 ` sashiko-bot
2026-09-01 14:36 ` [PATCH v3 8/8] iio: imu: inv_icm42607: Add gyroscope " Kanak Shilledar
2026-09-02 5:30 ` [PATCH v3 0/8] Add support for InvenSense ICM-42370-P accelerometer Andy Shevchenko
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=20260901144731.AA53A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kanak.shilledar@axis.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