Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 7/7] drm/i915/dsb: Avoid redundant writes to the DSB buffer for indexed register writes
Date: Tue, 17 Nov 2026 20:46:35 +0200	[thread overview]
Message-ID: <avyhCx4my_lBzTyj@intel.com> (raw)
In-Reply-To: <a2cdb4b3495a62ecbfd8a9d3261c499098a60d38@intel.com>

On Tue, Nov 17, 2026 at 06:05:08PM +0200, Jani Nikula wrote:
> On Mon, 16 Nov 2026, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Currently each and every intel_dsb_reg_write_indexed() call
> > will store the new register count into the actual DSB buffer,
> > overwriting the previous count. Considering the LUT has
> > perhaps 1024 or more entries, that is a lot of redundant
> > writes into a buffer that may live in the local memory of a
> > discrete GPU.
> >
> > Defer storing the count until the final value is known,
> > that is when a completely new instruction is about to
> > be emitted.
> 
> Please remind me what guarantees there will be a new instruction, so
> that an unfinished buffer never gets to the DSB.
> 
> Maybe a word or two about that here, or in a comment near
> intel_dsb_ins_align() would be helpful for the more casual DSB folks...

Preparation of a DSB buffer must end with either intel_dsb_finish()
or intel_dsb_gosub_finish(). Each of those always calls
intel_dsb_align_tail() which in turn always calls intel_dsb_ins_align().

> 
> Other than that,
> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> 
> > Eliminating these and other redundant writes speeds up the
> > DSB buffer writes for a 1024 entry LUT update from ~75 usec
> > to ~45 usec on my DG2.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_dsb.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
> > index f7a54dc44894..057f0545bace 100644
> > --- a/drivers/gpu/drm/i915/display/intel_dsb.c
> > +++ b/drivers/gpu/drm/i915/display/intel_dsb.c
> > @@ -335,6 +335,10 @@ static bool intel_dsb_prev_ins_is_indexed_write(struct intel_dsb *dsb)
> >  
> >  static void intel_dsb_ins_align(struct intel_dsb *dsb)
> >  {
> > +	/* Store the final indexed register write count */
> > +	if (intel_dsb_prev_ins_is_indexed_write(dsb))
> > +		dsb_buffer_write(dsb, dsb->ins_start_offset + 0, dsb->ins[0]);
> > +
> >  	/*
> >  	 * Every instruction must be 8 byte aligned.
> >  	 * Indexed register writes may leave free_pos misaligned.
> > @@ -409,9 +413,12 @@ void intel_dsb_reg_write_indexed(struct intel_dsb *dsb,
> >  	if (!assert_dsb_has_room(dsb))
> >  		return;
> >  
> > -	/* Update the count */
> > +	/*
> > +	 * Update the count. The actual dsb_buffer_write()
> > +	 * is done from intel_dsb_ins_align() once the final
> > +	 * count is known.
> > +	 */
> >  	dsb->ins[0]++;
> > -	dsb_buffer_write(dsb, dsb->ins_start_offset + 0, dsb->ins[0]);
> >  
> >  	dsb_buffer_write(dsb, dsb->free_pos++, val);
> >  }
> 
> -- 
> Jani Nikula, Intel

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2026-11-17 18:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  8:10 [PATCH 0/7] drm/i915/dsb: Optimize indexed register writes Ville Syrjala
2026-11-16  8:10 ` [PATCH 1/7] drm/i915/dsb: Remove old comment about stale contents of the DSB buffer Ville Syrjala
2026-11-17 15:43   ` Jani Nikula
2026-11-16  8:10 ` [PATCH 2/7] drm/i915/dsb: Eliminate intel_dsb_prev_ins_is_write() Ville Syrjala
2026-11-17 15:44   ` Jani Nikula
2026-11-16  8:10 ` [PATCH 3/7] drm/i915/dsb: Carve up intel_dsb_prev_ins_is_indexed_write() Ville Syrjala
2026-11-17 15:47   ` Jani Nikula
2026-11-16  8:10 ` [PATCH 4/7] drm/i915/dsb: Extract intel_dsb_set_ins() Ville Syrjala
2026-11-17 15:48   ` Jani Nikula
2026-11-16  8:10 ` [PATCH 5/7] drm/i915/dsb: Update previous instruction tracking in intel_dsb_align_tail() & co Ville Syrjala
2026-11-17 16:07   ` Jani Nikula
2026-11-17 18:41     ` Ville Syrjälä
2026-11-17 18:55       ` Ville Syrjälä
2026-11-16  8:10 ` [PATCH 6/7] drm/i915/dsb: Skip redundant zeroing of every second indexed write DW Ville Syrjala
2026-11-17 15:57   ` Jani Nikula
2026-11-16  8:10 ` [PATCH 7/7] drm/i915/dsb: Avoid redundant writes to the DSB buffer for indexed register writes Ville Syrjala
2026-11-17 16:05   ` Jani Nikula
2026-11-17 18:46     ` Ville Syrjälä [this message]
2026-11-16  8:47 ` ✓ CI.KUnit: success for drm/i915/dsb: Optimize " Patchwork
2026-11-16  9:19 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-16 12:32 ` ✓ Xe.CI.FULL: " Patchwork

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=avyhCx4my_lBzTyj@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.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