Commit 059c2a79 authored by Matthew Brost's avatar Matthew Brost
Browse files

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: default avatarMatthew Auld <matthew.auld@intel.com>
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241021173512.1584248-1-matthew.brost@intel.com
parent c8b0acd6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+5 −4
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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);
}

+0 −1
Original line number Diff line number Diff line
@@ -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 {