On 12/2/26 12:40, Boris Brezillon wrote:
On Wed, 2 Dec 2026 09:11:02 +0000 Tvrtko Ursulin tursulin@ursulin.net wrote:
On 02/12/2026 09:00, Boris Brezillon wrote:
All dependencies get added through drm_sched_job_add_dependency() or variants that call drm_sched_job_add_dependency() internally. At this point, the job is already attached an entity, and we can do the same-entity check there, so we don't insert the fence in the XArray in the first place.
Note that we keep the elimination logic in drm_sched_entity_add_dependency_cb() too, because dependencies returned by ::prepare_job() could also potentially be coming from the same entity.
Signed-off-by: Boris Brezillon boris.brezillon@collabora.com
drivers/gpu/drm/scheduler/sched_entity.c | 8 +------- drivers/gpu/drm/scheduler/sched_main.c | 5 +++++ include/drm/gpu_scheduler.h | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c index 03e68b4102d5..39419b3ac552 100644 --- a/drivers/gpu/drm/scheduler/sched_entity.c +++ b/drivers/gpu/drm/scheduler/sched_entity.c @@ -473,13 +473,7 @@ 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*/
- if (drm_sched_entity_can_skip_dependency(entity, fence)) { dma_fence_put(entity->dependency); return false; }
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 85a49e219837..5f123a5e39ff 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -678,6 +678,11 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job, if (!fence) return 0;
- if (drm_sched_entity_can_skip_dependency(job->entity, fence)) {
dma_fence_put(fence);return 0;I thought we could be braver and unwrap, snipping at the root much more than just the plain fences. As written it is not super exciting, but I am also not saying the two have to come together. It can be considered as a follow up.
IIRC I tried that once and it caused problems.
The background was that you have cases where you need to have a CPU round trip between submissions to the same engine because the run_job() callback needed the information from the previous submission to correctly stitch together the current one.
I then later cleaned that up by introducing the DRM_SCHED_FENCE_DONT_PIPELINE flag, so it should work now but please keep in mind that this might cause regressions.
Regards, Christian.
Just sent a new version introducing a drm_sched_job_add_dependency_unwrapped() helper so drivers don't have to do that manually. Sorry for the fast iteration rate BTW, but I oscillate between mesa and kernel a lot these days, and every time I leave something unfinished on the kernel side it tends to rot and eventually fall through cracks, so I thought this time I'd try to push this through as fast as possible, especially since there seems to be no controversy on the proposed changes. Please let me know if you want me to slow things down a bit.
linaro-mm-sig@lists.linaro.org