This is essentially part of drm_sched_dependency_optimized(), which only amdgpu seems to make use of. Use it a bit more. Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx> Cc: "Christian König" <christian.koenig@xxxxxxx> Cc: Daniel Vetter <daniel.vetter@xxxxxxxx> Cc: Luben Tuikov <luben.tuikov@xxxxxxx> Cc: Andrey Grodzovsky <andrey.grodzovsky@xxxxxxx> Cc: Alex Deucher <alexander.deucher@xxxxxxx> Cc: Jack Zhang <Jack.Zhang1@xxxxxxx> --- drivers/gpu/drm/scheduler/sched_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 370c336d383f..c31d7cf7df74 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -649,6 +649,13 @@ int drm_sched_job_await_fence(struct drm_sched_job *job, if (!fence) return 0; + /* if it's a fence from us it's guaranteed to be earlier */ + if (fence->context == job->entity->fence_context || + fence->context == job->entity->fence_context + 1) { + 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. -- 2.32.0.rc2