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

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

Ensure we only operate on valid CRTCs. Either assert or continue the
loop, depending on the case.

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.

The test is a bit weird because the pipe (or just int i) is conflated
and used for more things than just the pipe. I think the test could use
some refactoring around these parts, but I'm unsure how exactly. I hope
this is the minimal fix that gets the job done for NULL returns from
igt_crtc_for_pipe().

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

diff --git a/tests/intel/kms_pipe_stress.c b/tests/intel/kms_pipe_stress.c
index 85ab2ec50621..79538a2aca6e 100644
--- a/tests/intel/kms_pipe_stress.c
+++ b/tests/intel/kms_pipe_stress.c
@@ -579,6 +579,7 @@ static void stress_pipes(struct data *data, struct timespec *start,
continue;

crtc = igt_crtc_for_pipe(display, pipe);
+ igt_assert_f(crtc->valid, "There is no pipe %s\n", kmstest_pipe_name(pipe));

igt_assert_f(crtc->n_planes < MAX_PLANES,
"Currently we don't support more than %d planes!",
@@ -740,6 +741,7 @@ static void destroy_framebuffers(struct data *data)
continue;

crtc = igt_crtc_for_pipe(display, i);
+ igt_assert_f(crtc->valid, "There is no pipe %s\n", kmstest_pipe_name(i));

for (j = 0; j < MAX_PLANES; j++) {
if (data->fb[i * MAX_PLANES + j].fb_id) {
@@ -801,6 +803,8 @@ static void prepare_test(struct data *data)
igt_assert(data->highest_mode[i]);

crtc = igt_crtc_for_pipe(display, i);
+ if (!crtc->valid)
+ continue;

if (data->highest_mode[i]) {
igt_info("Using mode: \n");
--
2.47.3