[igt-dev] [PATCH i-g-t 2/3] tests/psr: Avoid opening of already open debugfs dir

Dhinakaran Pandiyan dhinakaran.pandiyan at intel.com
Thu Aug 9 22:06:05 UTC 2018


The tests calls igt_debugfs_dir() to open the debugfs dir and further
along calls igt_debugfs_read() each i915_edp_psr_status needs to be
read. The igt_debugfs_read() calls open the directory again, fix this by
making use of the newly added __igt_debugfs_read()

Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
---
 lib/igt_psr.c                    |  8 ++++----
 lib/igt_psr.h                    |  4 ++--
 tests/kms_frontbuffer_tracking.c |  4 ++--
 tests/kms_psr.c                  | 10 ++++++----
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/lib/igt_psr.c b/lib/igt_psr.c
index c979b0b5..3369b889 100644
--- a/lib/igt_psr.c
+++ b/lib/igt_psr.c
@@ -23,18 +23,18 @@
 
 #include  "igt_psr.h"
 
-bool psr_active(int fd, bool check_active)
+bool psr_active(int dir, bool check_active)
 {
 	bool active;
 	char buf[512];
 
-	igt_debugfs_read(fd, "i915_edp_psr_status", buf);
+	igt_debugfs_simple_read(dir, "i915_edp_psr_status", buf, sizeof(buf));
 	active = strstr(buf, "HW Enabled & Active bit: yes\n") &&
 		(strstr(buf, "SRDENT") || strstr(buf, "SLEEP"));
 	return check_active ? active : !active;
 }
 
-bool psr_wait_entry(int fd)
+bool psr_wait_entry(int dir)
 {
-	return igt_wait(psr_active(fd, true), 500, 1);
+	return igt_wait(psr_active(dir, true), 500, 1);
 }
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
index 980f85e0..8b957954 100644
--- a/lib/igt_psr.h
+++ b/lib/igt_psr.h
@@ -28,7 +28,7 @@
 #include "igt_core.h"
 #include "igt_aux.h"
 
-bool psr_wait_entry(int fd);
-bool psr_active(int fd, bool check_active);
+bool psr_wait_entry(int dir);
+bool psr_active(int dir, bool check_active);
 
 #endif
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 04c371f4..86a68a84 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -1632,9 +1632,9 @@ static void do_status_assertions(int flags)
 	}
 
 	if (flags & ASSERT_PSR_ENABLED)
-		igt_assert_f(psr_wait_entry(drm.fd), "PSR still disabled\n");
+		igt_assert_f(psr_wait_entry(drm.debugfs), "PSR still disabled\n");
 	else if (flags & ASSERT_PSR_DISABLED)
-		igt_assert_f(psr_active(drm.fd, false), "PSR still enabled\n");
+		igt_assert_f(psr_active(drm.debugfs, false), "PSR still enabled\n");
 }
 
 static void __do_assertions(const struct test_mode *t, int flags,
diff --git a/tests/kms_psr.c b/tests/kms_psr.c
index 218b3960..3e64cf04 100644
--- a/tests/kms_psr.c
+++ b/tests/kms_psr.c
@@ -192,7 +192,8 @@ static bool sink_support(data_t *data)
 {
 	char buf[512];
 
-	igt_debugfs_read(data->drm_fd, "i915_edp_psr_status", buf);
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_edp_psr_status",
+			 buf, sizeof(buf));
 
 	return data->with_psr_disabled ||
 		strstr(buf, "Sink_Support: yes\n");
@@ -203,7 +204,7 @@ static bool psr_wait_entry_if_enabled(data_t *data)
 	if (data->with_psr_disabled)
 		return true;
 
-	return psr_wait_entry(data->drm_fd);
+	return psr_wait_entry(data->debugfs_fd);
 }
 
 static inline void manual(const char *expected)
@@ -215,7 +216,8 @@ static bool drrs_disabled(data_t *data)
 {
 	char buf[512];
 
-	igt_debugfs_read(data->drm_fd, "i915_drrs_status", buf);
+	igt_debugfs_simple_read(data->debugfs_fd, "i915_drrs_status",
+			 buf, sizeof(buf));
 
 	return !strstr(buf, "DRRS Supported: Yes\n");
 }
@@ -292,7 +294,7 @@ static void run_test(data_t *data)
 		expected = "screen GREEN";
 		break;
 	}
-	igt_assert(psr_active(data->drm_fd, false));
+	igt_assert(psr_active(data->debugfs_fd, false));
 	manual(expected);
 }
 
-- 
2.17.1



More information about the igt-dev mailing list