Skip to contentSkip to conversation

clk: imx: add missing pm_runtime_dont_use_autosuspend() calls

PATCH In review Joshua Crofts 3 participants 12 messages Sep 15 – Sep 18

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover clk: imx: add missing pm_runtime_dont_use_autosuspend() calls

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

The offending drivers were found using a semantic patch for Coccinelle I'm working on [1].

[1] https://lore.kernel.org/all/[email protected]/

Joshua Crofts (2):
clk: imx: clk-imx8qxp-lpcg: add missing
pm_runtime_dont_use_autosuspend()
clk: imx: scu: add missing pm_runtime_dont_use_autosuspend() call

 drivers/clk/imx/clk-imx8qxp-lpcg.c | 1 +
 drivers/clk/imx/clk-scu.c          | 2 ++
 2 files changed, 3 insertions(+)
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/2 clk: imx: clk-imx8qxp-lpcg: add missing pm_runtime_dont_use_autosuspend()

imx_lpcg_parse_clks_from_dt() disables PM runtime but doesn't call the pm_runtime_dont_use_autosuspend() function, causing potential resource leaks.

Add the missing function call.

Found using Coccinelle.

Fixes 18cdbad40c6c ("clk: imx: clk-imx8qxp-lpcg: add runtime pm support")
---
 drivers/clk/imx/clk-imx8qxp-lpcg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/imx/clk-imx8qxp-lpcg.c +1 -0
index f0cf6cf91899..b31903060361 100644
@@ -279,6 +279,7 @@ static int imx_lpcg_parse_clks_from_dt(struct platform_device *pdev,
 	}
 
 	pm_runtime_disable(&pdev->dev);
+	pm_runtime_dont_use_autosuspend(&pdev->dev);
 
 	return ret;
 }
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/2 clk: imx: scu: add missing pm_runtime_dont_use_autosuspend() call

In reply to Joshua Crofts

imx_clk_scu_probe() disables PM runtime on failure, but doesn't call the pm_runtime_dont_use_autosuspend() function, causing potential resource leaks.

Add the missing function calls.

Found using Coccinelle.

Fixes 18a50f82cd2f ("clk: imx: scu: Do not enable runtime PM for CPU clks")
Fixes 78edeb080330 ("clk: imx: scu: add runtime pm support")
---
 drivers/clk/imx/clk-scu.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clk/imx/clk-scu.c +2 -0
index 44220e9c5c2a..18f73e679331 100644
@@ -525,6 +525,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
 		if (ret) {
 			pm_genpd_remove_device(dev);
 			pm_runtime_disable(dev);
+			pm_runtime_dont_use_autosuspend(dev);
 			return ret;
 		}
 	}
@@ -533,6 +534,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
 			   clk->rsrc, clk->clk_type);
 	if (IS_ERR(hw)) {
 		pm_runtime_disable(dev);
+		pm_runtime_dont_use_autosuspend(dev);
 		return PTR_ERR(hw);
 	}
 
Signature · 1 line
2.47.3
#3 lore raw
In reply to Joshua Crofts
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Johan

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/linux-iio/[email protected]/

#4 lore raw
Quoted 8 lines · Johan Hovold
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

Quoted 6 lines

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Is it possilbe to create/improve runtime pm API, let runtime_pm enable/disable include these pair functions.

I get many similar patches since scan tools is more powerful now.

Frank

Quoted 6 lines

Johan

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/linux-iio/[email protected]/

#5 lore raw
Quoted 13 lines · On Wed, 16 Sep 2026 11:11:54 -0500 Frank Li <[email protected]> wrote:
Quoted 12 lines · Johan Hovold
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

Quoted 7 lines
Quoted 2 lines

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Is it possilbe to create/improve runtime pm API, let runtime_pm enable/disable include these pair functions.

I get many similar patches since scan tools is more powerful now.

I suppose that could work. One would still have to scrub the kernel of legacy use/dont_use_autosuspend() calls though, so it could end up being a large patchset.

Signature · 2 lines
Kind regards,
Joshua Crofts
#6 lore raw
Quoted 19 lines · On Thu, 17 Sep 2026 10:24:29 +0200 Joshua Crofts <[email protected]>…
Quoted 16 lines · On Wed, 16 Sep 2026 11:11:54 -0500 Frank Li <[email protected]> wrote:
Quoted 14 lines · Johan Hovold
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Quoted 9 lines
Quoted 4 lines

Is it possilbe to create/improve runtime pm API, let runtime_pm enable/disable include these pair functions.

I get many similar patches since scan tools is more powerful now.

