All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/panfrost: fix stuck reset.pending on JOB_BUS_FAULT
@ 2026-11-19 19:10 ThePedroo
  2026-11-19 19:28 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: ThePedroo @ 2026-11-19 19:10 UTC (permalink / raw)
  To: dri-devel
  Cc: Boris Brezillon, Rob Herring, Steven Price, Adrián Larumbe,
	linux-kernel

From: Pedro Olímpio <pedro@performanc.org>

panfrost_job_handle_err() signals job->done_fence and then calls
drm_sched_fault(), which just queues the scheduler timeout work.
panfrost_job_timedout() bails with DRM_GPU_SCHED_STAT_NO_HANG when it
sees the already-signaled fence:

	if (dma_fence_is_signaled(job->done_fence))
		return DRM_GPU_SCHED_STAT_NO_HANG;

so the reset never runs and reset.pending stays stuck at 1. Every
later job is then enqueued in pfdev->jobs but never started ian
panfrost_job_hw_submit(), until it hits the 500ms timeout.

Queue the existing ordered reset work instead, which runs
panfrost_reset() unconditionally (when pending is set), even though
the fence was already signaled.

Fixes: 030761e097b4 ("drm/panfrost: Queue jobs on the hardware")
Signed-off-by: Pedro Olímpio <pedro@performanc.org>
---
 drivers/gpu/drm/panfrost/panfrost_job.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
index d59b4863b8ad..8c45ffec1107 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -497,10 +497,8 @@ static void panfrost_job_handle_err(struct panfrost_device *pfdev,
 
 	pm_runtime_put_autosuspend(pfdev->base.dev);
 
-	if (panfrost_exception_needs_reset(pfdev, js_status)) {
-		atomic_set(&pfdev->reset.pending, 1);
-		drm_sched_fault(&pfdev->js->queue[js].sched);
-	}
+	if (panfrost_exception_needs_reset(pfdev, js_status))
+		panfrost_device_schedule_reset(pfdev);
 }
 
 static void panfrost_jm_handle_done(struct panfrost_device *pfdev,
-- 
2.53.0

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

* Re: [PATCH] drm/panfrost: fix stuck reset.pending on JOB_BUS_FAULT
  2026-11-19 19:10 [PATCH] drm/panfrost: fix stuck reset.pending on JOB_BUS_FAULT ThePedroo
@ 2026-11-19 19:28 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-19 19:28 UTC (permalink / raw)
  To: ThePedroo, dri-devel

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/panfrost: use-after-free in panfrost_jm_fini() [1]
--

commit 425df48a8a39ab3673476c8b751250446dcc35c8
Author: Pedro Olímpio <pedro@performanc.org>

drm/panfrost: fix stuck reset.pending on JOB_BUS_FAULT

This commit replaces the drm_sched_fault() call in panfrost_job_handle_err()
with panfrost_device_schedule_reset() so that a GPU reset runs even after
job->done_fence has been signaled.

> diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
> index 3a46dd61cf87f..3c3107d706795 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_job.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_job.c
> @@ -499,10 +499,8 @@ static void panfrost_job_handle_err(struct panfrost_device *pfdev,
>  
>  	pm_runtime_put_autosuspend(pfdev->base.dev);
>  
> -	if (panfrost_exception_needs_reset(pfdev, js_status)) {
> -		atomic_set(&pfdev->reset.pending, 1);
> -		drm_sched_fault(&pfdev->js->queue[js].sched);
> -	}
> +	if (panfrost_exception_needs_reset(pfdev, js_status))
> +		panfrost_device_schedule_reset(pfdev);
>  }
>  
>  static void panfrost_jm_handle_done(struct panfrost_device *pfdev,

[Severity: Critical]
This problem wasn't introduced by this patch, but can a pending
pfdev->reset.work item race with panfrost_jm_fini() [1] and access
js->queue[j].sched after drm_sched_fini()?

drivers/gpu/drm/panfrost/panfrost_job.c:panfrost_jm_fini() {
    ...
	for (j = 0; j < NUM_JOB_SLOTS; j++) {
		drm_sched_fini(&js->queue[j].sched);
	}

	disable_work_sync(&pfdev->reset.work);
    ...
}

CPU0                                    CPU1 (pfdev->reset.wq)
panfrost_jm_fini()
  drm_sched_fini(&js->queue[j].sched)
                                        panfrost_reset()
                                          drm_sched_stop() <-- use-after-free
  disable_work_sync(&pfdev->reset.work)

If a reset queued via panfrost_device_schedule_reset() runs during driver
teardown before disable_work_sync() cancels it, panfrost_reset() calls
drm_sched_stop() on the already finalized scheduler.

[1] https://sashiko.dev/#/bug/linux-3c56dd27-0f33-4f82-a144-72279b21c756

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/a3b7a3f3-4da6-4a41-b842-cf9778dd7ba1@performanc.org?part=1

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

end of thread, other threads:[~2026-11-19 19:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:10 [PATCH] drm/panfrost: fix stuck reset.pending on JOB_BUS_FAULT ThePedroo
2026-11-19 19:28 ` sashiko-bot

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.