Linux Media Controller development
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Christian König" <christian.koenig@amd.com>
Cc: Steven Price <steven.price@arm.com>,
	Liviu Dudau <liviu.dudau@arm.com>,
	Akash Goel <akash.goel@arm.com>,
	Karunika Choo <karunika.choo@arm.com>,
	Lukas Zapolskas <lukas.zapolskas@arm.com>,
	Chris Diamand <chris.diamand@arm.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Philipp Stanner <phasta@kernel.org>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
	Xianzhong Li <xianzhong.li@nxp.com>
Subject: Re: [PATCH] drm/panthor: Skip job dependencies when we can
Date: Tue, 1 Dec 2026 16:09:30 +0100	[thread overview]
Message-ID: <20261201160930.10feff50@fedora1.home> (raw)
In-Reply-To: <af10ec48-efce-4a2e-84e2-270113f74ecd@amd.com>

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

      reply	other threads:[~2026-12-01 15:09 UTC|newest]

Thread overview: 6+ 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 14:14 ` Boris Brezillon
2026-12-01 14:40 ` Christian König
2026-12-01 15:09   ` Boris Brezillon [this message]

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=20261201160930.10feff50@fedora1.home \
    --to=boris.brezillon@collabora.com \
    --cc=airlied@gmail.com \
    --cc=akash.goel@arm.com \
    --cc=chris.diamand@arm.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karunika.choo@arm.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=lukas.zapolskas@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=phasta@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tzimmermann@suse.de \
    --cc=xianzhong.li@nxp.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox