Re: [PATCH v7 09/17] drm/panfrost: Fix PM refcnt and autosuspend issues at device probe/remove
From: Boris Brezillon
Date: Tue Sep 01 2026 - 09:46:32 EST
On Fri, 28 Aug 2026 21:56:49 +0100
Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx> wrote:
> During device probe(), failure to do a PM get() will leave the usage_count
> set to 0, which is the value assigned at device creation time. That means
> when the autosuspend delay expires, runtime suspend callback won't be
> invoked, so the device will remain powered on forever.
>
> On top of that, failure to call PM put() during device unplug means
> Panfrost device's PM usage_count increases monotonically for every new
> module reload.
>
> The combined outcome of both of the above was that devfreq OPP transition
> notifications would be printed all the time, even when no jobs are being
> submitted. This quickly fills the kernel ring buffer with junk.
>
> To fix the above:
> - Manually adjust the PM refcnt at device probe and removal time.
> - Ensure pm_runtime_dont_use_autosuspend is called in the wind-down path.
> - Call pm_runtime_put_autosuspend() when device is ready to accept jobs
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx>
> Fixes: 635430797d3f ("drm/panfrost: Rework runtime PM initialization")
> Fixes: 876b15d2c88d ("drm/panfrost: Fix module unload")
Because of how things are currently ordered, this won't be backportable
without patch 2, which doesn't have a Fixes tag, so, either we put the
fix first, and then we move code, or we make it a single commit.
> ---
> drivers/gpu/drm/panfrost/panfrost_device.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
> index 99f7da2180f9..70c8109ea698 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.c
> @@ -322,6 +322,7 @@ int panfrost_device_init(struct panfrost_device *pfdev)
>
> pm_runtime_set_active(pfdev->base.dev);
> pm_runtime_mark_last_busy(pfdev->base.dev);
> + pm_runtime_get_noresume(pfdev->base.dev);
> pm_runtime_enable(pfdev->base.dev);
> pm_runtime_set_autosuspend_delay(pfdev->base.dev, 50); /* ~3 frames */
> pm_runtime_use_autosuspend(pfdev->base.dev);
> @@ -334,9 +335,13 @@ int panfrost_device_init(struct panfrost_device *pfdev)
> if (err < 0)
> goto out_devreg;
>
> + pm_runtime_put_autosuspend(pfdev->base.dev);
> +
> return 0;
>
> out_devreg:
> + pm_runtime_dont_use_autosuspend(pfdev->base.dev);
> + pm_runtime_put_noidle(pfdev->base.dev);
> pm_runtime_disable(pfdev->base.dev);
> panfrost_device_disable_hw(pfdev);
> panfrost_gem_fini(pfdev);
> @@ -363,7 +368,9 @@ int panfrost_device_init(struct panfrost_device *pfdev)
> void panfrost_device_fini(struct panfrost_device *pfdev)
> {
> pm_runtime_get_sync(pfdev->base.dev);
> + pm_runtime_dont_use_autosuspend(pfdev->base.dev);
> pm_runtime_disable(pfdev->base.dev);
> + pm_runtime_put_noidle(pfdev->base.dev);
>
> panfrost_jm_stop_sched_jobs(pfdev);
> panfrost_device_disable_hw(pfdev);
>