[igt-dev] [CI 2/2] tests/kms_psr_sink_crc: Test PSR source HW status.

Dhinakaran Pandiyan dhinakaran.pandiyan at intel.com
Tue Jul 3 23:29:42 UTC 2018


We make use of the status MMIO to tell whether the HW entered and
exited.

Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
---
 tests/kms_psr_sink_crc.c | 58 +++++++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 25 deletions(-)

diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
index d36be7dd..00486f03 100644
--- a/tests/kms_psr_sink_crc.c
+++ b/tests/kms_psr_sink_crc.c
@@ -189,31 +189,37 @@ static bool sink_support(data_t *data)
 {
 	char buf[512];
 
-	igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf);
+	igt_debugfs_read(data->drm_fd, "i915_edp_psr_source_status", buf);
 
 	return data->with_psr_disabled ||
 		strstr(buf, "Sink_Support: yes\n");
 }
 
-static bool psr_enabled(data_t *data)
+static bool psr_hw_enabled(int fd, char *buf, size_t size)
 {
-	char buf[512];
+	__igt_debugfs_read(fd, "i915_edp_psr_source_status", buf, size);
+	return strstr(buf, "HW Enabled & Active bit: yes\n");
+}
 
-	igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf);
+static bool psr_hw_status(int fd, bool active, char *buf, size_t size)
+{
+	__igt_debugfs_read(fd, "i915_edp_psr_source_status", buf, size);
 
-	return data->with_psr_disabled ||
-		strstr(buf, "HW Enabled & Active bit: yes\n");
+	/* TODO: Update the checks for PSR2 */
+	return strstr(buf, "Source PSR status:") &&
+	       (active ? !!strstr(buf, "SRDENT") : !strstr(buf, "SRDENT"));
 }
 
-static bool wait_psr_entry(data_t *data)
+static void assert_psr_entry(data_t *data)
 {
-	int timeout = 5;
-	while (timeout--) {
-		if (psr_enabled(data))
-			return true;
-		sleep(1);
-	}
-	return false;
+	char buf[512];
+
+	if (data->with_psr_disabled)
+		return;
+
+	igt_assert_f(psr_hw_enabled(data->drm_fd, buf, sizeof(buf)), "%s\n", buf);
+	igt_assert_f(igt_wait(psr_hw_status(data->drm_fd, true, buf, sizeof(buf)), 500, 1),
+		     "%s\n", buf);
 }
 
 static inline void manual(const char *expected)
@@ -236,25 +242,26 @@ static void run_test(data_t *data)
 	igt_plane_t *test_plane = data->test_plane;
 	void *ptr;
 	const char *expected = "";
+	char buf[512];
 
 	/* Confirm that screen became Green */
 	manual("screen GREEN");
 
 	/* Confirm screen stays Green after PSR got active */
-	igt_assert(wait_psr_entry(data));
+	assert_psr_entry(data);
 	manual("screen GREEN");
 
 	/* Setting a secondary fb/plane */
 	igt_plane_set_fb(test_plane, &data->fb_white);
 	igt_display_commit(&data->display);
+	igt_assert_f(psr_hw_status(data->drm_fd, false, buf, sizeof(buf)), "%s", buf);
 
-	/* Confirm it is not Green anymore */
-	igt_assert(wait_psr_entry(data));
 	if (test_plane->type == DRM_PLANE_TYPE_PRIMARY)
 		manual("screen WHITE");
 	else
 		manual("GREEN background with WHITE box");
 
+	assert_psr_entry(data);
 	switch (data->op) {
 	case PAGE_FLIP:
 		/* Only in use when testing primary plane */
@@ -303,6 +310,7 @@ static void run_test(data_t *data)
 		expected = "screen GREEN";
 		break;
 	}
+	igt_assert_f(psr_hw_status(data->drm_fd, false, buf, sizeof(buf)), "%s", buf);
 	manual(expected);
 }
 
@@ -436,13 +444,13 @@ int main(int argc, char *argv[])
 
 	igt_subtest("basic") {
 		setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
-		igt_assert(wait_psr_entry(&data));
+		assert_psr_entry(&data);
 		test_cleanup(&data);
 	}
 
 	igt_subtest("no_drrs") {
 		setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
-		igt_assert(wait_psr_entry(&data));
+		assert_psr_entry(&data);
 		igt_assert(drrs_disabled(&data));
 		test_cleanup(&data);
 	}
@@ -451,7 +459,7 @@ int main(int argc, char *argv[])
 		igt_subtest_f("primary_%s", op_str(op)) {
 			data.op = op;
 			setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
-			igt_assert(wait_psr_entry(&data));
+			assert_psr_entry(&data);
 			run_test(&data);
 			test_cleanup(&data);
 		}
@@ -461,7 +469,7 @@ int main(int argc, char *argv[])
 		igt_subtest_f("sprite_%s", op_str(op)) {
 			data.op = op;
 			setup_test_plane(&data, DRM_PLANE_TYPE_OVERLAY);
-			igt_assert(wait_psr_entry(&data));
+			assert_psr_entry(&data);
 			run_test(&data);
 			test_cleanup(&data);
 		}
@@ -471,7 +479,7 @@ int main(int argc, char *argv[])
 		igt_subtest_f("cursor_%s", op_str(op)) {
 			data.op = op;
 			setup_test_plane(&data, DRM_PLANE_TYPE_CURSOR);
-			igt_assert(wait_psr_entry(&data));
+			assert_psr_entry(&data);
 			run_test(&data);
 			test_cleanup(&data);
 		}
@@ -480,7 +488,7 @@ int main(int argc, char *argv[])
 	igt_subtest_f("dpms") {
 		data.op = RENDER;
 		setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
-		igt_assert(wait_psr_entry(&data));
+		assert_psr_entry(&data);
 		dpms_off_on(&data);
 		run_test(&data);
 		test_cleanup(&data);
@@ -489,10 +497,10 @@ int main(int argc, char *argv[])
 	igt_subtest_f("suspend") {
 		data.op = PLANE_ONOFF;
 		setup_test_plane(&data, DRM_PLANE_TYPE_CURSOR);
-		igt_assert(wait_psr_entry(&data));
+		assert_psr_entry(&data);
 		igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
 					      SUSPEND_TEST_NONE);
-		igt_assert(wait_psr_entry(&data));
+		assert_psr_entry(&data);
 		run_test(&data);
 		test_cleanup(&data);
 	}
-- 
2.14.1



More information about the igt-dev mailing list