drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls
Subsystems (4)
PATCH 1/1 drm/panfrost: add missing pm_runtime_dont_use_autosuspend() calls
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.
--- drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/panfrost/panfrost_drv.c +2 -0
@@ -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);
Signature · 1 line
2.47.3
[email protected]
AI reviewThank 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 --
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 <[email protected]>
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.
drivers/gpu/drm/panfrost/panfrost_drv.c static int panfrost_probe(struct platform_device *pdev) · line 1015
Quoted 9 lines
drivers/gpu/drm/panfrost/panfrost_drv.c +1
-0@@ -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()?
Quoted 3 lines
drivers/gpu/drm/panfrost/panfrost_drv.c +0
-0pm_runtime_disable (pfdev->base.dev);panfrost_device_fini (pfdev);pm_runtime_set_suspended (pfdev->base.dev);
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 3 lines · Joshua Crofts
panfrost_remove()andpanfrost_probe()disable PM runtime on teardown or failure but don't call thepm_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.
Quoted 6 lines
Add the missing function calls.
Found using Coccinelle.
Fixes 5c0c825ae4c6 ("drm/panfrost: Replace DRM driver allocation method with newer one")Cc <[email protected]>
And it does not need to be backported.
Quoted 1 line
Signed-off-by Joshua Crofts <[email protected]>
Johan
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/linux-iio/[email protected]/
Adrián Larumbe
maintainerHi Joshua, thanks for the patch.
However, a fix for the same issue had been in the making for some time. It's already been upstreamed:e9672bf9382f ("drm/panfrost: Fix PM refcnt and autosuspend issues at device probe/remove")
Kind Regards,
Adrian
Quoted 37 lines · Joshua Crofts
panfrost_remove()andpanfrost_probe()disable PM runtime on teardown or failure but don't call thepm_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 <[email protected]>Signed-off-by Joshua Crofts <[email protected]>--- drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/panfrost/panfrost_drv.c +2
-0@@ -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);Signature · 1 line
2.47.3