Skip to content

Commit 059c2a7

Browse files
committed
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 <[email protected]> Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c8b0acd commit 059c2a7

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

drivers/gpu/drm/xe/xe_execlist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ execlist_run_job(struct drm_sched_job *drm_job)
313313
q->ring_ops->emit_job(job);
314314
xe_execlist_make_active(exl);
315315

316-
return dma_fence_get(job->fence);
316+
return job->fence;
317317
}
318318

319319
static void execlist_job_free(struct drm_sched_job *drm_job)

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ guc_exec_queue_run_job(struct drm_sched_job *drm_job)
790790
struct xe_exec_queue *q = job->q;
791791
struct xe_guc *guc = exec_queue_to_guc(q);
792792
struct xe_device *xe = guc_to_xe(guc);
793+
struct dma_fence *fence = NULL;
793794
bool lr = xe_exec_queue_is_lr(q);
794795

795796
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)
807808

808809
if (lr) {
809810
xe_sched_job_set_error(job, -EOPNOTSUPP);
810-
return NULL;
811-
} else if (test_and_set_bit(JOB_FLAG_SUBMIT, &job->fence->flags)) {
812-
return job->fence;
811+
dma_fence_put(job->fence); /* Drop ref from xe_sched_job_arm */
813812
} else {
814-
return dma_fence_get(job->fence);
813+
fence = job->fence;
815814
}
815+
816+
return fence;
816817
}
817818

818819
static void guc_exec_queue_free_job(struct drm_sched_job *drm_job)

drivers/gpu/drm/xe/xe_sched_job.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ void xe_sched_job_arm(struct xe_sched_job *job)
280280
fence = &chain->base;
281281
}
282282

283-
job->fence = fence;
283+
job->fence = dma_fence_get(fence); /* Pairs with put in scheduler */
284284
drm_sched_job_arm(&job->drm);
285285
}
286286

drivers/gpu/drm/xe/xe_sched_job_types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct xe_sched_job {
4040
* @fence: dma fence to indicate completion. 1 way relationship - job
4141
* can safely reference fence, fence cannot safely reference job.
4242
*/
43-
#define JOB_FLAG_SUBMIT DMA_FENCE_FLAG_USER_BITS
4443
struct dma_fence *fence;
4544
/** @user_fence: write back value when BB is complete */
4645
struct {

0 commit comments

Comments
 (0)