Skip to contentSkip to conversation

RFC: Fix chamelium port allocation during igt_fixture

PATCH Superseded Moahmmed Bilal 1 participant 3 messages Dec 5, 2025

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover RFC: Fix chamelium port allocation during igt_fixture

selecting appropriate connector and solving the igt_fixture issue.

Mohammed Bilal (2):
RFC: chamelium/kms_chamelium_hpd: add helper function to select
connector port
RFC: chamelium/kms_chamelium_hpd: use helper function for connector
lookup in DP/HDMI/VGA tests

 tests/chamelium/kms_chamelium_hpd.c | 426 ++++++++++++++++++++--------
 1 file changed, 303 insertions(+), 123 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/2 RFC: chamelium/kms_chamelium_hpd: add helper function to select connector port

From: Mohammed Bilal <[email protected]>

Introduce a new helper function get_port() which returns the chamelium_port matching the requested connector type. The helper iterates through the available ports and returns the first match, or NULL if no matching connector is found.

---
 tests/chamelium/kms_chamelium_hpd.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tests/chamelium/kms_chamelium_hpd.c +15 -0
index 161f494e9..3c8af63bd 100644
@@ -158,6 +158,21 @@ enum test_modeset_mode {
 	TEST_MODESET_OFF,
 };
 
+__maybe_unused
+static struct chamelium_port *get_port(struct chamelium_port **ports,
+				       int port_count, int connector_type)
+{
+	int i;
+
+	for (i = 0; i < port_count; i++) {
+		if (chamelium_port_get_type(ports[i]) ==
+		    connector_type)
+			return ports[i];
+	}
+
+	return NULL;
+}
+
 static void try_suspend_resume_hpd(chamelium_data_t *data,
 				   struct chamelium_port *port,
 				   enum igt_suspend_state state,
Signature · 1 line
2.48.1
#2 lore raw

PATCH 2/2 RFC: chamelium/kms_chamelium_hpd: use helper function for connector lookup in DP/HDMI/VGA tests

In reply to Moahmmed Bilal

From: Mohammed Bilal <[email protected]>

Use the new get_port() helper to retrieve the appropriate connector for each hotplug subtest, ensuring consistent connector handling across DP/HDMI/VGA tests. Also remove the per-connector igt_fixture blocks, as they were being executed regardless of which subtest was run. The helper-based approach avoids unwanted fixture execution and keeps connector selection simple and reliable.

---
 tests/chamelium/kms_chamelium_hpd.c | 411 +++++++++++++++++++---------
 1 file changed, 288 insertions(+), 123 deletions(-)
tests/chamelium/kms_chamelium_hpd.c +288 -123
index 3c8af63bd..840363311 100644
@@ -440,7 +440,6 @@ static void test_hpd_storm_detect(chamelium_data_t *data,
 	igt_hpd_storm_set_threshold(data->drm_fd, 1);
 	chamelium_fire_hpd_pulses(data->chamelium, port, width, 10);
 	igt_assert(igt_hpd_storm_detected(data->drm_fd));
-
 	mon = igt_watch_uevents();
 	chamelium_fire_hpd_pulses(data->chamelium, port, width, 10);
 
@@ -478,156 +477,327 @@ IGT_TEST_DESCRIPTION("Testing HPD with a Chamelium board");
 igt_main
 {
 	chamelium_data_t data;
-	struct chamelium_port *port;
-	int p;
 
 	igt_fixture {
 		chamelium_init_test(&data);
 	}
 
-	igt_describe("DisplayPort tests");
-	igt_subtest_group {
-		igt_fixture {
-			chamelium_require_connector_present(
-				data.ports, DRM_MODE_CONNECTOR_DisplayPort,
-				data.port_count, 1);
-		}
+igt_describe("DP tests");
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("dp-hpd", DisplayPort)
-			test_hotplug(&data, port, HPD_TOGGLE_COUNT_DP_HDMI,
-				     TEST_MODESET_OFF);
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("dp-hpd")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("dp-hpd-fast", DisplayPort) test_hotplug(
-			&data, port, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("dp-hpd-enable-disable-mode", DisplayPort)
-			test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
-				     TEST_MODESET_ON_OFF);
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_DP_HDMI, TEST_MODESET_OFF);
+	}
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("dp-hpd-with-enabled-mode", DisplayPort)
-			test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
-				     TEST_MODESET_ON);
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("dp-hpd-fast")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
 
-		igt_describe(test_hotplug_for_each_pipe_desc);
-		connector_subtest("dp-hpd-for-each-pipe", DisplayPort)
-			test_hotplug_for_each_pipe(&data, port);
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_suspend_resume_hpd_desc);
-		connector_subtest("dp-hpd-after-suspend", DisplayPort)
-			test_suspend_resume_hpd(&data, port, SUSPEND_STATE_MEM,
-						SUSPEND_TEST_NONE);
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+	}
 
