Yo Boris,

On Wed, 2026-12-02 at 12:34 +0100, 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

typo, attached *to* an entity

[…]

>       }
> diff --git a/drivers/gpu/drm/scheduler/sched_internal.h 
> b/drivers/gpu/drm/scheduler/sched_internal.h
> index 32d3ddb820be..b7afed36b915 100644
> --- a/drivers/gpu/drm/scheduler/sched_internal.h
> +++ b/drivers/gpu/drm/scheduler/sched_internal.h

Personally, I'm not a huge fan of code in headers anymore since it
makes finding things more bothersome than when it'd be concentrated in
sched_entity.c; but I'm not sure whether the kernel has a policy on
that.

> @@ -122,6 +122,26 @@ drm_sched_entity_is_ready(struct drm_sched_entity 
> *entity)
>       return true;
>  }
>  
> +/**
> + * drm_sched_entity_can_skip_dependency() - Check if a dependency can be 
> skipped.
> + * @entity: entity the dependency will be waited on

This reads confusing.

"entity for whose job the dependency will be set"?

> + * @fence: fence representing the dependency

Maybe call it dependency, or dep_fence?

> + *
> + * Returns true if the dependency can be skipped, false if it can't.

nit: Official kernel doc style says that the return statement should be
marked with "Return: "

> + */
> +static inline bool
> +drm_sched_entity_can_skip_dependency(struct drm_sched_entity *entity,
> +                                  struct dma_fence *fence)
> +{
> +     /*
> +      * Fence is a scheduled/finished fence from a job
> +      * which belongs to the same entity, we can ignore
> +      * fences from ourself
> +      */

nit:
since you're already touching it, maybe wrapp the comment to 80 chars?

> +     return fence->context == entity->fence_context ||
> +            fence->context == entity->fence_context + 1;
> +}
> +
>  void drm_sched_entity_stats_release(struct kref *kref);
>  
>  /**
> 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;
> +     }


But otherwise cool patch. Just the other day I had been wondering why
we do that check so late currently.


Philipp

Reply via email to