diff mbox series

[RFC,06/14] drm/sched: Ignore own fence earlier

Message ID 20241230165259.95855-7-tursulin@igalia.com (mailing list archive)
State New
Headers show
Series Deadline scheduler and other ideas | expand

Commit Message

Tvrtko Ursulin Dec. 30, 2024, 4:52 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>

If a job depends on another job from the same context it will be naturally
ordered by the submission queue. We can therefore ignore those before
adding them to the dependency tracking xarray.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@redhat.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <pstanner@redhat.com>
---
 drivers/gpu/drm/scheduler/sched_entity.c | 11 -----------
 drivers/gpu/drm/scheduler/sched_main.c   | 12 ++++++++++++
 2 files changed, 12 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index b93da068585e..2c342c7b9712 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -412,17 +412,6 @@  static bool drm_sched_entity_add_dependency_cb(struct drm_sched_entity *entity)
 	struct dma_fence *fence = entity->dependency;
 	struct drm_sched_fence *s_fence;
 
-	if (fence->context == entity->fence_context ||
-	    fence->context == entity->fence_context + 1) {
-		/*
-		 * Fence is a scheduled/finished fence from a job
-		 * which belongs to the same entity, we can ignore
-		 * fences from ourself
-		 */
-		dma_fence_put(entity->dependency);
-		return false;
-	}
-
 	s_fence = to_drm_sched_fence(fence);
 	if (!fence->error && s_fence && s_fence->sched == sched &&
 	    !test_bit(DRM_SCHED_FENCE_DONT_PIPELINE, &fence->flags)) {
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 5c92784bb533..34ed22c6482e 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -648,6 +648,7 @@  EXPORT_SYMBOL(drm_sched_job_arm);
 int drm_sched_job_add_dependency(struct drm_sched_job *job,
 				 struct dma_fence *fence)
 {
+	struct drm_sched_entity *entity = job->entity;
 	struct dma_fence *entry;
 	unsigned long index;
 	u32 id = 0;
@@ -656,6 +657,17 @@  int drm_sched_job_add_dependency(struct drm_sched_job *job,
 	if (!fence)
 		return 0;
 
+	if (fence->context == entity->fence_context ||
+	    fence->context == entity->fence_context + 1) {
+		/*
+		 * Fence is a scheduled/finished fence from a job
+		 * which belongs to the same entity, we can ignore
+		 * fences from ourself
+		 */
+		dma_fence_put(fence);
+		return 0;
+	}
+
 	/* Deduplicate if we already depend on a fence from the same context.
 	 * This lets the size of the array of deps scale with the number of
 	 * engines involved, rather than the number of BOs.