[igt-dev] [PATCH i-g-t v5 1/4] test/psr: Do not fail tests when kernel set a valid disabled reason

José Roberto de Souza jose.souza at intel.com
Sat Jan 26 01:32:53 UTC 2019


If kernel set a reason why PSR was not enabled the test should not
be reported as a error.
The reasons that kernel set are based in the modeset, sink and source
parameters and are not considered a error.

Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
 lib/igt_psr.c   | 30 ++++++++++++++++++++++++++++++
 lib/igt_psr.h   |  1 +
 tests/kms_psr.c | 21 ++++++++++++++++++++-
 3 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/lib/igt_psr.c b/lib/igt_psr.c
index d726fad5..591b2013 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -178,3 +178,33 @@ bool psr_sink_support(int debugfs_fd, enum psr_mode mode)
 		 */
 		return strstr(buf, "Sink support: yes [0x03]");
 }
+
+#define DISABLED_REASON_LOOKUP "Disabled reason: "
+
+bool psr_disabled_reason_get(int debugfs_fd, char *reason, int len)
+{
+	char buf[PSR_STATUS_MAX_LEN];
+	char *str;
+	int ret;
+
+	ret = igt_debugfs_simple_read(debugfs_fd, "i915_edp_psr_status", buf,
+				      sizeof(buf));
+	if (ret < 0)
+		return false;
+
+	str = strstr(buf, DISABLED_REASON_LOOKUP);
+	if (!str)
+		return false;
+
+	str = &str[strlen(DISABLED_REASON_LOOKUP)];
+
+	for (ret = 0; str[ret] != '\n'; ret++);
+
+	if (ret + 1 > len)
+		return false;
+
+	memcpy(reason, str, ret);
+	reason[ret] = '\0';
+
+	return true;
+}
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
index 7e7017bf..465839d2 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -40,5 +40,6 @@ bool psr_wait_update(int debugfs_fd, enum psr_mode mode);
 bool psr_enable(int debugfs_fd, enum psr_mode);
 bool psr_disable(int debugfs_fd);
 bool psr_sink_support(int debugfs_fd, enum psr_mode);
+bool psr_disabled_reason_get(int debugfs_fd, char *reason, int len);
 
 #endif
diff --git a/tests/kms_psr.c b/tests/kms_psr.c
index 3e16a6bf..e854200e 100644
--- a/tests/kms_psr.c
+++ b/tests/kms_psr.c
@@ -387,11 +387,30 @@ static void setup_test_plane(data_t *data, int test_plane)
 
 static void test_setup(data_t *data)
 {
+	bool ret;
+
 	if (data->op_psr_mode == PSR_MODE_2)
 		igt_require(data->supports_psr2);
 	psr_enable_if_enabled(data);
 	setup_test_plane(data, data->test_plane_id);
-	igt_assert(psr_wait_entry_if_enabled(data));
+
+	ret = psr_wait_entry_if_enabled(data);
+	if (!ret) {
+		char reason[128];
+
+		ret = psr_disabled_reason_get(data->debugfs_fd, reason,
+					      sizeof(reason));
+
+		/* Check if it is a PSR2 reason while trying to enable PSR1 */
+		if (ret && data->op_psr_mode == PSR_MODE_1 &&
+		    strstr(reason, "PSR2"))
+			ret = false;
+
+		if (ret)
+			igt_skip("Skipping test because %s\n", reason);
+		else
+			igt_assert_f(ret, "PSR not enabled\n");
+	}
 }
 
 static void dpms_off_on(data_t *data)
-- 
2.20.1



More information about the igt-dev mailing list