[PATCH v4 14/17] drm/panfrost: Keep the GPU powered in the job timeout handler

From: Arun Iyengar via B4 Relay

Date: Thu Nov 26 2026 - 04:38:48 EST


From: Arun Iyengar <aiyengar1990@xxxxxxxxx>

panfrost_job_timedout() accesses the GPU without a runtime PM reference
of its own. If the job completes after the fence check, the GPU can
autosuspend first (clocks off on GPU_PM_RT). Take a reference with
pm_runtime_get_noresume(): if the fence is still unsignalled after
that, the job's own reference was held.

Tested on an H616 with a test-only wait after the fence check: before,
the GPU suspended 50 ms after the fence; after, it stayed active.

Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver")
Cc: stable@xxxxxxxxxxxxxxx
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/sashiko-outbox-212575@xxxxxxxxxx/
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
v4: new.
---
drivers/gpu/drm/panfrost/panfrost_job.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
index 722f87ebe..74cc3dd02 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -775,8 +775,8 @@ panfrost_reset(struct panfrost_device *pfdev,
dma_fence_end_signalling(cookie);
}

-static enum drm_gpu_sched_stat panfrost_job_timedout(struct drm_sched_job
- *sched_job)
+static enum drm_gpu_sched_stat
+panfrost_job_handle_timeout(struct drm_sched_job *sched_job)
{
struct panfrost_job *job = to_panfrost_job(sched_job);
struct panfrost_device *pfdev = job->pfdev;
@@ -821,6 +821,19 @@ static enum drm_gpu_sched_stat panfrost_job_timedout(struct drm_sched_job
return DRM_GPU_SCHED_STAT_RESET;
}

+static enum drm_gpu_sched_stat panfrost_job_timedout(struct drm_sched_job
+ *sched_job)
+{
+ struct panfrost_device *pfdev = to_panfrost_job(sched_job)->pfdev;
+ enum drm_gpu_sched_stat stat;
+
+ pm_runtime_get_noresume(pfdev->base.dev);
+ stat = panfrost_job_handle_timeout(sched_job);
+ pm_runtime_put_autosuspend(pfdev->base.dev);
+
+ return stat;
+}
+
static void panfrost_reset_work(struct work_struct *work)
{
struct panfrost_device *pfdev;

--
2.55.0