mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/panthor: Skip job dependencies when we can
@ 2026-12-01 13:58 Boris Brezillon
  2026-12-01 14:09 ` Philipp Stanner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ 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	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-01 14:15 UTC | newest]

Thread overview: 4+ 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 14:14 ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®