* [PATCH] PM: runtime: call pm_runtime_dont_use_autosuspend() on reinit()
@ 2026-09-19 8:24 Joshua Crofts
2026-09-25 19:50 ` Rafael J. Wysocki (Intel)
0 siblings, 1 reply; 2+ messages in thread
From: Joshua Crofts @ 2026-09-19 8:24 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Danilo Krummrich
Cc: linux-pm, driver-core, linux-kernel, Frank Li, Joshua Crofts
Add a pm_runtime_dont_use_autosuspend() call to pm_runtime_reinit() to
ensure autosuspend is disabled on driver teardown.
Suggested-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
If a driver doesn't use devm_* functions for automatic cleanup on
teardown and autosuspend is enabled during probe, it should also be
disabled on teardown in a _remove() function or equivalent. However,
due to bad documentation, driver authors usually omit the
pm_runtime_dont_use_autosuspend() call on teardown.
Reason for investigating: this week, several patches popped up in
the linux-iio mailing list, adding these missing calls to several
IIO drivers. For some reason I ended up writing a cocci script to
find other instances of this and found ~195 offending drivers.
After a discussion with Frank Li on the matter [1] when sending a similar
patch adding these missing calls to the clk subsystem, we arrived to the
idea of actually adding the dont_use_autosuspend() call to
pm_runtime_reinit() and have driver core handle this instead of
submitting 195+ patches to amend the issue.
[1] https://lore.kernel.org/all/aq1N863eJpD_ZrLU@SMW015318/
---
drivers/base/power/runtime.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index fab38bc98113..9a37f6162fe0 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1874,6 +1874,9 @@ void pm_runtime_reinit(struct device *dev)
if (dev->power.runtime_status == RPM_ACTIVE)
pm_runtime_set_suspended(dev);
+ if (dev->power.use_autosuspend)
+ pm_runtime_dont_use_autosuspend(dev);
+
if (dev->power.irq_safe) {
spin_lock_irq(&dev->power.lock);
dev->power.irq_safe = 0;
---
base-commit: 40288c9206c17eb66a603262e06a58d300d0f279
change-id: 20260919-move-dont-use-autosuspend-0203336ca270
Best regards,
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PM: runtime: call pm_runtime_dont_use_autosuspend() on reinit()
2026-09-19 8:24 [PATCH] PM: runtime: call pm_runtime_dont_use_autosuspend() on reinit() Joshua Crofts
@ 2026-09-25 19:50 ` Rafael J. Wysocki (Intel)
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-09-25 19:50 UTC (permalink / raw)
To: Joshua Crofts
Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Danilo Krummrich, linux-pm, driver-core, linux-kernel, Frank Li
On Sat, Sep 19, 2026 at 10:25 AM Joshua Crofts <joshua.crofts1@gmail.com> wrote:
>
> Add a pm_runtime_dont_use_autosuspend() call to pm_runtime_reinit() to
> ensure autosuspend is disabled on driver teardown.
>
> Suggested-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
> ---
> If a driver doesn't use devm_* functions for automatic cleanup on
> teardown and autosuspend is enabled during probe, it should also be
> disabled on teardown in a _remove() function or equivalent. However,
> due to bad documentation, driver authors usually omit the
> pm_runtime_dont_use_autosuspend() call on teardown.
>
> Reason for investigating: this week, several patches popped up in
> the linux-iio mailing list, adding these missing calls to several
> IIO drivers. For some reason I ended up writing a cocci script to
> find other instances of this and found ~195 offending drivers.
>
> After a discussion with Frank Li on the matter [1] when sending a similar
> patch adding these missing calls to the clk subsystem, we arrived to the
> idea of actually adding the dont_use_autosuspend() call to
> pm_runtime_reinit() and have driver core handle this instead of
> submitting 195+ patches to amend the issue.
>
> [1] https://lore.kernel.org/all/aq1N863eJpD_ZrLU@SMW015318/
> ---
> drivers/base/power/runtime.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index fab38bc98113..9a37f6162fe0 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -1874,6 +1874,9 @@ void pm_runtime_reinit(struct device *dev)
> if (dev->power.runtime_status == RPM_ACTIVE)
> pm_runtime_set_suspended(dev);
>
> + if (dev->power.use_autosuspend)
> + pm_runtime_dont_use_autosuspend(dev);
> +
> if (dev->power.irq_safe) {
> spin_lock_irq(&dev->power.lock);
> dev->power.irq_safe = 0;
>
> ---
Applied as 7.4 material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-25 19:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 8:24 [PATCH] PM: runtime: call pm_runtime_dont_use_autosuspend() on reinit() Joshua Crofts
2026-09-25 19:50 ` Rafael J. Wysocki (Intel)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®