All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [PATCH i-g-t 01/15] lib/kms: Introduce for_each_crtc*()
Date: Fri, 30 Jan 2026 17:36:03 +0200	[thread overview]
Message-ID: <aXzP4wDaz9hCkKKi@intel.com> (raw)
In-Reply-To: <8ce09d54c3f0208797f5b256e8aa27d29c6f4fbf@intel.com>

On Fri, Jan 30, 2026 at 03:38:03PM +0200, Jani Nikula wrote:
> On Fri, 30 Jan 2026, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Add for_each_crtc*() as the crtc based replacement for
> > the for_each_pipe*() iterators (which will eventually get
> > nuked).
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  lib/igt_kms.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 68 insertions(+)
> >
> > diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> > index 432c67d11780..a4857ea0e574 100644
> > --- a/lib/igt_kms.h
> > +++ b/lib/igt_kms.h
> > @@ -682,6 +682,19 @@ static inline bool igt_pipe_connector_valid(enum pipe pipe, igt_output_t *output
> >  		output->config.valid_crtc_idx_mask & (1 << (pipe));
> >  }
> >  
> > +/**
> > + * igt_crtc_connector_valid:
> > + * @crtc: CRTC to check.
> > + * @output: #igt_output_t to check.
> > + *
> > + * Checks whether the given CRTC and output can be used together.
> > + */
> > +static inline bool igt_crtc_connector_valid(igt_crtc_t *crtc, igt_output_t *output)
> > +{
> > +	return igt_output_is_connected(output) &&
> > +		output->config.valid_crtc_idx_mask & (1 << crtc->pipe);
> 
> So should this use crtc->crtc_offset instead of crtc->pipe? Or will that
> bring complications during the conversions that try to remain
> functionally unchanged?

I wasn't thinking too had at this point. Just trying to mostly preserve
the behaviour until we can get to the point where we only have to
modify igt_kms.[ch] to change things.

> 
> (And should crtc->crtc_offset really be named crtc_index?)

Yeah, I think so. But not worrying about it right now.

> 
> > +}
> > +
> >  #define for_each_if(condition) if (!(condition)) {} else
> >  
> >  /**
> > @@ -744,6 +757,23 @@ static inline bool igt_pipe_connector_valid(enum pipe pipe, igt_output_t *output
> >  	for_each_pipe_static(pipe) \
> >  		for_each_if(igt_crtc_for_pipe((display), (pipe))->valid)
> >  
> > +/**
> > + * for_each_crtc:
> > + * @display: a pointer to an #igt_display_t structure
> > + * @crtc: The CRTC
> > + *
> > + * This for loop iterates over all CRTCs.
> > + *
> > + * Note that this cannot be used to enumerate per-CRTC subtest names since it
> > + * depends upon runtime probing of the actual kms driver that is being tested.
> > + * Use #for_each_pipe_static instead.
> > + */
> > +#define for_each_crtc(display, crtc) \
> > +	for ((crtc) = &(display)->crtcs[0]; \
> > +	     (crtc) < &(display)->crtcs[(display)->n_crtcs]; \
> > +	     (crtc)++) \
> > +		for_each_if ((crtc)->valid)
> 
> I feel like for_each_crtc() should iterate the CRTCs in CRTC order, not
> pipe order. What's the plan? Are we eventually going to have ->crtcs[]
> in CRTC order?

I don't even know what it means to have them in pipe order. It should be
one and the same right now because the kernel anyway has them in the
same order. I guess it just means we could theoeretically have holes
in the array with crtc->valid==false for fused off pipes?

But yeah, if/when we start to reorder the pipes, I think we should keep
this stuff in CRTC order, and get rid of the holes.

> And then do something special when some tests want to use
> pipe order?

Something like that. Or make sure the tests don't have some
silly assumptions where the order matters.

> The other day I was looking at making ->n_crtcs and thus
> igt_display_n_crtcs() reflect the actual CRTC count, not IGT_MAX_PIPES,
> and it's also complicated because too many places depend on
> igt_display_n_crtcs() indicating the size of ->crtcs[] and that being
> indexed by pipe instead of CRTC index. So that's also dependent on
> indexing ->crtcs[] with CRTC index.

Yeah, it all needs to get fixed properly to get rid of the pipe
indexing/holes. And then we can nuke that silly crtc->valid thing
as well. Though I admit I didn't really look to closely at what
it all entails.

> Anyway, the loops here make my head spin, but it's all

Yeah, they ugly. for_each_crtc_with_single_output() in particular since
it still shares __igt_pipe_populate_outputs() with the pipe based thing
but I didn't want to start rewriting that stuff until the old iterator
is gone.

> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> 
> I'd just like to hear what the plan is wrt the above questions, perhaps
> recorded in the commit message.

I suppose I don't really have a real solid plane yet, other than
to try to limit the damage to lib/igt_kms.[ch] when we need to
do those changes.

