[Intel-gfx] [PATCH 2/2] test/pm_psr: Add Baytrail simple pm_psr test.

Rodrigo Vivi rodrigo.vivi at gmail.com
Sat Mar 1 00:47:24 CET 2014


Different from core PSR implementation (i.e. Haswell and Broadwell)
Baytrail PSR can be enabled even when source is ok because it
provides way to inactivate PSR whenever any screen updated is done.
Baytrail also doesn't provide any kind of Performance Counters.

Signed-off-by: Rodrigo Vivi <rodrigo.vivi at gmail.com>
---
 tests/pm_psr.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 97 insertions(+), 17 deletions(-)

diff --git a/tests/pm_psr.c b/tests/pm_psr.c
index def8e12..d75ef9e 100644
--- a/tests/pm_psr.c
+++ b/tests/pm_psr.c
@@ -30,21 +30,23 @@
 #include <string.h>
 #include <unistd.h>
 #include "drmtest.h"
+#include "igt_debugfs.h"
 
-#define SLEEP_DURATION 5000 // in milliseconds
+typedef struct {
+	int drm_fd;
+	igt_debugfs_t debugfs;
+	int devid;
+} data_t;
 
-static int get_perf(const char *path)
+static int get_perf(data_t *data)
 {
 	int ret, perf;
 	bool sink, source, enabled;
 	FILE *file;
 	char str[4];
 
-	file = fopen(path, "r");
-	if (file == NULL) {
-		fprintf(stderr, "Couldn't open %s (%d)\n", path, errno);
-		abort();
-	}
+	file = igt_debugfs_fopen(&data->debugfs, "i915_edp_psr_status", "r");
+	igt_require(file);
 
 	ret = fscanf(file, "Sink_Support: %s\n", str);
 	if (ret == 0)
@@ -78,23 +80,101 @@ static int get_perf(const char *path)
 	return perf;
 }
 
-igt_simple_main
+static bool psr_supported(data_t *data)
 {
-	int ret, perf1, perf2;
-	int device = drm_get_card();
-	char *path;
+	int ret;
+	FILE *file;
+	char str[4];
+	bool sink, source;
 
-	igt_skip_on_simulation();
+	file = igt_debugfs_fopen(&data->debugfs, "i915_edp_psr_status", "r");
+	igt_require(file);
+
+	ret = fscanf(file, "Sink_Support: %s\n", str);
+	if (ret == 0)
+	    igt_skip("i915_edp_psr_status format not supported by this test case\n");
+	sink = strcmp(str, "yes") == 0;
+
+	ret = fscanf(file, "Source_OK: %s\n", str);
+	igt_assert(ret != 0);
+	source = strcmp(str, "yes") == 0;
+
+	fclose(file);
+	return sink && source;
+}
+
+static bool psr_enabled(data_t *data)
+{
+	int ret;
+	FILE *file;
+	char str[4];
+
+	file = igt_debugfs_fopen(&data->debugfs, "i915_edp_psr_status", "r");
+	igt_require(file);
+
+	ret = fscanf(file, "Sink_Support: %s\n", str);
+	igt_assert(ret != 0);
+
+	ret = fscanf(file, "Source_OK: %s\n", str);
+	igt_assert(ret != 0);
+
+	ret = fscanf(file, "Enabled: %s\n", str);
+	igt_assert(ret != 0);
+
+	fclose(file);
+	return strcmp(str, "yes") == 0;
+}
+
+static bool wait_psr_entry(data_t *data, int timeout)
+{
+	while (timeout--) {
+		if (psr_enabled(data))
+			return true;
+		sleep(1);
+	}
+	return false;
+}
+
+/* Baytrail doesn't provide a performance counter for PSR */
+/* PSR on Baytrail can be disabled/inactive even when source is ok. */
+static void vlv_test(data_t *data)
+{
+	if (!psr_supported(data))
+		igt_skip("This platform or current configuration don't support PSR.\n");
 
-	ret = asprintf(&path, "/sys/kernel/debug/dri/%d/i915_edp_psr_status", device);
-	igt_assert(ret != -1);
+	if (!wait_psr_entry(data, 10)) {
+		fprintf(stderr, " Unable to enter PSR state.\n It can either be disabled by kernel parameter or it simply failed.\n Make sure there is no screen update happening on eDP, not even a small blinking cursor.\n");
+		igt_fail(1);
+	}
+}
 
-	perf1 = get_perf(path);
-	sleep(SLEEP_DURATION / 1000);
-	perf2 = get_perf(path);
+/* Haswell and Broadwell */
+static void core_test(data_t *data)
+{
+	int perf1, perf2;
+
+	perf1 = get_perf(data);
+	sleep (5);
+	perf2 = get_perf(data);
 
 	if (perf1 == perf2) {
 	    fprintf(stderr, "Unable to enter PSR state again\n");
 	    igt_fail(1);
 	}
 }
+
+igt_simple_main
+{
+	data_t data = {};
+
+	igt_skip_on_simulation();
+
+	data.drm_fd = drm_open_any();
+	data.devid = intel_get_drm_devid(data.drm_fd);
+	igt_debugfs_init(&data.debugfs);
+
+	if (IS_HASWELL(data.devid) || IS_BROADWELL(data.devid))
+		core_test(&data);
+	else if (IS_VALLEYVIEW(data.devid))
+		vlv_test(&data);
+}
-- 
1.8.1.2




More information about the Intel-gfx mailing list