Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kunal Joshi <kunal1.joshi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Subject: [PATCH 3/4] tests/kms_feature_discovery: Add tests for UHBR/non-UHBR over SST/MST
Date: Wed, 15 Jan 2025 13:02:42 +0530	[thread overview]
Message-ID: <20250115073243.2002014-4-kunal1.joshi@intel.com> (raw)
In-Reply-To: <20250115073243.2002014-1-kunal1.joshi@intel.com>

This patch introduces subtests in kms_feature_discovery.c
to validate both UHBR and non-UHBR link rates over SST
and MST configurations. It adds four new subtests
(uhbr-sst, uhbr-mst, non-uhbr-sst, non-uhbr-mst) that check if
the link rates match the expected UHBR or non-UHBR capability
and whether the outputs are MST or SST. The new test logic
integrates with recently introduced helpers
(kms_joiner_helper and kms_mst_helper) for display
setup and pipe assignment. The meson build script is also
updated to compile these helper sources for kms_feature_discovery.

v2: Add definition for UHBR_LINK_RATE

Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
---
 tests/kms_feature_discovery.c | 177 ++++++++++++++++++++++++++++++++++
 tests/meson.build             |   4 +
 2 files changed, 181 insertions(+)

diff --git a/tests/kms_feature_discovery.c b/tests/kms_feature_discovery.c
index 5bca9ad76..48e655c6d 100644
--- a/tests/kms_feature_discovery.c
+++ b/tests/kms_feature_discovery.c
@@ -42,6 +42,8 @@
 #include "igt_psr.h"
 #include "igt_sysfs.h"
 #include "igt_types.h"
+#include "intel/kms_joiner_helper.h"
+#include "intel/kms_mst_helper.h"
 
 /**
  * SUBTEST: display
@@ -71,10 +73,164 @@
  * Test category: functionality test
  *
  * arg[1].values: 1, 2, 3, 4
+ *
+ * SUBTEST: uhbr-sst
+ * Description: Test we can drive UHBR rates over SST.
+ * Functionality: feature_discovery, uhbr, sst
+ * Test category: functionality test
+ *
+ * SUBTEST: uhbr-mst
+ * Description: Test we can drive UHBR rates over MST.
+ * Functionality: feature_discovery, uhbr, mst
+ * Test category: functionality test
+ *
+ * SUBTEST: non-uhbr-sst
+ * Description: Test we can drive non-UHBR rates over SST.
+ * Functionality: feature_discovery, sst
+ * Test category: functionality test
+ *
+ * SUBTEST: non-uhbr-mst
+ * Description: Test we can drive non-UHBR rates over MST.
+ * Functionality: feature_discovery, mst
+ * Test category: functionality test
+ */
+
+/*
+ * DP Spec defines 10, 13.5, and 20 Gbps as UHBR
+ * So considering all below as NON-UHBR
  */
+#define UHBR_LINK_RATE 1000000
 
 static igt_display_t display;
 