> 
> BR,
> Jani.
> 
> 
> > +
> >  /**
> >   * for_each_pipe_with_valid_output:
> >   * @display: a pointer to an #igt_display_t structure
> > @@ -765,6 +795,27 @@ static inline bool igt_pipe_connector_valid(enum pipe pipe, igt_output_t *output
> >  			for_each_if ((((output) = &(display)->outputs[con__]), \
> >  						igt_pipe_connector_valid((pipe), (output))))
> >  
> > +/**
> > + * for_each_crtc_with_valid_output:
> > + * @display: a pointer to an #igt_display_t structure
> > + * @crtc: CRTC for which this @crtc / @output combination is valid.
> > + * @output: The output for which this @crtc / @output combination is valid.
> > + *
> > + * This for loop is called over all connected outputs. This function
> > + * will try every combination of @crtc and @output.
> > + *
> > + * If you only need to test a single output for each pipe, use
> > + * for_each_crtc_with_single_output(), if you only need an
> > + * output for a single CRTC, use igt_get_single_output_for_pipe().
> > + */
> > +#define for_each_crtc_with_valid_output(display, crtc, output) \
> > +	for ((output) = &(display)->outputs[0], (crtc) = &(display)->crtcs[0]; \
> > +	     assert(igt_can_fail()), (crtc) < &(display)->crtcs[(display)->n_crtcs] && \
> > +		     (output) < &(display)->outputs[(display)->n_outputs]; \
> > +	     (output) = (output) + 1 < &(display)->outputs[(display)->n_outputs] ? \
> > +		     (output) + 1 : ((crtc)++, &(display)->outputs[0])) \
> > +		for_each_if ((crtc)->valid && igt_crtc_connector_valid((crtc), (output)))
> > +
> >  igt_output_t **__igt_pipe_populate_outputs(igt_display_t *display,
> >  					   igt_output_t **chosen_outputs);
> >  
> > @@ -785,6 +836,23 @@ igt_output_t **__igt_pipe_populate_outputs(igt_display_t *display,
> >  		for_each_if (*__output && \
> >  			     ((pipe) = (__output - __outputs), (output) = *__output, 1))
> >  
> > +/**
> > + * for_each_crtc_with_single_output:
> > + * @display: a pointer to an #igt_display_t structure
> > + * @crtc: The CRTC for which this @crtc / @output combination is valid.
> > + * @output: The output for which this @crtc / @output combination is valid.
> > + *
> > + * This loop is called over all CRTCs, and will try to find a compatible output
> > + * for each CRTC. Unlike for_each_pipe_with_valid_output(), this function will
> > + * be called at most once for each pipe.
> > + */
> > +#define for_each_crtc_with_single_output(display, crtc, output) \
> > +	for (igt_output_t *__outputs[igt_display_n_crtcs(display)], \
> > +	     **__output = __igt_pipe_populate_outputs((display), __outputs); \
> > +		 __output < &__outputs[igt_display_n_crtcs(display)]; __output++) \
> > +		for_each_if (*__output && \
> > +			     ((crtc) = igt_crtc_for_pipe((display), (__output - __outputs)), (output) = *__output, 1))
> > +
> >  /**
> >   * for_each_valid_output_on_pipe:
> >   * @display: a pointer to an #igt_display_t structure
> 
> -- 
> Jani Nikula, Intel

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2026-01-30 15:36 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 10:52 [PATCH i-g-t 00/15] lib/kms: Start introducing for_each_crtc*() Ville Syrjala
2026-01-30 10:52 ` [PATCH i-g-t 01/15] lib/kms: Introduce for_each_crtc*() Ville Syrjala
2026-01-30 13:38   ` Jani Nikula
2026-01-30 15:36     ` Ville Syrjälä [this message]
2026-02-02 11:10       ` Jani Nikula
2026-02-02 15:31         ` Ville Syrjälä
2026-01-30 10:52 ` [PATCH i-g-t 02/15] tests/drm_read: Use for_each_crtc*() Ville Syrjala
2026-01-30 13:39   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 03/15] tests/kms_plane_scaling: " Ville Syrjala
2026-01-30 12:03   ` Jani Nikula
2026-01-30 15:41     ` Ville Syrjälä
2026-02-02 11:04       ` Jani Nikula
2026-01-30 14:07   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 04/15] tests/kms_color: Convert to for_each_crtc*() Ville Syrjala
2026-01-30 14:08   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 05/15] tests/intel/kms_pm_dc: Use for_each_crtc*() Ville Syrjala
2026-01-30 14:10   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 06/15] tests/kms_rotation_crc: " Ville Syrjala
2026-01-30 14:11   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 07/15] lib/kms: Use for_each_crtc_with_single_output() and for_each_crtc() Ville Syrjala
2026-01-30 14:15   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 08/15] lib/kms: Use for_each_crtc_with_single_output(), part 1 Ville Syrjala
2026-01-30 14:16   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 09/15] lib/kms: Use for_each_crtc_with_single_output(), part 2 Ville Syrjala
2026-01-30 14:19   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 10/15] lib/kms: Use for_each_crtc_with_single_output(), part 3 Ville Syrjala
2026-01-30 14:22   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 11/15] lib/kms: Use for_each_crtc_with_valid_output(), part 1 Ville Syrjala
2026-01-30 14:24   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 12/15] lib/kms: Use for_each_crtc_with_valid_output(), part 2 Ville Syrjala
2026-01-30 14:26   ` Jani Nikula
2026-02-02 15:38     ` [PATCH i-g-t v2 " Ville Syrjala
2026-01-30 10:52 ` [PATCH i-g-t 13/15] lib/kms: Use for_each_crtc_with_valid_output(), part 3 Ville Syrjala
2026-01-30 14:27   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 14/15] lib/kms: Use for_each_crtc_with_valid_output(), part 4 Ville Syrjala
2026-01-30 14:30   ` Jani Nikula
2026-01-30 10:52 ` [PATCH i-g-t 15/15] lib/kms: Nuke for_each_pipe_with_*_output() Ville Syrjala
2026-01-30 14:35   ` Jani Nikula
2026-02-03  2:58 ` ✓ i915.CI.BAT: success for lib/kms: Start introducing for_each_crtc*() (rev2) Patchwork
2026-02-03  3:12 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-03 13:48 ` ✗ i915.CI.Full: failure " Patchwork
2026-02-03 14:33 ` ✗ 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=aXzP4wDaz9hCkKKi@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jani.nikula@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 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.