* [PATCH] iio: imu: inv_icm45600: fix regulator put warning when probe fails
@ 2026-02-05 13:35 Jean-Baptiste Maneyrol via B4 Relay
2026-02-05 16:19 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-02-05 13:35 UTC (permalink / raw)
To: Remi Buisson, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko
Cc: Jonathan Cameron, linux-iio, linux-kernel, Jean-Baptiste Maneyrol,
stable
From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
When the driver probe fails we encounter a regulator put warning
because vddio regulator is not stopped before release. The issue
comes from pm_runtime not already setup when core probe fails and
the vddio regulator disable callback is called.
Fix the issue by deleting pm_runtime check in the vddio regulator
disable callback and handing over the vddio disable management to
pm_runtime by deleting the disable remove action before setting up
pm_runtime.
Fixes: 7ff021a3faca ("iio: imu: inv_icm45600: add new inv_icm45600 driver")
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Cc: stable@vger.kernel.org
---
drivers/iio/imu/inv_icm45600/inv_icm45600_core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c b/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
index ab1cb7b9dba435a3280e50ab77cd16e903c7816c..18d613a025cb4f9cbb8d73f27a46fc1207f5820d 100644
--- a/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
+++ b/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
@@ -676,10 +676,6 @@ static int inv_icm45600_enable_regulator_vddio(struct inv_icm45600_state *st)
static void inv_icm45600_disable_vddio_reg(void *_data)
{
struct inv_icm45600_state *st = _data;
- struct device *dev = regmap_get_device(st->map);
-
- if (pm_runtime_status_suspended(dev))
- return;
regulator_disable(st->vddio_supply);
}
@@ -780,6 +776,8 @@ int inv_icm45600_core_probe(struct regmap *regmap, const struct inv_icm45600_chi
if (ret)
return ret;
+ /* hand over vddio management to pm_runtime */
+ devm_remove_action(dev, inv_icm45600_disable_vddio_reg, st);
pm_runtime_get_noresume(dev);
pm_runtime_set_autosuspend_delay(dev, 2 * USEC_PER_MSEC);
pm_runtime_use_autosuspend(dev);
---
base-commit: d820183f371d9aa8517a1cd21fe6edacf0f94b7f
change-id: 20260205-inv-icm45600-fix-regulator-put-warning-7c45a49c4c53
Best regards,
--
Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: imu: inv_icm45600: fix regulator put warning when probe fails
2026-02-05 13:35 [PATCH] iio: imu: inv_icm45600: fix regulator put warning when probe fails Jean-Baptiste Maneyrol via B4 Relay
@ 2026-02-05 16:19 ` Andy Shevchenko
2026-02-05 17:19 ` Jean-Baptiste Maneyrol
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2026-02-05 16:19 UTC (permalink / raw)
To: jean-baptiste.maneyrol
Cc: Remi Buisson, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Jonathan Cameron, linux-iio, linux-kernel,
stable
On Thu, Feb 05, 2026 at 02:35:33PM +0100, Jean-Baptiste Maneyrol via B4 Relay wrote:
> When the driver probe fails we encounter a regulator put warning
> because vddio regulator is not stopped before release. The issue
> comes from pm_runtime not already setup when core probe fails and
> the vddio regulator disable callback is called.
>
> Fix the issue by deleting pm_runtime check in the vddio regulator
> disable callback and handing over the vddio disable management to
> pm_runtime by deleting the disable remove action before setting up
> pm_runtime.
...
> + /* hand over vddio management to pm_runtime */
> + devm_remove_action(dev, inv_icm45600_disable_vddio_reg, st);
First of all, note "remove" vs. "release". Have you tried to remove and insert
module several times? Does kmemleak happy about this?
Second, calling devm_*() for release resources is very exceptional situation.
This usually means that something is wrong to begin with in the probe.
Can you find a better way without calling devm_*() for releasing resources?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: imu: inv_icm45600: fix regulator put warning when probe fails
2026-02-05 16:19 ` Andy Shevchenko
@ 2026-02-05 17:19 ` Jean-Baptiste Maneyrol
2026-02-05 19:26 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Jean-Baptiste Maneyrol @ 2026-02-05 17:19 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Remi Buisson, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, Jonathan Cameron, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
>From: Andy Shevchenko <andriy.shevchenko@intel.com>
>Sent: Thursday, February 5, 2026 17:19
>To: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>
>Cc: Remi Buisson <Remi.Buisson@tdk.com>; Jonathan Cameron <jic23@kernel.org>; David Lechner <dlechner@baylibre.com>; Nuno Sá <nuno.sa@analog.com>; Andy Shevchenko <andy@kernel.org>; Jonathan Cameron <Jonathan.Cameron@huawei.com>; linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; stable@vger.kernel.org <stable@vger.kernel.org>
>Subject: Re: [PATCH] iio: imu: inv_icm45600: fix regulator put warning when probe fails
>
>On Thu, Feb 05, 2026 at 02: 35: 33PM +0100, Jean-Baptiste Maneyrol via B4 Relay wrote: > When the driver probe fails we encounter a regulator put warning > because vddio regulator is not stopped before release. The issue > comes from
>ZjQcmQRYFpfptBannerStart
>This Message Is From an External Sender
>This message came from outside your organization.
>
>ZjQcmQRYFpfptBannerEnd
>On Thu, Feb 05, 2026 at 02:35:33PM +0100, Jean-Baptiste Maneyrol via B4 Relay wrote:
>
>> When the driver probe fails we encounter a regulator put warning
>> because vddio regulator is not stopped before release. The issue
>> comes from pm_runtime not already setup when core probe fails and
>> the vddio regulator disable callback is called.
>>
>> Fix the issue by deleting pm_runtime check in the vddio regulator
>> disable callback and handing over the vddio disable management to
>> pm_runtime by deleting the disable remove action before setting up
>> pm_runtime.
>
>...
>
>> + /* hand over vddio management to pm_runtime */
>> + devm_remove_action(dev, inv_icm45600_disable_vddio_reg, st);
>
>First of all, note "remove" vs. "release". Have you tried to remove and insert
>module several times? Does kmemleak happy about this?
Hello Andy,
remove is used on purpose, since we want to avoid disabling the vddio regulator
here.
The problem we are facing here is that vddio regulator disable is handle by 2
different resource managements: manually with devm_ and with pm_runtime. It
is needed because we want pm_runtime to be able to disable vddio when the chip
is suspended. And we also want to avoid the manual vddio disable during the
driver probe for code clarity. To prevent vddio regulator to be disabled 2 times
when the driver unloads, the manual vddio disable has a check on pm_runtime.
But when there is an issue in probe (like chip not responding), the vddio
disable callback is not working correctly because pm_runtime has not been setup.
The most easiest way to fix this is to remove the devm vddio disable when
pm_runtime is setup to avoid any double free resources. pm_runtime will disable
vddio, thus there is no risk of resource leak.
Hope I'm clear enough.
Thanks,
JB
>
>Second, calling devm_*() for release resources is very exceptional situation.
>This usually means that something is wrong to begin with in the probe.
>
>Can you find a better way without calling devm_*() for releasing resources?
>
>--
>With Best Regards,
>Andy Shevchenko
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: imu: inv_icm45600: fix regulator put warning when probe fails
2026-02-05 17:19 ` Jean-Baptiste Maneyrol
@ 2026-02-05 19:26 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2026-02-05 19:26 UTC (permalink / raw)
To: Jean-Baptiste Maneyrol
Cc: Andy Shevchenko, Remi Buisson, David Lechner, Nuno Sá,
Andy Shevchenko, Jonathan Cameron, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
On Thu, 5 Feb 2026 17:19:28 +0000
Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com> wrote:
> >From: Andy Shevchenko <andriy.shevchenko@intel.com>
> >Sent: Thursday, February 5, 2026 17:19
> >To: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>
> >Cc: Remi Buisson <Remi.Buisson@tdk.com>; Jonathan Cameron <jic23@kernel.org>; David Lechner <dlechner@baylibre.com>; Nuno Sá <nuno.sa@analog.com>; Andy Shevchenko <andy@kernel.org>; Jonathan Cameron <Jonathan.Cameron@huawei.com>; linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; stable@vger.kernel.org <stable@vger.kernel.org>
> >Subject: Re: [PATCH] iio: imu: inv_icm45600: fix regulator put warning when probe fails
> >
> >On Thu, Feb 05, 2026 at 02: 35: 33PM +0100, Jean-Baptiste Maneyrol via B4 Relay wrote: > When the driver probe fails we encounter a regulator put warning > because vddio regulator is not stopped before release. The issue > comes from
> >ZjQcmQRYFpfptBannerStart
> >This Message Is From an External Sender
> >This message came from outside your organization.
> >
> >ZjQcmQRYFpfptBannerEnd
> >On Thu, Feb 05, 2026 at 02:35:33PM +0100, Jean-Baptiste Maneyrol via B4 Relay wrote:
> >
> >> When the driver probe fails we encounter a regulator put warning
> >> because vddio regulator is not stopped before release. The issue
> >> comes from pm_runtime not already setup when core probe fails and
> >> the vddio regulator disable callback is called.
> >>
> >> Fix the issue by deleting pm_runtime check in the vddio regulator
> >> disable callback and handing over the vddio disable management to
> >> pm_runtime by deleting the disable remove action before setting up
> >> pm_runtime.
> >
> >...
> >
> >> + /* hand over vddio management to pm_runtime */
> >> + devm_remove_action(dev, inv_icm45600_disable_vddio_reg, st);
> >
> >First of all, note "remove" vs. "release". Have you tried to remove and insert
> >module several times? Does kmemleak happy about this?
>
> Hello Andy,
>
> remove is used on purpose, since we want to avoid disabling the vddio regulator
> here.
>
> The problem we are facing here is that vddio regulator disable is handle by 2
> different resource managements: manually with devm_ and with pm_runtime. It
> is needed because we want pm_runtime to be able to disable vddio when the chip
> is suspended. And we also want to avoid the manual vddio disable during the
> driver probe for code clarity. To prevent vddio regulator to be disabled 2 times
> when the driver unloads, the manual vddio disable has a check on pm_runtime.
> But when there is an issue in probe (like chip not responding), the vddio
> disable callback is not working correctly because pm_runtime has not been setup.
I'm curious that pm_runtime_status_suspend() returns true under those circumstances.
ah. pm_runtime_init() does that. It's a bit ugly but maybe a commented
extra all to pm_runtime_set_active() before registering the devm callback to turn
the power off?
>
> The most easiest way to fix this is to remove the devm vddio disable when
> pm_runtime is setup to avoid any double free resources. pm_runtime will disable
> vddio, thus there is no risk of resource leak.
This is making life rather complex. Also what happens if runtime PM is not
configured into the kernel?
I'm really not keen on using devm then ripping it out again. That just
makes a mess of the ordering.
These devm / runtime pm interactions are rather unfortunate.
Jonathan
>
> Hope I'm clear enough.
>
> Thanks,
> JB
>
> >
> >Second, calling devm_*() for release resources is very exceptional situation.
> >This usually means that something is wrong to begin with in the probe.
> >
> >Can you find a better way without calling devm_*() for releasing resources?
> >
> >--
> >With Best Regards,
> >Andy Shevchenko
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-05 19:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-05 13:35 [PATCH] iio: imu: inv_icm45600: fix regulator put warning when probe fails Jean-Baptiste Maneyrol via B4 Relay
2026-02-05 16:19 ` Andy Shevchenko
2026-02-05 17:19 ` Jean-Baptiste Maneyrol
2026-02-05 19:26 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox