From: Arun Iyengar <[email protected]>

panfrost_reset() stops the schedulers, which detaches them from the done
fences of the jobs on the GPU, then soft-stops the slots and handles the
pending interrupts. A job that completes in that window gets its done
fence signalled and its jc cleared. drm_sched_resubmit_jobs() then calls
panfrost_job_run(), which returns NULL for a job with no jc, and since
commit 03877d621db0 ("drm/scheduler: mark jobs without fence as
canceled") drm_sched_start() completes it with -ECANCELED, although it
did complete.

Return the job's done fence instead: drm_sched_start() finds it
signalled and completes the job with its status, 0 or the error
panfrost_job_handle_err() set for a job that was hard-stopped or
faulted.

This depends on the previous patch: without it, a job cancelled from
_NEXT and taken for done would now be reported as completed.

Found by code review (Sashiko) of "Soft-stop and resume a job that
outlives the timeout", which widens the window. Not reproduced.

Fixes: 03877d621db0 ("drm/scheduler: mark jobs without fence as canceled")
Cc: [email protected]
Reported-by: Sashiko <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Arun Iyengar <[email protected]>
---
 drivers/gpu/drm/panfrost/panfrost_job.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c 
b/drivers/gpu/drm/panfrost/panfrost_job.c
index 1bb70b07d..897743cb8 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -409,11 +409,11 @@ static struct dma_fence *panfrost_job_run(struct 
drm_sched_job *sched_job)
        if (unlikely(job->base.s_fence->finished.error))
                return NULL;
 
-       /* Nothing to execute: can happen if the job has finished while
-        * we were resetting the GPU.
+       /* The job has finished while we were resetting the GPU. Return its
+        * done fence: with no fence, drm_sched_start() cancels the job.
         */
        if (!job->jc)
-               return NULL;
+               return dma_fence_get(job->done_fence);
 
        fence = panfrost_fence_create(pfdev, slot);
        if (IS_ERR(fence))

-- 
2.55.0


Reply via email to