+static void setup_planes_fbs(int fd, igt_output_t *outputs[],
+			     int output_count, drmModeModeInfo * mode[],
+			     struct igt_fb fbs[], struct igt_plane *primarys[])
+{
+	int i;
+
+	for (i = 0; i < output_count; i++) {
+		mode[i] = igt_output_get_mode(outputs[i]);
+		igt_info("Mode %dx%d@%d on output %s\n",
+				mode[i]->hdisplay, mode[i]->vdisplay,
+				mode[i]->vrefresh,
+				igt_output_name(outputs[i]));
+		primarys[i] = igt_output_get_plane_type(outputs[i],
+				DRM_PLANE_TYPE_PRIMARY);
+		igt_create_color_fb(fd, mode[i]->hdisplay,
+				mode[i]->vdisplay,
+				DRM_FORMAT_XRGB8888,
+				DRM_FORMAT_MOD_LINEAR,
+				0.0, 1.0, 0.0,
+				&fbs[i]);
+		igt_plane_set_fb(primarys[i], &fbs[i]);
+	}
+}
+
+static bool fit_modes_in_bw(void)
+{
+	bool found;
+	int ret;
+
+	ret = igt_display_try_commit_atomic(&display,
+			DRM_MODE_ATOMIC_TEST_ONLY |
+			DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+	if (ret != 0) {
+		found = igt_override_all_active_output_modes_to_fit_bw(&display);
+		igt_require_f(found,
+				"No valid mode combo found for modeset\n");
+	}
+	return true;
+}
+
+static void do_modeset(int fd, igt_output_t *output,
+		       bool mst, bool uhbr)
+{
+	int output_count = 0, n_pipes = 0, i;
+	uint32_t master_pipes_mask = 0, valid_pipes_mask = 0, used_pipes_mask = 0;
+	igt_output_t *outputs[IGT_MAX_PIPES];
+	drmModeModeInfo * modes[IGT_MAX_PIPES];
+	struct igt_fb fbs[IGT_MAX_PIPES];
+	struct igt_plane *primarys[IGT_MAX_PIPES];
+
+	for_each_pipe(&display, i) {
+		n_pipes++;
+		valid_pipes_mask = valid_pipes_mask | BIT(i);
+	}
+
+	if (mst)
+		igt_assert_f(igt_find_all_mst_output_in_topology(fd,
+					&display,
+					output,
+					outputs,
+					&output_count),
+				"Unable to find mst outputs\n");
+	else
+		outputs[output_count++] = output;
+
+	igt_assert_f(output_count > 0, "Require at least 1 output\n");
+	igt_set_all_master_pipes_for_platform(&display, &master_pipes_mask);
+	igt_assert_f(igt_assign_pipes_for_outputs(fd, outputs,
+				output_count, n_pipes,
+				&used_pipes_mask,
+				master_pipes_mask,
+				valid_pipes_mask),
+			"Unable to assign pipes for outputs\n");
+	igt_assert_f(fit_modes_in_bw(), "Unable to fit modes in bw\n");
+	setup_planes_fbs(fd, outputs, output_count, modes, fbs, primarys);
+	igt_display_commit2(&display, COMMIT_ATOMIC);
+}
+
+static bool run_link_rate_test(int fd, igt_output_t *output,
+			       bool mst, bool uhbr)
+{
+	bool is_uhbr, is_output_mst;
+
+	igt_display_reset(&display);
+	igt_reset_link_params(fd, output);
+
+	is_output_mst = igt_check_output_is_dp_mst(output);
+	is_uhbr = igt_get_max_link_rate(fd, output) >= UHBR_LINK_RATE;
+
+	if ((mst && !is_output_mst) || (!mst && is_output_mst)) {
+		igt_info("Skipping %s as test expects %s output and output is %s\n", output->name,
+				mst ? "mst" : "sst", is_output_mst ? "mst" : "sst");
+		return false;
+	}
+
+	if ((uhbr && !is_uhbr) || (!uhbr && is_uhbr)) {
+		igt_info("Test expects %s but output %s is %s\n",
+				uhbr ? "uhbr" : "non-uhbr", output->name,
+				is_uhbr ? "uhbr" : "non-uhbr");
+		return false;
+	}
+
+	do_modeset(fd, output, mst, uhbr);
+
+	if (uhbr)
+		return igt_get_current_link_rate(fd, output) >= UHBR_LINK_RATE;
+	else
+		return igt_get_current_link_rate(fd, output) < UHBR_LINK_RATE;
+}
+
+static bool test_link_rate(int fd, bool mst, bool uhbr)
+{
+	bool ran = false;
+	igt_output_t *output;
+
+	igt_skip_on_f(!is_intel_device(fd),
+			"Test supported only on intel platforms\n");
+
+	for_each_connected_output(&display, output) {
+		if (output->config.connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort)
+			ran = ran | run_link_rate_test(fd, output, mst, uhbr);
+		else
+			igt_info("Skipping non DisplayPort output %s\n", output->name);
+	}
+
+	return ran;
+}
+
 IGT_TEST_DESCRIPTION("A metatest that checks for \"features\" presence. "
 		     "The subtests here should only skip or pass, "
 		     "anything else means we have a serious problem.");
@@ -177,5 +333,26 @@ igt_main {
 			}
 			igt_require_f(ret == 0, "No DP-MST configuration found.\n");
 		}
