All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls
@ 2026-09-16  7:50 Joshua Crofts
  2026-09-16  8:01 ` sashiko-bot
  2026-09-16  9:27 ` Johan Hovold
  0 siblings, 2 replies; 3+ messages in thread
From: Joshua Crofts @ 2026-09-16  7:50 UTC (permalink / raw)
  To: Boris Breyillon, Rob Herring, Steven Price, Adrián Larumbe,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Dave Airlie,
	Simona Vetter
  Cc: dri-devel, linux-kernel, stable

panfrost_remove() and panfrost_probe() disable PM runtime on teardown or
failure but don't call the pm_runtime_dont_use_autosuspend() function,
causing potential resource leaks.

Add the missing function calls.

Found using Coccinelle.

Fixes: 5c0c825ae4c6 ("drm/panfrost: Replace DRM driver allocation method with newer one")
Cc: <stable@vger.kernel.org>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
index 36cc2e67a308..74e8e5783f9b 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -1012,6 +1012,7 @@ static int panfrost_probe(struct platform_device *pdev)
 err_out2:
 	drm_dev_unregister(&pfdev->base);
 err_out1:
+	pm_runtime_dont_use_autosuspend(pfdev->base.dev);
 	pm_runtime_disable(pfdev->base.dev);
 	panfrost_device_fini(pfdev);
 	pm_runtime_set_suspended(pfdev->base.dev);
@@ -1027,6 +1028,7 @@ static void panfrost_remove(struct platform_device *pdev)
 	panfrost_gem_shrinker_cleanup(&pfdev->base);
 
 	pm_runtime_get_sync(pfdev->base.dev);
+	pm_runtime_dont_use_autosuspend(pfdev->base.dev);
 	pm_runtime_disable(pfdev->base.dev);
 	panfrost_device_fini(pfdev);
 	pm_runtime_set_suspended(pfdev->base.dev);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls
  2026-09-16  7:50 [PATCH] drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
@ 2026-09-16  8:01 ` sashiko-bot
  2026-09-16  9:27 ` Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-09-16  8:01 UTC (permalink / raw)
  To: Joshua Crofts; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/panfrost: fatal SError crash in probe error path due to synchronous suspend
--

commit 0a02f30e746f195b71331259b1584b0eadbe399f
Author: Joshua Crofts <joshua.crofts1@gmail.com>

drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls

This commit adds missing pm_runtime_dont_use_autosuspend() calls in
panfrost_remove() and panfrost_probe() to prevent potential resource leaks
on teardown or failure.

> diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
> index 96a66d673ba60..67652f6c8647d 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
> @@ -1012,6 +1012,7 @@ static int panfrost_probe(struct platform_device *pdev)
>  err_out2:
>  	drm_dev_unregister(&pfdev->base);
>  err_out1:
> +	pm_runtime_dont_use_autosuspend(pfdev->base.dev);

[Severity: High]
Does calling pm_runtime_dont_use_autosuspend() here cause a synchronous
suspend of the hardware?

Since pm_runtime_get_sync() wasn't called in this error path (unlike in
panfrost_remove()), the usage count is 0. Clearing the autosuspend flag
triggers a synchronous rpm_idle(), which executes the runtime suspend
callback and disables the GPU clocks and power domains.

Right after this, panfrost_device_fini() is called, which touches MMIO
registers when attempting to power off the GPU:

panfrost_probe() ->
  err_out1:
  pm_runtime_dont_use_autosuspend()
  ...
  panfrost_device_fini() ->
    panfrost_gpu_fini() ->
      panfrost_gpu_power_off()

Will accessing these MMIO registers while the device clocks are disabled
trigger a bus abort (SError) and cause a kernel panic?

Would it be safer to call pm_runtime_get_sync() before
pm_runtime_dont_use_autosuspend() in this error path, similar to how it is
handled in panfrost_remove(), or perhaps move the call after
pm_runtime_disable()?

>  	pm_runtime_disable(pfdev->base.dev);
>  	panfrost_device_fini(pfdev);
>  	pm_runtime_set_suspended(pfdev->base.dev);

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916075051.1353-1-joshua.crofts1@gmail.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls
  2026-09-16  7:50 [PATCH] drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
  2026-09-16  8:01 ` sashiko-bot
@ 2026-09-16  9:27 ` Johan Hovold
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2026-09-16  9:27 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Boris Breyillon, Rob Herring, Steven Price, Adrián Larumbe,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Dave Airlie,
	Simona Vetter, dri-devel, linux-kernel, stable

On Wed, Sep 16, 2026 at 07:50:51AM +0000, Joshua Crofts wrote:
> panfrost_remove() and panfrost_probe() disable PM runtime on teardown or
> failure but don't call the pm_runtime_dont_use_autosuspend() function,
> causing potential resource leaks.

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.

> Add the missing function calls.
> 
> Found using Coccinelle.
> 
> Fixes: 5c0c825ae4c6 ("drm/panfrost: Replace DRM driver allocation method with newer one")
> Cc: <stable@vger.kernel.org>

And it does not need to be backported.

> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>

Johan

[1] https://lore.kernel.org/all/aqpd3viN1UoZBkgL@hovoldconsulting.com/
[2] https://lore.kernel.org/linux-iio/aow51Nk-cet9qaUQ@hovoldconsulting.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-17  7:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16  7:50 [PATCH] drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
2026-09-16  8:01 ` sashiko-bot
2026-09-16  9:27 ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.