On Tue, 2026-12-01 at 14:58 +0100, Boris Brezillon wrote:
> If a job is passed a dependency that's coming from the same queue the
> job is targeting, we can get rid of the dependency because of the
> implicit serialization provided by the queue.

Shouldn't drm_sched be doing that already? See below.

Am I understanding correctly that someone sets a dependency for
something on the same userspace context, not merely relying on FIFO
behavior?

JobQueue currently is not deadlock-resistant against that because I
expected drivers to ignore such deps.

> 
> 

[…]

>  
> +static bool can_skip_dep(const struct drm_sched_job *job, struct dma_fence 
> *fence)
> +{
> +     if (!fence)
> +             return true;
> +
> +     /* This fence comes from our queue, and the serialization happening at
> +      * the queue level makes it so we can skip the CPU wait.
> +      */
> +     if (fence->context == job->entity->fence_context ||
> +         fence->context == job->entity->fence_context + 1)
> +             return true;
> +

[…]

> +             if (can_skip_dep(job, fence)) {
> +                     dma_fence_put(fence);

drm_sched does:

static bool drm_sched_entity_add_dependency_cb(struct drm_sched_entity *entity,
                                               struct drm_sched_job *sched_job)
{
        struct drm_gpu_scheduler *sched = entity->rq->sched;
        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;
        }



I seem to be missing something, because at first glance drm_sched
should ignore your added dependencies.


P.

Reply via email to