+
+		igt_describe("Test we can drive UHBR rates over SST");
+		igt_subtest("uhbr-sst")
+			igt_require_f(test_link_rate(fd, false, true),
+					"Didn't find any SST output with uhbr rates");
+
+		igt_describe("Test we can drive UHBR rates over MST");
+		igt_subtest("uhbr-mst")
+			igt_require_f(test_link_rate(fd, true, true),
+					"Didn't find any MST output with uhbr rates");
+
+		igt_describe("Test we can drive non uhbr rates over SST");
+		igt_subtest("non-uhbr-sst")
+			igt_require_f(test_link_rate(fd, false, false),
+					"Didn't find any SST output with non-uhbr rates");
+
+		igt_describe("Test we can drive non uhbr rates over MST");
+		igt_subtest("non-uhbr-mst")
+			igt_require_f(test_link_rate(fd, true, false),
+					"Didn't find any MST output with non-uhbr rates");
+
 	}
 }
diff --git a/tests/meson.build b/tests/meson.build
index 6418899ca..851ca8fa5 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -366,6 +366,10 @@ extra_sources = {
 	'kms_chamelium_frames': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
 	'kms_chamelium_hpd': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
 	'kms_dsc': [ join_paths ('intel', 'kms_dsc_helper.c') ],
+	'kms_feature_discovery': [
+		join_paths ('intel', 'kms_joiner_helper.c'),
+		join_paths ('intel', 'kms_mst_helper.c')
+	],
 	'kms_joiner': [join_paths ('intel', 'kms_joiner_helper.c')],
 	'kms_dp_linktrain_fallback': [join_paths ('intel', 'kms_mst_helper.c')],
 	'kms_psr2_sf':  [ join_paths ('intel', 'kms_dsc_helper.c') ],
-- 
2.25.1


  parent reply	other threads:[~2025-01-15  7:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15  7:32 [PATCH 0/4] add test to validate uhbr/non-uhbr over sst/mst Kunal Joshi
2025-01-15  7:32 ` [PATCH 1/4] tests/intel/kms_joiner_helper: helper for joiner-related functions Kunal Joshi
2025-01-15  7:32 ` [PATCH 2/4] tests/intel/kms_mst_helper: Add helper for MST-related functions Kunal Joshi
2025-01-15  7:32 ` Kunal Joshi [this message]
2025-01-16 10:24   ` [PATCH 3/4] tests/kms_feature_discovery: Add tests for UHBR/non-UHBR over SST/MST B, Jeevan
2025-01-27  9:49   ` Sharma, Swati2
2025-01-15  7:32 ` [PATCH 4/4] HAX: DO NOT MERGE Kunal Joshi
2025-01-15 10:16 ` ✗ GitLab.Pipeline: warning for add test to validate uhbr/non-uhbr over sst/mst (rev2) Patchwork
2025-01-15 10:36 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-01-15 10:40 ` ✗ i915.CI.BAT: " Patchwork
2025-01-15 17:39 ` ✗ Xe.CI.Full: " Patchwork
2025-01-27 12:31 ` [PATCH 0/4] add test to validate uhbr/non-uhbr over sst/mst Jani Nikula
2025-01-28  7:05   ` Joshi, Kunal1
2025-01-28 15:04     ` Jani Nikula
2025-02-03  8:04       ` Joshi, Kunal1

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=20250115073243.2002014-4-kunal1.joshi@intel.com \
    --to=kunal1.joshi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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