-		igt_describe(test_suspend_resume_hpd_desc);
-		connector_subtest("dp-hpd-after-hibernate", DisplayPort)
-			test_suspend_resume_hpd(&data, port, SUSPEND_STATE_DISK,
-						SUSPEND_TEST_DEVICES);
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("dp-hpd-enable-disable-mode")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
 
-		igt_describe(test_hpd_storm_detect_desc);
-		connector_subtest("dp-hpd-storm", DisplayPort)
-			test_hpd_storm_detect(&data, port,
-					      HPD_STORM_PULSE_INTERVAL_DP);
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_hpd_storm_disable_desc);
-		connector_subtest("dp-hpd-storm-disable", DisplayPort)
-			test_hpd_storm_disable(&data, port,
-					       HPD_STORM_PULSE_INTERVAL_DP);
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON_OFF);
 	}
 
-	igt_describe("HDMI tests");
-	igt_subtest_group {
-		igt_fixture {
-			chamelium_require_connector_present(
-				data.ports, DRM_MODE_CONNECTOR_HDMIA,
-				data.port_count, 1);
-		}
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("dp-hpd-with-enabled-mode")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
+
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("hdmi-hpd", HDMIA)
-			test_hotplug(&data, port, HPD_TOGGLE_COUNT_DP_HDMI,
-				     TEST_MODESET_OFF);
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON);
+	}
+
+	igt_describe(test_hotplug_for_each_pipe_desc);
+	igt_subtest("dp-hpd-for-each-pipe")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("hdmi-hpd-fast", HDMIA) test_hotplug(
-			&data, port, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("hdmi-hpd-enable-disable-mode", HDMIA)
-			test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
-				     TEST_MODESET_ON_OFF);
+		test_hotplug_for_each_pipe(&data, hport);
+	}
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("hdmi-hpd-with-enabled-mode", HDMIA)
-			test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
-				     TEST_MODESET_ON);
+	igt_describe(test_suspend_resume_hpd_desc);
+	igt_subtest("dp-hpd-after-suspend")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
 
-		igt_describe(test_hotplug_for_each_pipe_desc);
-		connector_subtest("hdmi-hpd-for-each-pipe", HDMIA)
-			test_hotplug_for_each_pipe(&data, port);
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_suspend_resume_hpd_desc);
-		connector_subtest("hdmi-hpd-after-suspend", HDMIA)
-			test_suspend_resume_hpd(&data, port, SUSPEND_STATE_MEM,
-						SUSPEND_TEST_NONE);
+		test_suspend_resume_hpd(&data, hport, SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);
+	}
 
-		igt_describe(test_suspend_resume_hpd_desc);
-		connector_subtest("hdmi-hpd-after-hibernate", HDMIA)
-			test_suspend_resume_hpd(&data, port, SUSPEND_STATE_DISK,
-						SUSPEND_TEST_DEVICES);
+	igt_describe(test_suspend_resume_hpd_desc);
+	igt_subtest("dp-hpd-after-hibernate")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
 
