Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe: Take ref to job's fence in arm

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

+7 -7
+1 -1
drivers/gpu/drm/xe/xe_execlist.c
··· 313 313 q->ring_ops->emit_job(job); 314 314 xe_execlist_make_active(exl); 315 315 316 - return dma_fence_get(job->fence); 316 + return job->fence; 317 317 } 318 318 319 319 static void execlist_job_free(struct drm_sched_job *drm_job)
+5 -4
drivers/gpu/drm/xe/xe_guc_submit.c
··· 790 790 struct xe_exec_queue *q = job->q; 791 791 struct xe_guc *guc = exec_queue_to_guc(q); 792 792 struct xe_device *xe = guc_to_xe(guc); 793 + struct dma_fence *fence = NULL; 793 794 bool lr = xe_exec_queue_is_lr(q); 794 795 795 796 xe_assert(xe, !(exec_queue_destroyed(q) || exec_queue_pending_disable(q)) || ··· 808 807 809 808 if (lr) { 810 809 xe_sched_job_set_error(job, -EOPNOTSUPP); 811 - return NULL; 812 - } else if (test_and_set_bit(JOB_FLAG_SUBMIT, &job->fence->flags)) { 813 - return job->fence; 810 + dma_fence_put(job->fence); /* Drop ref from xe_sched_job_arm */ 814 811 } else { 815 - return dma_fence_get(job->fence); 812 + fence = job->fence; 816 813 } 814 + 815 + return fence; 817 816 } 818 817 819 818 static void guc_exec_queue_free_job(struct drm_sched_job *drm_job)
+1 -1
drivers/gpu/drm/xe/xe_sched_job.c
··· 280 280 fence = &chain->base; 281 281 } 282 282 283 - job->fence = fence; 283 + job->fence = dma_fence_get(fence); /* Pairs with put in scheduler */ 284 284 drm_sched_job_arm(&job->drm); 285 285 } 286 286
-1
drivers/gpu/drm/xe/xe_sched_job_types.h
··· 40 40 * @fence: dma fence to indicate completion. 1 way relationship - job 41 41 * can safely reference fence, fence cannot safely reference job. 42 42 */ 43 - #define JOB_FLAG_SUBMIT DMA_FENCE_FLAG_USER_BITS 44 43 struct dma_fence *fence; 45 44 /** @user_fence: write back value when BB is complete */ 46 45 struct {