[PATCH i-g-t v2 04/11] tests/intel/kms_joiner_helper: Prepare for returning NULL from igt_crtc_for_pipe()

Jani Nikula
2026-03-20T10:40:04Z

Assert that the pipe is really there during testing. Refactor the code
slightly to reduce duplication while at it.

This prepares for returning NULL for invalid pipes from
igt_crtc_for_pipe() by ensuring the test logic is sound. The follow-up
can change the check from crtc->valid to crtc != NULL with no functional
change here.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
tests/intel/kms_joiner_helper.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tests/intel/kms_joiner_helper.c b/tests/intel/kms_joiner_helper.c
index 7dd87c5c36ea..724ce41a892b 100644
--- a/tests/intel/kms_joiner_helper.c
+++ b/tests/intel/kms_joiner_helper.c
@@ -141,6 +141,8 @@ bool igt_assign_pipes_for_outputs(int drm_fd,
igt_output_t *out;

for (idx = 0; idx < num_outputs; idx++) {
+ igt_crtc_t *crtc;
+
out = outputs[idx];
needed = get_required_pipes(drm_fd, out);
if (needed < 0)
@@ -160,6 +162,9 @@ bool igt_assign_pipes_for_outputs(int drm_fd,
needed, kmstest_pipe_name(start),
kmstest_pipe_name(start + needed - 1), out->name);

+ crtc = igt_crtc_for_pipe(out->display, start);
+ igt_assert_f(crtc->valid, "There is no pipe %s\n", kmstest_pipe_name(start));
+
if (needed > 1) {
mp = get_next_master_pipe(BIT(start));

@@ -168,13 +173,10 @@ bool igt_assign_pipes_for_outputs(int drm_fd,
out->name);
return false;
}
- igt_output_set_crtc(out,
- igt_crtc_for_pipe(out->display, start));
- igt_debug("Using pipe %s as master.\n",
- kmstest_pipe_name(start));
- } else
- igt_output_set_crtc(out,
- igt_crtc_for_pipe(out->display, start));
+ igt_debug("Using pipe %s as master.\n", igt_crtc_name(crtc));
+ }
+
+ igt_output_set_crtc(out, crtc);

for (i = 0; i < needed; i++)
*used_pipes_mask |= BIT(start + i);
--
2.47.3