[PATCH i-g-t 04/10] lib/igt_kms: add function to force link training failure

Kunal Joshi kunal1.joshi at intel.com
Tue Jul 30 21:13:35 UTC 2024


[1] exposes interface which allows to force link training failure on
given connector.

writing below integer value does following action
1: retry current link paramaeter
2: reduce link rate/ lane count (in order respectively)

[1] https://patchwork.freedesktop.org/patch/594767/?series=133624&rev=3

Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>
---
 lib/igt_kms.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  2 ++
 2 files changed, 46 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 6d2144483..dd43d655a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -6781,6 +6781,50 @@ bool kmstest_force_connector_link_rate(int drm_fd, drmModeConnector *connector,
 	return true;
 }
 
+static bool force_connector_link_training_failure(int drm_fd,
+						   drmModeConnector *connector,
+						   const char *value)
+{
+	return connector_attr_set_debugfs(drm_fd, connector,
+					  "i915_dp_force_link_training_failure",
+					  value, "0");
+}
+
+/**
+ * kmstest_force_connector_force_training_failure:
+ * @fd: drm file descriptor
+ * @connector: connector
+ *
+ * Force link training failure on the specified connector
+ * and install exit handler for resetting
+ *
+ * Returns: True on success
+ */
+bool kmstest_force_connector_link_training_failure(int drm_fd, drmModeConnector *connector, int train_count)
+{
+	char value[2];
+	drmModeConnector *temp;
+
+	if (!is_intel_device(drm_fd))
+		return false;
+
+	snprintf(value, sizeof(value), "%d", train_count);
+	if (!force_connector_link_training_failure(drm_fd, connector, value))
+		return false;
+
+	dump_connector_attrs();
+	igt_install_exit_handler(reset_connectors_at_exit);
+
+	/*
+	 * To allow callers to always use GetConnectorCurrent we need to force a
+	 * redetection here.
+	 */
+	temp = drmModeGetConnector(drm_fd, connector->connector_id);
+	drmModeFreeConnector(temp);
+
+	return true;
+}
+
 /**
  * igt_get_dp_link_rate_set_for_output:
  * @drm_fd: A drm file descriptor
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4ffe03bfc..f5b3017d3 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -292,6 +292,8 @@ bool kmstest_force_connector_lane_count(int drm_fd, drmModeConnector *connector,
 					int lane_count);
 bool kmstest_force_connector_link_rate(int drm_fd, drmModeConnector *connector,
 				       int link_rate);
+bool kmstest_force_connector_link_training_failure(int drm_fd, drmModeConnector *connector,
+						   int train_count);
 
 bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 					drmModeModeInfo *mode);
-- 
2.43.0



More information about the igt-dev mailing list