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

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


add helper to check if platform supports forcing
link training failures

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

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 1440ab227..581028b74 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -7004,3 +7004,26 @@ bool igt_get_dp_link_retrain_disabled(int drm_fd, igt_output_t *output)
 	igt_require(res > 0);
 	return strstr(buf, "yes");
 }
+
+/**
+ * Checks if the force link training failure debugfs
+ * is available for a specific output.
+ *
+ * @drmfd: file descriptor of the DRM device.
+ * @output: output to check.
+ * Returns:
+ *  true if the debugfs is available, false otherwise.
+ */
+bool igt_has_force_link_training_failure_debugfs(int drmfd, igt_output_t *output)
+{
+	int debugfs_fd, ret;
+	char buf[512];
+
+	igt_assert_f(output->name, "Invalid output\n");
+	debugfs_fd = igt_debugfs_connector_dir(drmfd, output->name, O_RDONLY);
+	if (debugfs_fd < 0)
+		return false;
+	ret = igt_debugfs_simple_read(debugfs_fd, "i915_dp_force_link_training_failure", buf, sizeof(buf));
+	close(debugfs_fd);
+	return ret >= 0;
+}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 7540670df..4f0847385 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -1260,5 +1260,6 @@ enum dp_lane_count igt_get_dp_lane_count_set_for_output(int drm_fd, igt_output_t
 enum dp_link_rate igt_get_dp_max_link_rate(int drm_fd, igt_output_t *output);
 enum dp_lane_count igt_get_dp_max_lane_count(int drm_fd, igt_output_t *output);
 bool igt_get_dp_link_retrain_disabled(int drm_fd, igt_output_t *output);
+bool igt_has_force_link_training_failure_debugfs(int drmfd, igt_output_t *output);
 
 #endif /* __IGT_KMS_H__ */
-- 
2.43.0



More information about the igt-dev mailing list