From: sashiko-bot@kernel.org
To: "Boris Brezillon" <boris.brezillon@collabora.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH] drm/panthor: Skip job dependencies when we can
Date: Tue, 01 Dec 2026 14:15:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-243459@kernel.org> (raw)
In-Reply-To: <20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com>
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
next prev parent reply other threads:[~2026-12-01 14:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-12-01 14:40 ` Christian König
2026-12-01 15:09 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-243459@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=media-ci@linuxtv.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.