From: Jonathan Cameron <jic23@kernel.org>
To: Sean Nyekjaer <sean@geanix.com>
Cc: "Jean-Baptiste Maneyrol" <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
Subject: Re: [PATCH 4/6] iio: imu: inv_icm42600: Simplify pm_runtime setup
Date: Wed, 16 Jul 2025 09:00:10 +0100 [thread overview]
Message-ID: <20250716090010.23ea03b6@jic23-huawei> (raw)
In-Reply-To: <76fnxeuufv56fmfvq6odi5xz2yjtjxymz24t436zk7rtuyst4s@oihlvsoxhllp>
On Mon, 14 Jul 2025 07:42:43 +0000
Sean Nyekjaer <sean@geanix.com> wrote:
> On Mon, Jul 14, 2025 at 07:24:57AM +0100, Sean Nyekjaer wrote:
> > On Sun, Jul 13, 2025 at 03:28:10PM +0100, Jonathan Cameron wrote:
> > > On Wed, 09 Jul 2025 14:35:12 +0200
> > > Sean Nyekjaer <sean@geanix.com> wrote:
> > >
> > > > Remove unnecessary pm_runtime_get_noresume() and pm_runtime_put()
> > > > calls during probe. These are not required when the device is marked
> > > > active via pm_runtime_set_active() before enabling pm_runtime with
> > > > pm_runtime_enable().
> > > >
> > > > Also remove the redundant pm_runtime_put_sync() call from the cleanup
> > > > path, since the core is not incrementing the usage count beforehand.
> > > >
> > > > This simplifies the PM setup and avoids manipulating the usage counter
> > > > unnecessarily.
> > >
> > > Could we switch directly to using devm_pm_runtime_enable() for this driver?
> > >
> > > At first glance looks like this code is missing the disable of autosuspend
> > > that should be there (which devm_pm_runtime_enable() will also handle).
> > >
> >
> > I have tried to use devm_pm_runtime_enable() but on rmmod it warns
> > "unbalanced disables for regulator"
> >
> > If I remove this:
> > - ret = devm_add_action_or_reset(dev, inv_icm42600_disable_vddio_reg, st);
> > - if (ret)
> > - return ret;
> >
> > Everything seems okay again. I have checked with printk's that
> > inv_icm42600_disable_vddio_reg() is called twice with
> > devm_pm_runtime_enable() used.
> > Does it make sense?
> >
> > /Sean
>
> with pm_runtime_enable():
> root@v4:/data/root# insmod /tmp/inv-icm42600.ko; insmod /tmp/inv-icm42600-i2c.ko
> [ 3793.713077] inv-icm42600-i2c 1-0068: no INT1 interrupt defined, fallback to first interrupt
> [ 3793.727728] inv-icm42600-i2c 1-0068: mounting matrix not found: using identity...
> [ 3793.737660] inv-icm42600-i2c 1-0068: supply vdd not found, using dummy regulator
> [ 3793.856891] inv-icm42600-i2c 1-0068: supply vddio not found, using dummy regulator
> [ 3793.866872] inv_icm42600_enable_regulator_vddio() enable vddio
> [ 3793.920739] inv_icm42600_runtime_suspend() disable vddio
> root@v4:/data/root# rmmod inv_icm42600_i2c inv_icm42600
> [ 3796.954850] inv_icm42600_runtime_resume() -> inv_icm42600_enable_regulator_vddio()
> [ 3796.954910] inv_icm42600_enable_regulator_vddio() enable vddio
> [ 3796.985140] inv_icm42600_disable_vddio_reg() disable vddio
>
> with devm_pm_runtime_enable():
> root@v4:/data/root# insmod /tmp/inv-icm42600.ko; insmod /tmp/inv-icm42600-i2c.ko
> [ 3852.873887] inv-icm42600-i2c 1-0068: no INT1 interrupt defined, fallback to first interrupt
> [ 3852.888715] inv-icm42600-i2c 1-0068: mounting matrix not found: using identity...
> [ 3852.898514] inv-icm42600-i2c 1-0068: supply vdd not found, using dummy regulator
> [ 3853.016890] inv-icm42600-i2c 1-0068: supply vddio not found, using dummy regulator
> [ 3853.026860] inv_icm42600_enable_regulator_vddio() enable vddio
> [ 3853.080835] inv_icm42600_runtime_suspend() disable vddio
> root@v4:/data/root# rmmod inv_icm42600_i2c inv_icm42600
> [ 3854.448461] inv_icm42600_runtime_resume() -> inv_icm42600_enable_regulator_vddio()
> [ 3854.448540] inv_icm42600_enable_regulator_vddio() enable vddio
> [ 3854.467061] inv_icm42600_runtime_suspend() disable vddio
As below What is the call path for this final suspend?
Is it coming from update_autosuspend()?
> [ 3854.477170] inv_icm42600_disable_vddio_reg() disable vddio
> [ 3854.483835] ------------[ cut here ]------------
> [ 3854.483912] WARNING: CPU: 0 PID: 582 at drivers/regulator/core.c:3016 _regulator_disable+0x140/0x1a0
> [ 3854.497853] unbalanced disables for regulator
>
> Is the way from here to remove the devm_add_action_or_reset(dev,
> inv_icm42600_disable_vddio_reg... ?
That will make a mess if runtime PM is not built into
the kernel which is why an PM state in remove should return to the state
before it was enabled in the first place (i.e. on!).
That final runtime suspend surprises me.
>
> /Sean
>
next prev parent reply other threads:[~2025-07-16 8:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 12:35 [PATCH 0/6] iio: imu: inv_icm42600: pm_runtime fixes + various changes Sean Nyekjaer
2025-07-09 12:35 ` [PATCH 1/6] iio: imu: inv_icm42600: Use inv_icm42600_disable_vddio_reg() Sean Nyekjaer
2025-07-13 14:17 ` Jonathan Cameron
2025-07-09 12:35 ` [PATCH 2/6] iio: imu: inv_icm42600: Use devm_regulator_get_enable() for vdd regulator Sean Nyekjaer
2025-07-13 14:19 ` Jonathan Cameron
2025-07-09 12:35 ` [PATCH 3/6] iio: imu: inv_icm42600: Remove redundant error msg on regulator_disable() Sean Nyekjaer
2025-07-10 9:03 ` Andy Shevchenko
2025-07-10 10:47 ` Sean Nyekjaer
2025-07-10 13:07 ` Andy Shevchenko
2025-07-13 14:22 ` Jonathan Cameron
2025-07-09 12:35 ` [PATCH 4/6] iio: imu: inv_icm42600: Simplify pm_runtime setup Sean Nyekjaer
2025-07-10 9:08 ` Andy Shevchenko
2025-07-10 10:45 ` Sean Nyekjaer
2025-07-10 12:23 ` Andy Shevchenko
2025-07-13 14:28 ` Jonathan Cameron
2025-07-14 7:24 ` Sean Nyekjaer
2025-07-14 7:42 ` Sean Nyekjaer
2025-07-16 8:00 ` Jonathan Cameron [this message]
2025-07-18 6:40 ` Sean Nyekjaer
2025-07-19 11:47 ` Jonathan Cameron
2025-07-19 13:32 ` Jonathan Cameron
2025-08-08 13:42 ` Sean Nyekjaer
2025-07-09 12:35 ` [PATCH 5/6] iio: imu: inv_icm42600: Drop redundant pm_runtime reinitialization in resume Sean Nyekjaer
2025-07-09 12:35 ` [PATCH 6/6] iio: imu: inv_icm42600: Avoid configuring if already pm_runtime suspended Sean Nyekjaer
2025-07-10 9:11 ` Andy Shevchenko
2025-07-13 14:32 ` Jonathan Cameron
2025-07-14 10:15 ` Sean Nyekjaer
2025-07-16 8:06 ` Jonathan Cameron
2025-07-10 9:12 ` [PATCH 0/6] iio: imu: inv_icm42600: pm_runtime fixes + various changes 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=20250716090010.23ea03b6@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jean-baptiste.maneyrol@tdk.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--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