]> www.infradead.org Git - linux.git/commitdiff
drm/xe: Take ref to job's fence in arm
authorMatthew Brost <matthew.brost@intel.com>
Mon, 21 Oct 2024 17:35:12 +0000 (10:35 -0700)
committerMatthew Brost <matthew.brost@intel.com>
Wed, 23 Oct 2024 18:06:31 +0000 (11:06 -0700)
Take ref to job's fence in arm rather than run job. This ref is owned by
the drm scheduler so it makes sense to take the ref before handing over
the job to the scheduler. Also removes an atomic from the run job path.

Suggested-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241021173512.1584248-1-matthew.brost@intel.com
drivers/gpu/drm/xe/xe_execlist.c
drivers/gpu/drm/xe/xe_guc_submit.c
drivers/gpu/drm/xe/xe_sched_job.c
drivers/gpu/drm/xe/xe_sched_job_types.h

index f3b71fe7a96dcd3c91d56b9b52e65156d43d9582..a8c416a488129328eec2cd966f6ed6a26663ad55 100644 (file)
@@ -313,7 +313,7 @@ execlist_run_job(struct drm_sched_job *drm_job)
        q->ring_ops->emit_job(job);
        xe_execlist_make_active(exl);
 
-       return dma_fence_get(job->fence);
+       return job->fence;
 }
 
 static void execlist_job_free(struct drm_sched_job *drm_job)
index 2b6ac1de8ec031d40324f3b658b2d448d87b985e..d2dcc9afd223d0b966e376fd734db0cf0e68311d 100644 (file)
@@ -790,6 +790,7 @@ guc_exec_queue_run_job(struct drm_sched_job *drm_job)
        struct xe_exec_queue *q = job->q;
        struct xe_guc *guc = exec_queue_to_guc(q);
        struct xe_device *xe = guc_to_xe(guc);
+       struct dma_fence *fence = NULL;
        bool lr = xe_exec_queue_is_lr(q);
 
        xe_assert(xe, !(exec_queue_destroyed(q) || exec_queue_pending_disable(q)) ||
@@ -807,12 +808,12 @@ guc_exec_queue_run_job(struct drm_sched_job *drm_job)
 
        if (lr) {
                xe_sched_job_set_error(job, -EOPNOTSUPP);
-               return NULL;
-       } else if (test_and_set_bit(JOB_FLAG_SUBMIT, &job->fence->flags)) {
-               return job->fence;
+               dma_fence_put(job->fence);      /* Drop ref from xe_sched_job_arm */
        } else {
-               return dma_fence_get(job->fence);
+               fence = job->fence;
        }
+
+       return fence;
 }
 
 static void guc_exec_queue_free_job(struct drm_sched_job *drm_job)
index eeccc1c318aef12b7efe17bc63b1e33d13fb6abe..1905ca5909658bf37f939e2dbc412e3ebc8032b3 100644 (file)
@@ -280,7 +280,7 @@ void xe_sched_job_arm(struct xe_sched_job *job)
                fence = &chain->base;
        }
 
-       job->fence = fence;
+       job->fence = dma_fence_get(fence);      /* Pairs with put in scheduler */
        drm_sched_job_arm(&job->drm);
 }
 
index 426d261d7359c66ea51e1641c1cc4c17605ab476..f13f333f00bebdcade8846ec790354640c5bc67c 100644 (file)
@@ -40,7 +40,6 @@ struct xe_sched_job {
         * @fence: dma fence to indicate completion. 1 way relationship - job
         * can safely reference fence, fence cannot safely reference job.
         */
-#define JOB_FLAG_SUBMIT                DMA_FENCE_FLAG_USER_BITS
        struct dma_fence *fence;
        /** @user_fence: write back value when BB is complete */
        struct {