-		igt_describe(test_hpd_storm_detect_desc);
-		connector_subtest("hdmi-hpd-storm", HDMIA)
-			test_hpd_storm_detect(&data, port,
-					      HPD_STORM_PULSE_INTERVAL_HDMI);
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_hpd_storm_disable_desc);
-		connector_subtest("hdmi-hpd-storm-disable", HDMIA)
-			test_hpd_storm_disable(&data, port,
-					       HPD_STORM_PULSE_INTERVAL_HDMI);
+		test_suspend_resume_hpd(&data, hport, SUSPEND_STATE_DISK, SUSPEND_TEST_DEVICES);
 	}
 
-	igt_describe("VGA tests");
-	igt_subtest_group {
-		igt_fixture {
-			chamelium_require_connector_present(
-				data.ports, DRM_MODE_CONNECTOR_VGA,
-				data.port_count, 1);
-		}
+	igt_describe(test_hpd_storm_detect_desc);
+	igt_subtest("dp-hpd-storm")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
+
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("vga-hpd", VGA) test_hotplug(
-			&data, port, HPD_TOGGLE_COUNT_VGA, TEST_MODESET_OFF);
+		test_hpd_storm_detect(&data, hport, HPD_STORM_PULSE_INTERVAL_DP);
+	}
+
+	igt_describe(test_hpd_storm_disable_desc);
+	igt_subtest("dp-hpd-storm-disable")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_DisplayPort);
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("vga-hpd-fast", VGA) test_hotplug(
-			&data, port, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+		if (!hport)
+			igt_skip("DP connector not available\n");
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("vga-hpd-enable-disable-mode", VGA)
-			test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
-				     TEST_MODESET_ON_OFF);
+		test_hpd_storm_disable(&data, hport, HPD_STORM_PULSE_INTERVAL_DP);
+	}
 
-		igt_describe(test_basic_hotplug_desc);
-		connector_subtest("vga-hpd-with-enabled-mode", VGA)
-			test_hotplug(&data, port, HPD_TOGGLE_COUNT_FAST,
-				     TEST_MODESET_ON);
+igt_describe("HDMI tests");
 
-		igt_describe(test_suspend_resume_hpd_desc);
-		connector_subtest("vga-hpd-after-suspend", VGA)
-			test_suspend_resume_hpd(&data, port, SUSPEND_STATE_MEM,
-						SUSPEND_TEST_NONE);
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("hdmi-hpd")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
 
-		igt_describe(test_suspend_resume_hpd_desc);
-		connector_subtest("vga-hpd-after-hibernate", VGA)
-			test_suspend_resume_hpd(&data, port, SUSPEND_STATE_DISK,
-						SUSPEND_TEST_DEVICES);
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
 
