On 12/1/26 17:52, Boris Brezillon wrote:
On Tue, 01 Dec 2026 17:35:28 +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 benefit from the pipelining provided by the ring buffer (no extra MCU <-> CPU round-trip to have the job pushed to the ring buffer).
drm_sched_entity_add_dependency_cb() already has this optimization in place, all we need to do is explode the chain/array containers with a dma_fence_unwrap_for_each() when we add job dependencies.
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
Changes in v2:
- Explode container fences with dma_fence_unwrap_for_each() instead of and rely on drm_sched_entity_add_dependency_cb() elimination instead of open-coding it
drivers/gpu/drm/panthor/panthor_drv.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index dc8d0191aef4..a527ce86a113 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> @@ -612,8 +613,9 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx, int ret = 0; for (u32 i = 0; i < sync_op_count; i++) {
struct panthor_sync_signal *sig_sync;struct dma_fence *fence, *inner_fence;
struct dma_fence *fence;
struct dma_fence_unwrap iter;if (!sync_op_is_wait(&sync_ops[i])) continue; @@ -637,9 +639,16 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx, return ret; }
ret = drm_sched_job_add_dependency(job, fence);if (ret)return ret;
/* Explode containers so that drm_sched_entity_add_dependency_cb() can* eliminate fences that are coming from the same queue.*/dma_fence_unwrap_for_each(inner_fence, &iter, fence) {ret = drm_sched_job_add_dependency(job, inner_fence);Missing dma_fence_get(inner_fence) here, as reported by Sashiko.
Yeah drm_sched_job_add_dependency() consumed the fence reference.
if (ret) {dma_fence_put(iter.chain);
I had it on my TODO list for a very long time to clean that up.
Just send you the patch which makes dma_fence_unwrap_for_each() drop the reference with a scoped guard.
Apart from the reference count your patch looks reasonable to me.
Regards, Christian.
return ret;} }}return 0;
base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056 change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7
Best regards,
linaro-mm-sig@lists.linaro.org