Re: [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper

From: Boris Brezillon

Date: Wed Dec 02 2026 - 08:47:41 EST


On Wed, 02 Dec 2026 13:53:58 +0100
Philipp Stanner <phasta@xxxxxxxxxxx> wrote:

> On Wed, 2026-12-02 at 12:34 +0100, Boris Brezillon wrote:
> >
>
> […]
>
> > +/**
> > + * drm_sched_job_add_dependency_unwrapped - unwrap the fence (if this is a
> > + * container) and add the resulting fences as job dependencies
> > + * @job: scheduler job to add the dependencies to
> > + * @fence: the dma_fence to add to the list of dependencies.
>
> Not entirely true, this is the container containing the dependencies,
> not the actual dependency. Right?

It can be both: if it's a container fence, it's what you say, but if
it's a singular fence, the fence is added directly to the XArray. It's a
bit hard to express that in a short sentence, unfortunately...

>
> Maybe just call it "dependencies" or "deps" and below "fence" then
> singular, "dep"?

Well, the fact it can be both a singular fence or a container makes me
think we should keep the naming vague enough to apply to both. When you
think about it, it is a single dependency we get passed. We just
extract non-container fences out of it when we're being passed a
container, and add the resulting fences get added the dep list.

>
> > + *
> > + * Note that @fence is consumed in both the success and error cases.
> > + *
> > + * Returns:
>
> same nit, "Return: "

Will fix.

>
> > + * 0 on success, or an error on failing to expand the array.
> > + */
> > +int drm_sched_job_add_dependency_unwrapped(struct drm_sched_job *job,
> > +    struct dma_fence *fence)
> > +{
> > + struct dma_fence *inner_fence;
> > + int ret;
> > +
> > + dma_fence_unwrap_for_each(inner_fence, fence) {
> > + ret = drm_sched_job_add_dependency(job, dma_fence_get(inner_fence));
> > + if (ret)
> > + break;
> > + }
> > +
> > + dma_fence_put(fence);
> > + return ret;
> > +}
> > +EXPORT_SYMBOL(drm_sched_job_add_dependency_unwrapped);
>
>
> But makes sense to me.
>
> With the docu:
>
> Reviewed-by: Philipp Stanner <phasta@xxxxxxxxxx>

Thanks for the review.

Boris