* [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time
2026-12-02 11:34 [PATCH v4 0/3] drm/panthor: Improve job pipelining Boris Brezillon
@ 2026-12-02 11:34 ` Boris Brezillon
2026-12-02 11:44 ` Philipp Stanner
2026-12-02 12:37 ` Philipp Stanner
2026-12-02 11:34 ` [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper Boris Brezillon
2026-12-02 11:34 ` [PATCH v4 3/3] drm/panthor: Explode container fences to optimize pipelining Boris Brezillon
2 siblings, 2 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-02 11:34 UTC (permalink / raw)
To: Steven Price, Liviu Dudau, Akash Goel, Karunika Choo,
Lukas Zapolskas, Chris Diamand
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Sumit Semwal, Christian König,
Philipp Stanner, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li, Boris Brezillon
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_internal.h | 20 ++++++++++++++++++++
drivers/gpu/drm/scheduler/sched_main.c | 5 +++++
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_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
@@ -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
+ * @fence: fence representing the dependency
+ *
+ * Returns true if the dependency can be skipped, false if it can't.
+ */
+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
+ */
+ 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;
+ }
+
/* 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.56.1
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time
2026-12-02 11:34 ` [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time Boris Brezillon
@ 2026-12-02 11:44 ` Philipp Stanner
2026-12-02 12:20 ` Boris Brezillon
2026-12-02 12:37 ` Philipp Stanner
1 sibling, 1 reply; 11+ messages in thread
From: Philipp Stanner @ 2026-12-02 11:44 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Liviu Dudau, Akash Goel,
Karunika Choo, Lukas Zapolskas, Chris Diamand
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Sumit Semwal, Christian König,
Philipp Stanner, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li
I don't want to appear overly nitty, but could we follow the "wait 24
hours before submitting new revisions" rule?
Our inboxes aren't getting smaller these days…
Thanks
Philipp
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
> 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>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time
2026-12-02 11:44 ` Philipp Stanner
@ 2026-12-02 12:20 ` Boris Brezillon
0 siblings, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-02 12:20 UTC (permalink / raw)
To: Philipp Stanner
Cc: phasta, Steven Price, Liviu Dudau, Akash Goel, Karunika Choo,
Lukas Zapolskas, Chris Diamand, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Sumit Semwal,
Christian König, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li
Hi Philipp,
On Wed, 02 Dec 2026 12:44:39 +0100
Philipp Stanner <phasta@mailbox.org> wrote:
> I don't want to appear overly nitty, but could we follow the "wait 24
> hours before submitting new revisions" rule?
Duly noted. I guess I'll go back to my other stuff and forget about
this, again. Xianzhong, if this is blocker for you, can you or someone
in your team push this forward?
Thanks,
Boris
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time
2026-12-02 11:34 ` [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time Boris Brezillon
2026-12-02 11:44 ` Philipp Stanner
@ 2026-12-02 12:37 ` Philipp Stanner
2026-12-02 13:36 ` Boris Brezillon
1 sibling, 1 reply; 11+ messages in thread
From: Philipp Stanner @ 2026-12-02 12:37 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Liviu Dudau, Akash Goel,
Karunika Choo, Lukas Zapolskas, Chris Diamand
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Sumit Semwal, Christian König,
Philipp Stanner, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li
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
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time
2026-12-02 12:37 ` Philipp Stanner
@ 2026-12-02 13:36 ` Boris Brezillon
0 siblings, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-02 13:36 UTC (permalink / raw)
To: Philipp Stanner
Cc: phasta, Steven Price, Liviu Dudau, Akash Goel, Karunika Choo,
Lukas Zapolskas, Chris Diamand, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Sumit Semwal,
Christian König, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li
Hi Philipp,
On Wed, 02 Dec 2026 13:37:34 +0100
Philipp Stanner <phasta@mailbox.org> wrote:
> 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
Will fix.
>
> […]
>
> > }
> > 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.
For such simple helpers, it lets the compiler inline things directly
rather than relying on LTO to figure it out (note that if both users
were in sched_main.c, I would have put the helper there, but here we
have one caller in sched_main.c and the other one in sched_entity.c).
BTW, we have such inline helpers defined in header files spread
throughout the codebase, so I'd be surprised if it was
forbidden/discouraged. It's this sort of things where you have to trust
you own judgment (is the helper short enough, is this violating API
layering, ...). As for searching stuff in the code base, I think we
have good enough LSPs with decent IDE integration that it shouldn't
really be a problem. And for old school devs, "git grep to the rescue"
;-).
>
> > @@ -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"?
It's still confusing, I think, especially since there's no notion of
job at this level. How about "entity that waits on this dependency"?
>
> > + * @fence: fence representing the dependency
>
> Maybe call it dependency, or dep_fence?
I was just trying to be consistent with the existing helpers which name
this parameter "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: "
Will fix.
>
> > + */
> > +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?
Sure, I can do that.
>
> > + 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.
Thanks for the review.
Boris
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper
2026-12-02 11:34 [PATCH v4 0/3] drm/panthor: Improve job pipelining Boris Brezillon
2026-12-02 11:34 ` [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time Boris Brezillon
@ 2026-12-02 11:34 ` Boris Brezillon
2026-12-02 12:21 ` Boris Brezillon
2026-12-02 12:53 ` Philipp Stanner
2026-12-02 11:34 ` [PATCH v4 3/3] drm/panthor: Explode container fences to optimize pipelining Boris Brezillon
2 siblings, 2 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-02 11:34 UTC (permalink / raw)
To: Steven Price, Liviu Dudau, Akash Goel, Karunika Choo,
Lukas Zapolskas, Chris Diamand
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Sumit Semwal, Christian König,
Philipp Stanner, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li, Boris Brezillon
drm_sched_job_add_dependency() adds the dependency as is to the job,
but drivers like to have containers unwrapped and each individual fence
added as a dependency so they can skip same-queue dependencies and
benefit from hardware pipelining.
We don't make this behavior the default to not regress the existing
drm_sched_job_add_dependency() users. Note that
drm_sched_job_add_{resv,implicit}_dependencies() don't need this
unwrapping because it already happened at resv update time. We could
add a drm_sched_job_add_syncobj_dependency_unwrapped() variant, but
there's no known user for that yet, so let's postpone this until
someone actually needs it.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
drivers/gpu/drm/scheduler/sched_main.c | 29 +++++++++++++++++++++++++++++
include/drm/gpu_scheduler.h | 2 ++
2 files changed, 31 insertions(+)
diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 5f123a5e39ff..6449d74b5218 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -66,6 +66,7 @@
* This implies waiting for previously executed jobs.
*/
+#include <linux/dma-fence-unwrap.h>
#include <linux/export.h>
#include <linux/wait.h>
#include <linux/sched.h>
@@ -708,6 +709,34 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job,
}
EXPORT_SYMBOL(drm_sched_job_add_dependency);
+/**
+ * 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.
+ *
+ * Note that @fence is consumed in both the success and error cases.
+ *
+ * Returns:
+ * 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);
+
/**
* drm_sched_job_add_syncobj_dependency - adds a syncobj's fence as a job dependency
* @job: scheduler job to add the dependencies to
diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
index 3b0978fa8cf0..5308f53d3168 100644
--- a/include/drm/gpu_scheduler.h
+++ b/include/drm/gpu_scheduler.h
@@ -694,6 +694,8 @@ void drm_sched_job_arm(struct drm_sched_job *job);
void drm_sched_entity_push_job(struct drm_sched_job *sched_job);
int drm_sched_job_add_dependency(struct drm_sched_job *job,
struct dma_fence *fence);
+int drm_sched_job_add_dependency_unwrapped(struct drm_sched_job *job,
+ struct dma_fence *fence);
int drm_sched_job_add_syncobj_dependency(struct drm_sched_job *job,
struct drm_file *file,
u32 handle,
--
2.56.1
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper
2026-12-02 11:34 ` [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper Boris Brezillon
@ 2026-12-02 12:21 ` Boris Brezillon
2026-12-02 12:53 ` Philipp Stanner
1 sibling, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-02 12:21 UTC (permalink / raw)
To: Steven Price, Liviu Dudau, Akash Goel, Karunika Choo,
Lukas Zapolskas, Chris Diamand
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Sumit Semwal, Christian König,
Philipp Stanner, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li
On Wed, 02 Dec 2026 12:34:18 +0100
Boris Brezillon <boris.brezillon@collabora.com> wrote:
> drm_sched_job_add_dependency() adds the dependency as is to the job,
> but drivers like to have containers unwrapped and each individual fence
> added as a dependency so they can skip same-queue dependencies and
> benefit from hardware pipelining.
>
> We don't make this behavior the default to not regress the existing
> drm_sched_job_add_dependency() users. Note that
> drm_sched_job_add_{resv,implicit}_dependencies() don't need this
> unwrapping because it already happened at resv update time. We could
> add a drm_sched_job_add_syncobj_dependency_unwrapped() variant, but
> there's no known user for that yet, so let's postpone this until
> someone actually needs it.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
> drivers/gpu/drm/scheduler/sched_main.c | 29 +++++++++++++++++++++++++++++
> include/drm/gpu_scheduler.h | 2 ++
> 2 files changed, 31 insertions(+)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 5f123a5e39ff..6449d74b5218 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -66,6 +66,7 @@
> * This implies waiting for previously executed jobs.
> */
>
> +#include <linux/dma-fence-unwrap.h>
> #include <linux/export.h>
> #include <linux/wait.h>
> #include <linux/sched.h>
> @@ -708,6 +709,34 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job,
> }
> EXPORT_SYMBOL(drm_sched_job_add_dependency);
>
> +/**
> + * 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.
> + *
> + * Note that @fence is consumed in both the success and error cases.
> + *
> + * Returns:
> + * 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;
For the record, missing ret = 0 initialization here.
> +
> + 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);
> +
> /**
> * drm_sched_job_add_syncobj_dependency - adds a syncobj's fence as a job dependency
> * @job: scheduler job to add the dependencies to
> diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
> index 3b0978fa8cf0..5308f53d3168 100644
> --- a/include/drm/gpu_scheduler.h
> +++ b/include/drm/gpu_scheduler.h
> @@ -694,6 +694,8 @@ void drm_sched_job_arm(struct drm_sched_job *job);
> void drm_sched_entity_push_job(struct drm_sched_job *sched_job);
> int drm_sched_job_add_dependency(struct drm_sched_job *job,
> struct dma_fence *fence);
> +int drm_sched_job_add_dependency_unwrapped(struct drm_sched_job *job,
> + struct dma_fence *fence);
> int drm_sched_job_add_syncobj_dependency(struct drm_sched_job *job,
> struct drm_file *file,
> u32 handle,
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper
2026-12-02 11:34 ` [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper Boris Brezillon
2026-12-02 12:21 ` Boris Brezillon
@ 2026-12-02 12:53 ` Philipp Stanner
2026-12-02 13:47 ` Boris Brezillon
1 sibling, 1 reply; 11+ messages in thread
From: Philipp Stanner @ 2026-12-02 12:53 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Liviu Dudau, Akash Goel,
Karunika Choo, Lukas Zapolskas, Chris Diamand
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Sumit Semwal, Christian König,
Philipp Stanner, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li
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?
Maybe just call it "dependencies" or "deps" and below "fence" then
singular, "dep"?
> + *
> + * Note that @fence is consumed in both the success and error cases.
> + *
> + * Returns:
same nit, "Return: "
> + * 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@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper
2026-12-02 12:53 ` Philipp Stanner
@ 2026-12-02 13:47 ` Boris Brezillon
0 siblings, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-02 13:47 UTC (permalink / raw)
To: Philipp Stanner
Cc: phasta, Steven Price, Liviu Dudau, Akash Goel, Karunika Choo,
Lukas Zapolskas, Chris Diamand, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Sumit Semwal,
Christian König, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li
On Wed, 02 Dec 2026 13:53:58 +0100
Philipp Stanner <phasta@mailbox.org> 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@kernel.org>
Thanks for the review.
Boris
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 3/3] drm/panthor: Explode container fences to optimize pipelining
2026-12-02 11:34 [PATCH v4 0/3] drm/panthor: Improve job pipelining Boris Brezillon
2026-12-02 11:34 ` [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time Boris Brezillon
2026-12-02 11:34 ` [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper Boris Brezillon
@ 2026-12-02 11:34 ` Boris Brezillon
2 siblings, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-02 11:34 UTC (permalink / raw)
To: Steven Price, Liviu Dudau, Akash Goel, Karunika Choo,
Lukas Zapolskas, Chris Diamand
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Sumit Semwal, Christian König,
Philipp Stanner, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li, Boris Brezillon
Use drm_sched_job_add_dependency_unwrapped() to benefit from the
fence-coming-from-same-queue eviction even when fence containers
are involved. In some cases, this allows to queue jobs more
agressively and benefit from the pipelining provided by the CS
ring buffer.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Xianzhong Li <xianzhong.li@nxp.com>
---
drivers/gpu/drm/panthor/panthor_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index dc8d0191aef4..d84ca3701bbb 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -7,6 +7,7 @@
#include <asm/arch_timer.h>
#endif
+#include <linux/dma-fence-unwrap.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/of_platform.h>
@@ -637,7 +638,7 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
return ret;
}
- ret = drm_sched_job_add_dependency(job, fence);
+ ret = drm_sched_job_add_dependency_unwrapped(job, fence);
if (ret)
return ret;
}
--
2.56.1
^ permalink raw reply [flat|nested] 11+ messages in thread