* [PATCH] drm/panthor: Skip job dependencies when we can
@ 2026-12-01 13:58 Boris Brezillon
2026-12-01 14:09 ` Philipp Stanner
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-01 13:58 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, Boris Brezillon, Xianzhong Li
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. This will allow us to take
benefit of the pipelining provided by the ring buffer (no extra
MCU <-> CPU round-trip to have the job pushed to the ring buffer).
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Xianzhong Li <xianzhong.li@nxp.com>
---
Some recent effort to improve job pipelining [1] showed that the
MCU <-> CPU round-trip that lets us signal job fences adds a
non-negligible overhead, and this problem seems to be easier and
more systematically fixed if it's addressed at the KMD side, so
here's a patch doing exactly that.
[1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
---
drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index dc8d0191aef4..cfffb9e2dec8 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -7,6 +7,8 @@
#include <asm/arch_timer.h>
#endif
+#include <linux/dma-fence-array.h>
+#include <linux/dma-fence-chain.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/of_platform.h>
@@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
}
}
+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 (dma_fence_is_chain(fence)) {
+ dma_fence_chain_for_each(fence, fence) {
+ if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
+ return false;
+ }
+
+ return true;
+ } else if (dma_fence_is_array(fence)) {
+ struct dma_fence *sub_fence;
+ u32 index;
+
+ dma_fence_array_for_each(sub_fence, index, fence) {
+ if (!can_skip_dep(job, sub_fence))
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
/**
* panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
* job dependencies.
@@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
return ret;
}
+ if (can_skip_dep(job, fence)) {
+ dma_fence_put(fence);
+ continue;
+ }
+
ret = drm_sched_job_add_dependency(job, fence);
if (ret)
return ret;
---
base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056
change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7
Best regards,
--
Boris Brezillon <boris.brezillon@collabora.com>
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 13:58 [PATCH] drm/panthor: Skip job dependencies when we can Boris Brezillon
@ 2026-12-01 14:09 ` Philipp Stanner
2026-12-01 14:11 ` Tvrtko Ursulin
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Philipp Stanner @ 2026-12-01 14:09 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 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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 13:58 [PATCH] drm/panthor: Skip job dependencies when we can Boris Brezillon
2026-12-01 14:09 ` Philipp Stanner
@ 2026-12-01 14:11 ` Tvrtko Ursulin
2026-12-01 16:14 ` Boris Brezillon
2026-12-01 14:14 ` Boris Brezillon
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Tvrtko Ursulin @ 2026-12-01 14:11 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 01/12/2026 13:58, 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. This will allow us to take
> benefit of the pipelining provided by the ring buffer (no extra
> MCU <-> CPU round-trip to have the job pushed to the ring buffer).
>
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Cc: Xianzhong Li <xianzhong.li@nxp.com>
> ---
> Some recent effort to improve job pipelining [1] showed that the
> MCU <-> CPU round-trip that lets us signal job fences adds a
> non-negligible overhead, and this problem seems to be easier and
> more systematically fixed if it's addressed at the KMD side, so
> here's a patch doing exactly that.
>
> [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
> ---
> drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index dc8d0191aef4..cfffb9e2dec8 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -7,6 +7,8 @@
> #include <asm/arch_timer.h>
> #endif
>
> +#include <linux/dma-fence-array.h>
> +#include <linux/dma-fence-chain.h>
> #include <linux/list.h>
> #include <linux/module.h>
> #include <linux/of_platform.h>
> @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> }
> }
>
> +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 (dma_fence_is_chain(fence)) {
> + dma_fence_chain_for_each(fence, fence) {
> + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
> + return false;
> + }
> +
> + return true;
> + } else if (dma_fence_is_array(fence)) {
> + struct dma_fence *sub_fence;
> + u32 index;
> +
> + dma_fence_array_for_each(sub_fence, index, fence) {
> + if (!can_skip_dep(job, sub_fence))
> + return false;
> + }
> +
> + return true;
> + }
> +
> + return false;
> +}
> +
> /**
> * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
> * job dependencies.
> @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
> return ret;
> }
>
> + if (can_skip_dep(job, fence)) {
> + dma_fence_put(fence);
> + continue;
> + }
> +
> ret = drm_sched_job_add_dependency(job, fence);
> if (ret)
> return ret;
Alternatively you could do:
dma_fence_unwrap_for_each(..)
drm_sched_job_add_dependency(..)
And no can_skip_dep would be required.
As a side note this reminds me of my patch where I replaced
job->dependencies XArray with a single dma_fence_array built with
dma_fence_unwrap_merge as dependencies are added. So there is only one
wq cycle for dependencies. Although the cost then moves to
dma_fence_array signalling so I was never sure if it was fully worth it
or not.
Anyway, for this patch you can simplify as above.
Regards,
Tvrtko
>
> ---
> base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056
> change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7
>
> Best regards,
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 13:58 [PATCH] drm/panthor: Skip job dependencies when we can Boris Brezillon
2026-12-01 14:09 ` Philipp Stanner
2026-12-01 14:11 ` Tvrtko Ursulin
@ 2026-12-01 14:14 ` Boris Brezillon
2026-12-01 14:15 ` sashiko-bot
2026-12-01 14:40 ` Christian König
4 siblings, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-01 14:14 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 Tue, 01 Dec 2026 14:58:53 +0100
Boris Brezillon <boris.brezillon@collabora.com> 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. This will allow us to take
> benefit of the pipelining provided by the ring buffer (no extra
> MCU <-> CPU round-trip to have the job pushed to the ring buffer).
>
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Cc: Xianzhong Li <xianzhong.li@nxp.com>
> ---
> Some recent effort to improve job pipelining [1] showed that the
> MCU <-> CPU round-trip that lets us signal job fences adds a
> non-negligible overhead, and this problem seems to be easier and
> more systematically fixed if it's addressed at the KMD side, so
> here's a patch doing exactly that.
>
> [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
> ---
> drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index dc8d0191aef4..cfffb9e2dec8 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -7,6 +7,8 @@
> #include <asm/arch_timer.h>
> #endif
>
> +#include <linux/dma-fence-array.h>
> +#include <linux/dma-fence-chain.h>
> #include <linux/list.h>
> #include <linux/module.h>
> #include <linux/of_platform.h>
> @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> }
> }
>
> +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 (dma_fence_is_chain(fence)) {
> + dma_fence_chain_for_each(fence, fence) {
> + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
> + return false;
Oops, missing dma_fence_put() here (dma_fence_chain_for_each() owns a
fence ref which needs to be released if we bail out early).
> + }
> +
> + return true;
> + } else if (dma_fence_is_array(fence)) {
> + struct dma_fence *sub_fence;
> + u32 index;
> +
> + dma_fence_array_for_each(sub_fence, index, fence) {
> + if (!can_skip_dep(job, sub_fence))
> + return false;
> + }
> +
> + return true;
> + }
> +
> + return false;
> +}
> +
> /**
> * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
> * job dependencies.
> @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
> return ret;
> }
>
> + if (can_skip_dep(job, fence)) {
> + dma_fence_put(fence);
> + continue;
> + }
> +
> ret = drm_sched_job_add_dependency(job, fence);
> if (ret)
> return ret;
>
> ---
> base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056
> change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7
>
> Best regards,
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 13:58 [PATCH] drm/panthor: Skip job dependencies when we can Boris Brezillon
` (2 preceding siblings ...)
2026-12-01 14:14 ` Boris Brezillon
@ 2026-12-01 14:15 ` sashiko-bot
2026-12-01 14:40 ` Christian König
4 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-12-01 14:15 UTC (permalink / raw)
To: Boris Brezillon; +Cc: dri-devel, media-ci
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/panthor: dma_fence reference leak on early return in
can_skip_dep()
- [Medium] drm/panthor: incomplete dependency skipping in can_skip_dep()
for containers
--
commit f23961b342c7dac68cd73ec6ae60320b789f8887
Author: Boris Brezillon <boris.brezillon@collabora.com>
drm/panthor: Skip job dependencies when we can
This commit adds can_skip_dep() to drop sync wait dependencies that
originate from the same queue as the target job, including when wrapped in
a dma_fence_chain or dma_fence_array.
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index dc8d0191aef42..cfffb9e2dec8d 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
[ ... ]
> @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> }
> }
>
> +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 (dma_fence_is_chain(fence)) {
> + dma_fence_chain_for_each(fence, fence) {
> + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
> + return false;
> + }
[Severity: High]
Does returning false from inside dma_fence_chain_for_each() leak the
iterator's reference on fence?
dma_fence_chain_for_each() takes a reference via dma_fence_get() on entry
and advances it with dma_fence_chain_walk(), so breaking or returning out
of the loop early requires a dma_fence_put(fence) on the current chain
node.
> +
> + return true;
> + } else if (dma_fence_is_array(fence)) {
> + struct dma_fence *sub_fence;
> + u32 index;
> +
> + dma_fence_array_for_each(sub_fence, index, fence) {
> + if (!can_skip_dep(job, sub_fence))
> + return false;
> + }
> +
> + return true;
> + }
> +
> + return false;
> +}
> +
> /**
> * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
> * job dependencies.
> @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
> return ret;
> }
>
> + if (can_skip_dep(job, fence)) {
> + dma_fence_put(fence);
> + continue;
> + }
> +
> ret = drm_sched_job_add_dependency(job, fence);
[Severity: Medium]
Can container fences still force an unnecessary wait on a same-queue
fence here?
First, can_skip_dep() does not check dma_fence_is_signaled(fence), so an
already-signaled fence from another context (such as a stub fence or an
already-completed cross-queue fence at a chain head or inside a
dma_fence_array) causes can_skip_dep() to return false even when the only
unsignaled fences in the container belong to the same queue.
Second, when a dma_fence_chain or dma_fence_array mixes a same-queue fence
with an unsignaled cross-queue fence, can_skip_dep() returns false and the
entire container fence is passed to drm_sched_job_add_dependency(). If a
timeline syncobj chain has a newer same-queue fence at the head and an
older unsignaled cross-queue fence behind it, waiting on the outer chain
still blocks the new job in drm_sched until the same-queue fence signals
via an MCU <-> CPU round-trip. Unwrapping the container with
dma_fence_unwrap_for_each() and adding only the unsignaled non-local leaf
fences would avoid both issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com?part=1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 13:58 [PATCH] drm/panthor: Skip job dependencies when we can Boris Brezillon
` (3 preceding siblings ...)
2026-12-01 14:15 ` sashiko-bot
@ 2026-12-01 14:40 ` Christian König
2026-12-01 15:09 ` Boris Brezillon
4 siblings, 1 reply; 11+ messages in thread
From: Christian König @ 2026-12-01 14:40 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, Philipp Stanner, dri-devel,
linux-kernel, linux-media, linaro-mm-sig, Xianzhong Li
On 12/1/26 14:58, 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. This will allow us to take
> benefit of the pipelining provided by the ring buffer (no extra
> MCU <-> CPU round-trip to have the job pushed to the ring buffer).
>
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Cc: Xianzhong Li <xianzhong.li@nxp.com>
> ---
> Some recent effort to improve job pipelining [1] showed that the
> MCU <-> CPU round-trip that lets us signal job fences adds a
> non-negligible overhead, and this problem seems to be easier and
> more systematically fixed if it's addressed at the KMD side, so
> here's a patch doing exactly that.
>
> [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
> ---
> drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index dc8d0191aef4..cfffb9e2dec8 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -7,6 +7,8 @@
> #include <asm/arch_timer.h>
> #endif
>
> +#include <linux/dma-fence-array.h>
> +#include <linux/dma-fence-chain.h>
> #include <linux/list.h>
> #include <linux/module.h>
> #include <linux/of_platform.h>
> @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> }
> }
>
> +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 (dma_fence_is_chain(fence)) {
> + dma_fence_chain_for_each(fence, fence) {
> + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
Recursion is usually not allowed inside the Linux kernel even when like in this case it is limited.
But you can use the dma_fence_unwrap_for_each() helper for this which should make the code much easier to write and understand.
But let me send you the cleanup patch for the dma_fence_unwrap_for_each() helper as well.
Regards,
Christian.
> + return false;
> + }
> +
> + return true;
> + } else if (dma_fence_is_array(fence)) {
> + struct dma_fence *sub_fence;
> + u32 index;
> +
> + dma_fence_array_for_each(sub_fence, index, fence) {
> + if (!can_skip_dep(job, sub_fence))
> + return false;
> + }
> +
> + return true;
> + }
> +
> + return false;
> +}
> +
> /**
> * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
> * job dependencies.
> @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
> return ret;
> }
>
> + if (can_skip_dep(job, fence)) {
> + dma_fence_put(fence);
> + continue;
> + }
> +
> ret = drm_sched_job_add_dependency(job, fence);
> if (ret)
> return ret;
>
> ---
> base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056
> change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7
>
> Best regards,
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 14:40 ` Christian König
@ 2026-12-01 15:09 ` Boris Brezillon
0 siblings, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-01 15:09 UTC (permalink / raw)
To: Christian König
Cc: Steven Price, Liviu Dudau, Akash Goel, Karunika Choo,
Lukas Zapolskas, Chris Diamand, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Sumit Semwal,
Philipp Stanner, dri-devel, linux-kernel, linux-media,
linaro-mm-sig, Xianzhong Li
On Tue, 1 Dec 2026 15:40:03 +0100
Christian König <christian.koenig@amd.com> wrote:
> On 12/1/26 14:58, 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. This will allow us to take
> > benefit of the pipelining provided by the ring buffer (no extra
> > MCU <-> CPU round-trip to have the job pushed to the ring buffer).
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > Cc: Xianzhong Li <xianzhong.li@nxp.com>
> > ---
> > Some recent effort to improve job pipelining [1] showed that the
> > MCU <-> CPU round-trip that lets us signal job fences adds a
> > non-negligible overhead, and this problem seems to be easier and
> > more systematically fixed if it's addressed at the KMD side, so
> > here's a patch doing exactly that.
> >
> > [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
> > ---
> > drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
> > 1 file changed, 41 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> > index dc8d0191aef4..cfffb9e2dec8 100644
> > --- a/drivers/gpu/drm/panthor/panthor_drv.c
> > +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> > @@ -7,6 +7,8 @@
> > #include <asm/arch_timer.h>
> > #endif
> >
> > +#include <linux/dma-fence-array.h>
> > +#include <linux/dma-fence-chain.h>
> > #include <linux/list.h>
> > #include <linux/module.h>
> > #include <linux/of_platform.h>
> > @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> > }
> > }
> >
> > +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 (dma_fence_is_chain(fence)) {
> > + dma_fence_chain_for_each(fence, fence) {
> > + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
>
> Recursion is usually not allowed inside the Linux kernel even when like in this case it is limited.
>
> But you can use the dma_fence_unwrap_for_each() helper for this which should make the code much easier to write and understand.
Oh yeah, I was definitely looking for something like that, just didn't
look in the right place. I'll send a v2 making use of this helper.
Thanks,
Boris
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 14:11 ` Tvrtko Ursulin
@ 2026-12-01 16:14 ` Boris Brezillon
2026-12-01 16:20 ` Boris Brezillon
0 siblings, 1 reply; 11+ messages in thread
From: Boris Brezillon @ 2026-12-01 16:14 UTC (permalink / raw)
To: Tvrtko Ursulin
Cc: 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, Philipp Stanner, dri-devel, linux-kernel,
linux-media, linaro-mm-sig, Xianzhong Li
On Tue, 1 Dec 2026 14:11:23 +0000
Tvrtko Ursulin <tursulin@ursulin.net> wrote:
> On 01/12/2026 13:58, 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. This will allow us to take
> > benefit of the pipelining provided by the ring buffer (no extra
> > MCU <-> CPU round-trip to have the job pushed to the ring buffer).
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > Cc: Xianzhong Li <xianzhong.li@nxp.com>
> > ---
> > Some recent effort to improve job pipelining [1] showed that the
> > MCU <-> CPU round-trip that lets us signal job fences adds a
> > non-negligible overhead, and this problem seems to be easier and
> > more systematically fixed if it's addressed at the KMD side, so
> > here's a patch doing exactly that.
> >
> > [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
> > ---
> > drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
> > 1 file changed, 41 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> > index dc8d0191aef4..cfffb9e2dec8 100644
> > --- a/drivers/gpu/drm/panthor/panthor_drv.c
> > +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> > @@ -7,6 +7,8 @@
> > #include <asm/arch_timer.h>
> > #endif
> >
> > +#include <linux/dma-fence-array.h>
> > +#include <linux/dma-fence-chain.h>
> > #include <linux/list.h>
> > #include <linux/module.h>
> > #include <linux/of_platform.h>
> > @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> > }
> > }
> >
> > +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 (dma_fence_is_chain(fence)) {
> > + dma_fence_chain_for_each(fence, fence) {
> > + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
> > + return false;
> > + }
> > +
> > + return true;
> > + } else if (dma_fence_is_array(fence)) {
> > + struct dma_fence *sub_fence;
> > + u32 index;
> > +
> > + dma_fence_array_for_each(sub_fence, index, fence) {
> > + if (!can_skip_dep(job, sub_fence))
> > + return false;
> > + }
> > +
> > + return true;
> > + }
> > +
> > + return false;
> > +}
> > +
> > /**
> > * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
> > * job dependencies.
> > @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
> > return ret;
> > }
> >
> > + if (can_skip_dep(job, fence)) {
> > + dma_fence_put(fence);
> > + continue;
> > + }
> > +
> > ret = drm_sched_job_add_dependency(job, fence);
> > if (ret)
> > return ret;
>
> Alternatively you could do:
>
> dma_fence_unwrap_for_each(..)
> drm_sched_job_add_dependency(..)
>
> And no can_skip_dep would be required.
Yeah, I guess unwrapping things before adding deps works too and avoids
open-coding the is-this-the-same-queue logic. Thanks for the suggestion.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 16:14 ` Boris Brezillon
@ 2026-12-01 16:20 ` Boris Brezillon
2026-12-01 16:28 ` Tvrtko Ursulin
0 siblings, 1 reply; 11+ messages in thread
From: Boris Brezillon @ 2026-12-01 16:20 UTC (permalink / raw)
To: Tvrtko Ursulin
Cc: 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, Philipp Stanner, dri-devel, linux-kernel,
linux-media, linaro-mm-sig, Xianzhong Li
On Tue, 1 Dec 2026 17:14:38 +0100
Boris Brezillon <boris.brezillon@collabora.com> wrote:
> On Tue, 1 Dec 2026 14:11:23 +0000
> Tvrtko Ursulin <tursulin@ursulin.net> wrote:
>
> > On 01/12/2026 13:58, 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. This will allow us to take
> > > benefit of the pipelining provided by the ring buffer (no extra
> > > MCU <-> CPU round-trip to have the job pushed to the ring buffer).
> > >
> > > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > > Cc: Xianzhong Li <xianzhong.li@nxp.com>
> > > ---
> > > Some recent effort to improve job pipelining [1] showed that the
> > > MCU <-> CPU round-trip that lets us signal job fences adds a
> > > non-negligible overhead, and this problem seems to be easier and
> > > more systematically fixed if it's addressed at the KMD side, so
> > > here's a patch doing exactly that.
> > >
> > > [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
> > > ---
> > > drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
> > > 1 file changed, 41 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> > > index dc8d0191aef4..cfffb9e2dec8 100644
> > > --- a/drivers/gpu/drm/panthor/panthor_drv.c
> > > +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> > > @@ -7,6 +7,8 @@
> > > #include <asm/arch_timer.h>
> > > #endif
> > >
> > > +#include <linux/dma-fence-array.h>
> > > +#include <linux/dma-fence-chain.h>
> > > #include <linux/list.h>
> > > #include <linux/module.h>
> > > #include <linux/of_platform.h>
> > > @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> > > }
> > > }
> > >
> > > +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 (dma_fence_is_chain(fence)) {
> > > + dma_fence_chain_for_each(fence, fence) {
> > > + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
> > > + return false;
> > > + }
> > > +
> > > + return true;
> > > + } else if (dma_fence_is_array(fence)) {
> > > + struct dma_fence *sub_fence;
> > > + u32 index;
> > > +
> > > + dma_fence_array_for_each(sub_fence, index, fence) {
> > > + if (!can_skip_dep(job, sub_fence))
> > > + return false;
> > > + }
> > > +
> > > + return true;
> > > + }
> > > +
> > > + return false;
> > > +}
> > > +
> > > /**
> > > * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
> > > * job dependencies.
> > > @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
> > > return ret;
> > > }
> > >
> > > + if (can_skip_dep(job, fence)) {
> > > + dma_fence_put(fence);
> > > + continue;
> > > + }
> > > +
> > > ret = drm_sched_job_add_dependency(job, fence);
> > > if (ret)
> > > return ret;
> >
> > Alternatively you could do:
> >
> > dma_fence_unwrap_for_each(..)
> > drm_sched_job_add_dependency(..)
> >
> > And no can_skip_dep would be required.
>
> Yeah, I guess unwrapping things before adding deps works too and avoids
> open-coding the is-this-the-same-queue logic. Thanks for the suggestion.
It's a bit of shame those are not eliminated before being inserted in
the Xarray, but that's good enough for me.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 16:20 ` Boris Brezillon
@ 2026-12-01 16:28 ` Tvrtko Ursulin
2026-12-01 16:44 ` Boris Brezillon
0 siblings, 1 reply; 11+ messages in thread
From: Tvrtko Ursulin @ 2026-12-01 16:28 UTC (permalink / raw)
To: Boris Brezillon
Cc: 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, Philipp Stanner, dri-devel, linux-kernel,
linux-media, linaro-mm-sig, Xianzhong Li
On 01/12/2026 16:20, Boris Brezillon wrote:
> On Tue, 1 Dec 2026 17:14:38 +0100
> Boris Brezillon <boris.brezillon@collabora.com> wrote:
>
>> On Tue, 1 Dec 2026 14:11:23 +0000
>> Tvrtko Ursulin <tursulin@ursulin.net> wrote:
>>
>>> On 01/12/2026 13:58, 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. This will allow us to take
>>>> benefit of the pipelining provided by the ring buffer (no extra
>>>> MCU <-> CPU round-trip to have the job pushed to the ring buffer).
>>>>
>>>> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
>>>> Cc: Xianzhong Li <xianzhong.li@nxp.com>
>>>> ---
>>>> Some recent effort to improve job pipelining [1] showed that the
>>>> MCU <-> CPU round-trip that lets us signal job fences adds a
>>>> non-negligible overhead, and this problem seems to be easier and
>>>> more systematically fixed if it's addressed at the KMD side, so
>>>> here's a patch doing exactly that.
>>>>
>>>> [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
>>>> ---
>>>> drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
>>>> 1 file changed, 41 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
>>>> index dc8d0191aef4..cfffb9e2dec8 100644
>>>> --- a/drivers/gpu/drm/panthor/panthor_drv.c
>>>> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
>>>> @@ -7,6 +7,8 @@
>>>> #include <asm/arch_timer.h>
>>>> #endif
>>>>
>>>> +#include <linux/dma-fence-array.h>
>>>> +#include <linux/dma-fence-chain.h>
>>>> #include <linux/list.h>
>>>> #include <linux/module.h>
>>>> #include <linux/of_platform.h>
>>>> @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
>>>> }
>>>> }
>>>>
>>>> +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 (dma_fence_is_chain(fence)) {
>>>> + dma_fence_chain_for_each(fence, fence) {
>>>> + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
>>>> + return false;
>>>> + }
>>>> +
>>>> + return true;
>>>> + } else if (dma_fence_is_array(fence)) {
>>>> + struct dma_fence *sub_fence;
>>>> + u32 index;
>>>> +
>>>> + dma_fence_array_for_each(sub_fence, index, fence) {
>>>> + if (!can_skip_dep(job, sub_fence))
>>>> + return false;
>>>> + }
>>>> +
>>>> + return true;
>>>> + }
>>>> +
>>>> + return false;
>>>> +}
>>>> +
>>>> /**
>>>> * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
>>>> * job dependencies.
>>>> @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
>>>> return ret;
>>>> }
>>>>
>>>> + if (can_skip_dep(job, fence)) {
>>>> + dma_fence_put(fence);
>>>> + continue;
>>>> + }
>>>> +
>>>> ret = drm_sched_job_add_dependency(job, fence);
>>>> if (ret)
>>>> return ret;
>>>
>>> Alternatively you could do:
>>>
>>> dma_fence_unwrap_for_each(..)
>>> drm_sched_job_add_dependency(..)
>>>
>>> And no can_skip_dep would be required.
>>
>> Yeah, I guess unwrapping things before adding deps works too and avoids
>> open-coding the is-this-the-same-queue logic. Thanks for the suggestion.
>
> It's a bit of shame those are not eliminated before being inserted in
> the Xarray, but that's good enough for me.
I cannot guarantee I am not forgetting some gotcha, but from the top of
my head I can't remember a reason why we couldn't do that. On balance
it's probably cheaper to do it straight away. Send a patch? :)
Regards,
Tvrtko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drm/panthor: Skip job dependencies when we can
2026-12-01 16:28 ` Tvrtko Ursulin
@ 2026-12-01 16:44 ` Boris Brezillon
0 siblings, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2026-12-01 16:44 UTC (permalink / raw)
To: Tvrtko Ursulin
Cc: 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, Philipp Stanner, dri-devel, linux-kernel,
linux-media, linaro-mm-sig, Xianzhong Li
On Tue, 1 Dec 2026 16:28:58 +0000
Tvrtko Ursulin <tursulin@ursulin.net> wrote:
> On 01/12/2026 16:20, Boris Brezillon wrote:
> > On Tue, 1 Dec 2026 17:14:38 +0100
> > Boris Brezillon <boris.brezillon@collabora.com> wrote:
> >
> >> On Tue, 1 Dec 2026 14:11:23 +0000
> >> Tvrtko Ursulin <tursulin@ursulin.net> wrote:
> >>
> >>> On 01/12/2026 13:58, 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. This will allow us to take
> >>>> benefit of the pipelining provided by the ring buffer (no extra
> >>>> MCU <-> CPU round-trip to have the job pushed to the ring buffer).
> >>>>
> >>>> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> >>>> Cc: Xianzhong Li <xianzhong.li@nxp.com>
> >>>> ---
> >>>> Some recent effort to improve job pipelining [1] showed that the
> >>>> MCU <-> CPU round-trip that lets us signal job fences adds a
> >>>> non-negligible overhead, and this problem seems to be easier and
> >>>> more systematically fixed if it's addressed at the KMD side, so
> >>>> here's a patch doing exactly that.
> >>>>
> >>>> [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172
> >>>> ---
> >>>> drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++
> >>>> 1 file changed, 41 insertions(+)
> >>>>
> >>>> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> >>>> index dc8d0191aef4..cfffb9e2dec8 100644
> >>>> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> >>>> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> >>>> @@ -7,6 +7,8 @@
> >>>> #include <asm/arch_timer.h>
> >>>> #endif
> >>>>
> >>>> +#include <linux/dma-fence-array.h>
> >>>> +#include <linux/dma-fence-chain.h>
> >>>> #include <linux/list.h>
> >>>> #include <linux/module.h>
> >>>> #include <linux/of_platform.h>
> >>>> @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx)
> >>>> }
> >>>> }
> >>>>
> >>>> +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 (dma_fence_is_chain(fence)) {
> >>>> + dma_fence_chain_for_each(fence, fence) {
> >>>> + if (!can_skip_dep(job, dma_fence_chain_contained(fence)))
> >>>> + return false;
> >>>> + }
> >>>> +
> >>>> + return true;
> >>>> + } else if (dma_fence_is_array(fence)) {
> >>>> + struct dma_fence *sub_fence;
> >>>> + u32 index;
> >>>> +
> >>>> + dma_fence_array_for_each(sub_fence, index, fence) {
> >>>> + if (!can_skip_dep(job, sub_fence))
> >>>> + return false;
> >>>> + }
> >>>> +
> >>>> + return true;
> >>>> + }
> >>>> +
> >>>> + return false;
> >>>> +}
> >>>> +
> >>>> /**
> >>>> * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as
> >>>> * job dependencies.
> >>>> @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
> >>>> return ret;
> >>>> }
> >>>>
> >>>> + if (can_skip_dep(job, fence)) {
> >>>> + dma_fence_put(fence);
> >>>> + continue;
> >>>> + }
> >>>> +
> >>>> ret = drm_sched_job_add_dependency(job, fence);
> >>>> if (ret)
> >>>> return ret;
> >>>
> >>> Alternatively you could do:
> >>>
> >>> dma_fence_unwrap_for_each(..)
> >>> drm_sched_job_add_dependency(..)
> >>>
> >>> And no can_skip_dep would be required.
> >>
> >> Yeah, I guess unwrapping things before adding deps works too and avoids
> >> open-coding the is-this-the-same-queue logic. Thanks for the suggestion.
> >
> > It's a bit of shame those are not eliminated before being inserted in
> > the Xarray, but that's good enough for me.
>
> I cannot guarantee I am not forgetting some gotcha, but from the top of
> my head I can't remember a reason why we couldn't do that. On balance
> it's probably cheaper to do it straight away. Send a patch? :)
Oops, sorry, I was to quick. I can send a separate patch for that
though.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-12-01 16:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 13:58 [PATCH] drm/panthor: Skip job dependencies when we can Boris Brezillon
2026-12-01 14:09 ` Philipp Stanner
2026-12-01 14:11 ` Tvrtko Ursulin
2026-12-01 16:14 ` Boris Brezillon
2026-12-01 16:20 ` Boris Brezillon
2026-12-01 16:28 ` Tvrtko Ursulin
2026-12-01 16:44 ` Boris Brezillon
2026-12-01 14:14 ` Boris Brezillon
2026-12-01 14:15 ` sashiko-bot
2026-12-01 14:40 ` Christian König
2026-12-01 15:09 ` Boris Brezillon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.