[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ie3zr2mvuss2f7prksw6nuc3wonig5ju6y6hqq46upvkhovwpa@vtfc3tqwz3d5>
Date: Mon, 14 Jul 2025 07:24:57 +0000
From: Sean Nyekjaer <sean@...nix.com>
To: Jonathan Cameron <jic23@...nel.org>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@....com>, David Lechner <dlechner@...libre.com>, Nuno Sá <nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/6] iio: imu: inv_icm42600: Simplify pm_runtime setup
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@...nix.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
>
> >
> > Fixes: 31c24c1e93c3 ("iio: imu: inv_icm42600: add core of new inv_icm42600 driver")
> > Signed-off-by: Sean Nyekjaer <sean@...nix.com>
> > ---
> > drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
> > index 55a29b1e2b11355598b0ede7af22857aed3ae134..1072bea11c73d09a9a0e6ea9d4a5c7a72248dca7 100644
> > --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
> > +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
> > @@ -708,7 +708,6 @@ static void inv_icm42600_disable_pm(void *_data)
> > {
> > struct device *dev = _data;
> >
> > - pm_runtime_put_sync(dev);
> > pm_runtime_disable(dev);
> > }
> >
> > @@ -806,11 +805,10 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip,
> > ret = pm_runtime_set_active(dev);
> > if (ret)
> > return ret;
> > - pm_runtime_get_noresume(dev);
> > +
> > pm_runtime_enable(dev);
> > pm_runtime_set_autosuspend_delay(dev, INV_ICM42600_SUSPEND_DELAY_MS);
> > pm_runtime_use_autosuspend(dev);
> > - pm_runtime_put(dev);
> >
> > return devm_add_action_or_reset(dev, inv_icm42600_disable_pm, dev);
> > }
> >
>
Powered by blists - more mailing lists