Linux Media Controller development
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Philipp Stanner <phasta@mailbox.org>
Cc: phasta@kernel.org, "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>,
	"Christian König" <christian.koenig@amd.com>,
	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 v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time
Date: Wed, 2 Dec 2026 14:36:17 +0100	[thread overview]
Message-ID: <20261202143617.70bec705@fedora1.home> (raw)
In-Reply-To: <132576bb9d5bac3f5a51f739436d2d2db4106341.camel@mailbox.org>

Hi Philipp,

On Wed, 02 Dec 2026 13:37:34 +0100
Philipp Stanner <phasta@mailbox.org> wrote:

> Yo Boris,
> 
> On Wed, 2026-12-02 at 12:34 +0100, Boris Brezillon wrote:
> > All dependencies get added through drm_sched_job_add_dependency() or
> > variants that call drm_sched_job_add_dependency() internally. At this
> > point, the job is already attached an entity, and we can do the  
> 
> typo, attached *to* an entity

Will fix.

> 
> […]
> 
> >  	}
> > diff --git a/drivers/gpu/drm/scheduler/sched_internal.h b/drivers/gpu/drm/scheduler/sched_internal.h
> > index 32d3ddb820be..b7afed36b915 100644
> > --- a/drivers/gpu/drm/scheduler/sched_internal.h
> > +++ b/drivers/gpu/drm/scheduler/sched_internal.h  
> 
> Personally, I'm not a huge fan of code in headers anymore since it
> makes finding things more bothersome than when it'd be concentrated in
> sched_entity.c; but I'm not sure whether the kernel has a policy on
> that.

For such simple helpers, it lets the compiler inline things directly
rather than relying on LTO to figure it out (note that if both users
were in sched_main.c, I would have put the helper there, but here we
have one caller in sched_main.c and the other one in sched_entity.c).
BTW, we have such inline helpers defined in header files spread
throughout the codebase, so I'd be surprised if it was
forbidden/discouraged. It's this sort of things where you have to trust
you own judgment (is the helper short enough, is this violating API
layering, ...). As for searching stuff in the code base, I think we
have good enough LSPs with decent IDE integration that it shouldn't
really be a problem. And for old school devs, "git grep to the rescue"
;-).

> 
> > @@ -122,6 +122,26 @@ drm_sched_entity_is_ready(struct drm_sched_entity *entity)
> >  	return true;
> >  }
> >  
> > +/**
> > + * drm_sched_entity_can_skip_dependency() - Check if a dependency can be skipped.
> > + * @entity: entity the dependency will be waited on  
> 
> This reads confusing.
> 
> "entity for whose job the dependency will be set"?

It's still confusing, I think, especially since there's no notion of
job at this level. How about "entity that waits on this dependency"?

> 
> > + * @fence: fence representing the dependency  
> 
> Maybe call it dependency, or dep_fence?

I was just trying to be consistent with the existing helpers which name
this parameter "fence".

> 
> > + *
> > + * Returns true if the dependency can be skipped, false if it can't.  
> 
> nit: Official kernel doc style says that the return statement should be
> marked with "Return: "

Will fix.

> 
> > + */
> > +static inline bool
> > +drm_sched_entity_can_skip_dependency(struct drm_sched_entity *entity,
> > +				     struct dma_fence *fence)
> > +{
> > +	/*
> > +	 * Fence is a scheduled/finished fence from a job
> > +	 * which belongs to the same entity, we can ignore
> > +	 * fences from ourself
> > +	 */  
> 
> nit:
> since you're already touching it, maybe wrapp the comment to 80 chars?

Sure, I can do that.

> 
> > +	return fence->context == entity->fence_context ||
> > +	       fence->context == entity->fence_context + 1;
> > +}
> > +
> >  void drm_sched_entity_stats_release(struct kref *kref);
> >  
> >  /**
> > diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> > index 85a49e219837..5f123a5e39ff 100644
> > --- a/drivers/gpu/drm/scheduler/sched_main.c
> > +++ b/drivers/gpu/drm/scheduler/sched_main.c
> > @@ -678,6 +678,11 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job,
> >  	if (!fence)
> >  		return 0;
> >  
> > +	if (drm_sched_entity_can_skip_dependency(job->entity, fence)) {
> > +		dma_fence_put(fence);
> > +		return 0;
> > +	}  
> 
> 
> But otherwise cool patch. Just the other day I had been wondering why
> we do that check so late currently.

Thanks for the review.

Boris

  reply	other threads:[~2026-12-02 13:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 11:34 [PATCH v4 0/3] drm/panthor: Improve job pipelining Boris Brezillon
2026-12-02 11:34 ` [PATCH v4 1/3] drm/sched: Eliminate NOP dependencies at insertion time Boris Brezillon
2026-12-02 11:44   ` Philipp Stanner
2026-12-02 12:20     ` Boris Brezillon
2026-12-02 12:37   ` Philipp Stanner
2026-12-02 13:36     ` Boris Brezillon [this message]
2026-12-02 11:34 ` [PATCH v4 2/3] drm/sched: Add a drm_sched_job_add_dependency_unwrapped() helper Boris Brezillon
2026-12-02 12:21   ` Boris Brezillon
2026-12-02 12:53   ` Philipp Stanner
2026-12-02 13:47     ` Boris Brezillon
2026-12-02 11:34 ` [PATCH v4 3/3] drm/panthor: Explode container fences to optimize pipelining 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=20261202143617.70bec705@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=phasta@mailbox.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