I suppose that could work. One would still have to scrub the kernel of legacy use/dont_use_autosuspend() calls though, so it could end up being a large patchset.

On second thought, some drivers do tend to disable PM runtime system sleep etc. so it probably isn't as simple as adding the autosuspend stuff to enable/disable.

Signature · 2 lines
Kind regards,
Joshua Crofts
#7 lore raw
Quoted 27 lines · Joshua Crofts
Quoted 24 lines · On Thu, 17 Sep 2026 10:24:29 +0200 Joshua Crofts <[email protected]>…
Quoted 20 lines · On Wed, 16 Sep 2026 11:11:54 -0500 Frank Li <[email protected]> wrote:
Quoted 8 lines · Johan Hovold
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

Quoted 6 lines

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Is it possilbe to create/improve runtime pm API, let runtime_pm enable/disable include these pair functions.

I get many similar patches since scan tools is more powerful now.

Quoted 8 lines
Quoted 4 lines

I suppose that could work. One would still have to scrub the kernel of legacy use/dont_use_autosuspend() calls though, so it could end up being a large patchset.

On second thought, some drivers do tend to disable PM runtime system sleep etc. so it probably isn't as simple as adding the autosuspend stuff to enable/disable.

if runtime pm disable, does autosuspend still work? suppose it should be disable also

Frank

Quoted 4 lines

--
Kind regards,
Joshua Crofts

#8 lore raw
Quoted 34 lines · Frank Li
Quoted 32 lines · Joshua Crofts
Quoted 28 lines · On Thu, 17 Sep 2026 10:24:29 +0200 Joshua Crofts <[email protected]>…
Quoted 13 lines · On Wed, 16 Sep 2026 11:11:54 -0500 Frank Li <[email protected]> wrote:
Quoted 12 lines · Johan Hovold
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

Quoted 7 lines
Quoted 2 lines

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Is it possilbe to create/improve runtime pm API, let runtime_pm enable/disable include these pair functions.

I get many similar patches since scan tools is more powerful now.

I suppose that could work. One would still have to scrub the kernel of legacy use/dont_use_autosuspend() calls though, so it could end up being a large patchset.

Quoted 6 lines
Quoted 3 lines

On second thought, some drivers do tend to disable PM runtime system sleep etc. so it probably isn't as simple as adding the autosuspend stuff to enable/disable.

if runtime pm disable, does autosuspend still work? suppose it should be disable also

If we add dont_use_autosuspend to disable then every time the system suspends and resumes we lose the autosuspend config, meaning it will never autosuspend again.

I guess adding dont_use manually to the driver's remove() function is the only way (which according to my cocci script it's 195 drivers that should be patched)

--
Kind regards,
Joshua Crofts

#9 lore raw
Quoted 42 lines · Joshua Crofts
Quoted 34 lines · Frank Li
Quoted 32 lines · Joshua Crofts
Quoted 28 lines · On Thu, 17 Sep 2026 10:24:29 +0200 Joshua Crofts <[email protected]>…
Quoted 13 lines · On Wed, 16 Sep 2026 11:11:54 -0500 Frank Li <[email protected]> wrote:
Quoted 12 lines · Johan Hovold
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

Quoted 7 lines
Quoted 2 lines

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Is it possilbe to create/improve runtime pm API, let runtime_pm enable/disable include these pair functions.

I get many similar patches since scan tools is more powerful now.

I suppose that could work. One would still have to scrub the kernel of legacy use/dont_use_autosuspend() calls though, so it could end up being a large patchset.

Quoted 6 lines
Quoted 3 lines

On second thought, some drivers do tend to disable PM runtime system sleep etc. so it probably isn't as simple as adding the autosuspend stuff to enable/disable.

if runtime pm disable, does autosuspend still work? suppose it should be disable also

Quoted 6 lines

If we add dont_use_autosuspend to disable then every time the system suspends and resumes we lose the autosuspend config, meaning it will never autosuspend again.

I guess adding dont_use manually to the driver's remove() function is the only way (which according to my cocci script it's 195 drivers that should be patched)

Extend with exist pm_runtime_enable() and passdown delay value. if delay value is 0, actually it is no autosuspend version.

and merge dont_use_autosuspend() into disable function. And actually I don't understand why need two varible autosuspend_delay and use_autosuspend.

when autosuspend_delay 0, means take action immediately.

Frank

Quoted 4 lines

--
Kind regards,
Joshua Crofts

#10 lore raw
Quoted 50 lines · On Thu, 17 Sep 2026 13:36:11 -0500 Frank Li <[email protected]> wrote:
Quoted 42 lines · Joshua Crofts
Quoted 34 lines · Frank Li
Quoted 32 lines · Joshua Crofts
Quoted 28 lines · On Thu, 17 Sep 2026 10:24:29 +0200 Joshua Crofts <[email protected]>…
Quoted 13 lines · On Wed, 16 Sep 2026 11:11:54 -0500 Frank Li <[email protected]> wrote:
Quoted 12 lines · Johan Hovold
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

Quoted 7 lines
Quoted 2 lines

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Is it possilbe to create/improve runtime pm API, let runtime_pm enable/disable include these pair functions.

I get many similar patches since scan tools is more powerful now.

I suppose that could work. One would still have to scrub the kernel of legacy use/dont_use_autosuspend() calls though, so it could end up being a large patchset.

Quoted 6 lines
Quoted 3 lines

On second thought, some drivers do tend to disable PM runtime system sleep etc. so it probably isn't as simple as adding the autosuspend stuff to enable/disable.

if runtime pm disable, does autosuspend still work? suppose it should be disable also

Quoted 6 lines

If we add dont_use_autosuspend to disable then every time the system suspends and resumes we lose the autosuspend config, meaning it will never autosuspend again.

I guess adding dont_use manually to the driver's remove() function is the only way (which according to my cocci script it's 195 drivers that should be patched)

Quoted 7 lines

Extend with exist pm_runtime_enable() and passdown delay value. if delay value is 0, actually it is no autosuspend version.

and merge dont_use_autosuspend() into disable function. And actually I don't understand why need two varible autosuspend_delay and use_autosuspend.

when autosuspend_delay 0, means take action immediately.

Actually, what about putting dont_use_autosuspend() in pm_runtime_reinit()?
https://elixir.bootlin.com/linux/v7.3-rc3/source/drivers/base/power/runtime.c#L1865

driver core calls this in device_unbind_cleanup(), meaning driver core would just handle it.

Signature · 2 lines
Kind regards,
Joshua Crofts
#11 lore raw
Quoted 59 lines · Joshua Crofts
Quoted 56 lines · On Thu, 17 Sep 2026 13:36:11 -0500 Frank Li <[email protected]> wrote:
Quoted 42 lines · Joshua Crofts
Quoted 34 lines · Frank Li
Quoted 32 lines · Joshua Crofts
Quoted 28 lines · On Thu, 17 Sep 2026 10:24:29 +0200 Joshua Crofts <[email protected]>…
Quoted 13 lines · On Wed, 16 Sep 2026 11:11:54 -0500 Frank Li <[email protected]> wrote:
Quoted 12 lines · Johan Hovold
Quoted 3 lines · Joshua Crofts

Several drivers in the clk subsystem forget to call dont_use_autosuspend() on teardown or error, causing potential resource leaks. This series adds the missing calls.

No, as I've explained repeatedly elsewhere, it does not cause any resource leaks. [1][2]

The autosuspend setting leaks if you will, but that only matters in the theoretical corner case of someone rebinding a different driver (which will soon also taint the kernel).

Quoted 7 lines
Quoted 2 lines

So don't exaggerate the impact, this is essentially just a cleanup, which is fine in itself.

Is it possilbe to create/improve runtime pm API, let runtime_pm enable/disable include these pair functions.

I get many similar patches since scan tools is more powerful now.

I suppose that could work. One would still have to scrub the kernel of legacy use/dont_use_autosuspend() calls though, so it could end up being a large patchset.

Quoted 6 lines
Quoted 3 lines

On second thought, some drivers do tend to disable PM runtime system sleep etc. so it probably isn't as simple as adding the autosuspend stuff to enable/disable.

if runtime pm disable, does autosuspend still work? suppose it should be disable also

Quoted 6 lines

If we add dont_use_autosuspend to disable then every time the system suspends and resumes we lose the autosuspend config, meaning it will never autosuspend again.

I guess adding dont_use manually to the driver's remove() function is the only way (which according to my cocci script it's 195 drivers that should be patched)

Extend with exist pm_runtime_enable() and passdown delay value. if delay value is 0, actually it is no autosuspend version.

and merge dont_use_autosuspend() into disable function. And actually I don't understand why need two varible autosuspend_delay and use_autosuspend.

Quoted 7 lines
Quoted 1 line

when autosuspend_delay 0, means take action immediately.

Actually, what about putting dont_use_autosuspend() in pm_runtime_reinit()?
https://elixir.bootlin.com/linux/v7.3-rc3/source/drivers/base/power/runtime.c#L1865

driver core calls this in device_unbind_cleanup(), meaning driver core would just handle it.

Yes, much better.

Frank

Quoted 4 lines

--
Kind regards,
Joshua Crofts