-		igt_describe(test_hpd_without_ddc_desc);
-		connector_subtest("vga-hpd-without-ddc", VGA)
-			test_hpd_without_ddc(&data, port);
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_DP_HDMI, TEST_MODESET_OFF);
+	}
+
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("hdmi-hpd-fast")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
+
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
+
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+	}
+
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("hdmi-hpd-enable-disable-mode")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
+
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
+
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON_OFF);
+	}
+
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("hdmi-hpd-with-enabled-mode")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
+
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
+
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON);
+	}
+
+	igt_describe(test_hotplug_for_each_pipe_desc);
+	igt_subtest("hdmi-hpd-for-each-pipe")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
+
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
+
+		test_hotplug_for_each_pipe(&data, hport);
+	}
+
+	igt_describe(test_suspend_resume_hpd_desc);
+	igt_subtest("hdmi-hpd-after-suspend")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
+
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
+
+		test_suspend_resume_hpd(&data, hport, SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);
+	}
+
+	igt_describe(test_suspend_resume_hpd_desc);
+	igt_subtest("hdmi-hpd-after-hibernate")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
+
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
+
+		test_suspend_resume_hpd(&data, hport, SUSPEND_STATE_DISK, SUSPEND_TEST_DEVICES);
+	}
+
+	igt_describe(test_hpd_storm_detect_desc);
+	igt_subtest("hdmi-hpd-storm")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
+
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
+
+		test_hpd_storm_detect(&data, hport, HPD_STORM_PULSE_INTERVAL_HDMI);
+	}
+
+	igt_describe(test_hpd_storm_disable_desc);
+	igt_subtest("hdmi-hpd-storm-disable")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_HDMIA);
+
+		if (!hport)
+			igt_skip("HDMI connector not available\n");
+
+		test_hpd_storm_disable(&data, hport, HPD_STORM_PULSE_INTERVAL_HDMI);
+	}
+
+igt_describe("VGA tests");
+
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("vga-hpd")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_VGA);
+
+		if (!hport)
+			igt_skip("VGA connector not available\n");
+
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_VGA, TEST_MODESET_OFF);
+	}
+
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("vga-hpd-fast")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_VGA);
+
+		if (!hport)
+			igt_skip("VGA connector not available\n");
+
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_OFF);
+	}
+
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("vga-hpd-enable-disable-mode")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_VGA);
+
+		if (!hport)
+			igt_skip("VGA connector not available\n");
+
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON_OFF);
+	}
+
+	igt_describe(test_basic_hotplug_desc);
+	igt_subtest("vga-hpd-with-enabled-mode")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_VGA);
+
+		if (!hport)
+			igt_skip("VGA connector not available\n");
+
+		test_hotplug(&data, hport, HPD_TOGGLE_COUNT_FAST, TEST_MODESET_ON);
+	}
+
+	igt_describe(test_suspend_resume_hpd_desc);
+	igt_subtest("vga-hpd-after-suspend")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_VGA);
+
+		if (!hport)
+			igt_skip("VGA connector not available\n");
+
+		test_suspend_resume_hpd(&data, hport, SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);
+	}
+
+	igt_describe(test_suspend_resume_hpd_desc);
+	igt_subtest("vga-hpd-after-hibernate")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_VGA);
+
+		if (!hport)
+			igt_skip("VGA connector not available\n");
+
+		test_suspend_resume_hpd(&data, hport, SUSPEND_STATE_DISK, SUSPEND_TEST_DEVICES);
+	}
+
+	igt_describe(test_hpd_without_ddc_desc);
+	igt_subtest("vga-hpd-without-ddc")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_VGA);
+
+		if (!hport)
+			igt_skip("VGA connector not available\n");
+
+		test_hpd_without_ddc(&data, hport);
+	}
+
+	igt_describe(test_hotplug_for_each_pipe_desc);
+	igt_subtest("vga-hpd-for-each-pipe")
+	{
+		struct chamelium_port *hport =
+			get_port(data.ports, data.port_count, DRM_MODE_CONNECTOR_VGA);
+
+		if (!hport)
+			igt_skip("VGA connector not available\n");
+
+		test_hotplug_for_each_pipe(&data, hport);
 	}
 
 	igt_describe("Tests that operate on all connectors");
@@ -643,15 +813,10 @@ igt_main
 
 		igt_describe(test_suspend_resume_hpd_common_desc);
 		igt_subtest("common-hpd-after-hibernate")
-			test_suspend_resume_hpd_common(&data,
-						       SUSPEND_STATE_DISK,
+			test_suspend_resume_hpd_common(&data, SUSPEND_STATE_DISK,
 						       SUSPEND_TEST_DEVICES);
 	}
 
-	igt_describe(test_hotplug_for_each_pipe_desc);
-	connector_subtest("vga-hpd-for-each-pipe", VGA)
-		test_hotplug_for_each_pipe(&data, port);
-
 	igt_fixture {
 		igt_display_fini(&data.display);
 		drm_close_driver(data.drm_fd);
Signature · 1 line
2.48.1