[igt-dev] [PATCH i-g-t] tests/perf_pmu: Test RC6 during runtime suspend

Tvrtko Ursulin tursulin at ursulin.net
Wed Feb 7 13:34:05 UTC 2018


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Test to check that the RC6 counter works as expected during and after
runtime suspend.

v2:
 * Use correct sysfs root by using IGT helpers.
 * Turn off display to allow runtime suspend. (Imre)
 * Two subtest flavours.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 tests/perf_pmu.c | 42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 60cff4eee152..3981264b1fa8 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -40,6 +40,7 @@
 #include "igt_core.h"
 #include "igt_perf.h"
 #include "igt_sysfs.h"
+#include "igt_pm.h"
 #include "sw_sync.h"
 
 IGT_TEST_DESCRIPTION("Test the i915 pmu perf interface");
@@ -151,6 +152,8 @@ static unsigned int e2ring(int gem_fd, const struct intel_execution_engine2 *e)
 #define TEST_BUSY (1)
 #define FLAG_SYNC (2)
 #define TEST_TRAILING_IDLE (4)
+#define TEST_RUNTIME_PM (8)
+#define FLAG_LONG (16)
 
 static void end_spin(int fd, igt_spin_t *spin, unsigned int flags)
 {
@@ -1245,19 +1248,44 @@ static bool wait_for_rc6(int fd)
 }
 
 static void
-test_rc6(int gem_fd)
+test_rc6(int gem_fd, unsigned int flags)
 {
 	int64_t duration_ns = 2e9;
 	uint64_t idle, busy, prev;
 	unsigned int slept;
 	int fd, fw;
 
+	gem_quiescent_gpu(gem_fd);
+
 	fd = open_pmu(I915_PMU_RC6_RESIDENCY);
 
-	gem_quiescent_gpu(gem_fd);
+	if (flags & TEST_RUNTIME_PM) {
+		drmModeRes *res;
+
+		res = drmModeGetResources(gem_fd);
+		igt_assert(res);
+
+		/* force all connectors off */
+		kmstest_set_vt_graphics_mode();
+		kmstest_unset_all_crtcs(gem_fd, res);
+
+		igt_require(igt_setup_runtime_pm());
+		igt_require(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
+
+		/*
+		 * Sleep for a bit to see if once woken up estimated RC6 hasn't
+		 * drifted to far in advance of real RC6.
+		 */
+		if (flags & FLAG_LONG) {
+			pmu_read_single(fd);
+			sleep(5);
+			pmu_read_single(fd);
+		}
+	}
+
 	igt_require(wait_for_rc6(fd));
 
-	/* Go idle and check full RC6. */
+	/* While idle check full RC6. */
 	prev = pmu_read_single(fd);
 	slept = measured_usleep(duration_ns / 1000);
 	idle = pmu_read_single(fd);
@@ -1522,7 +1550,13 @@ igt_main
 	 * Test RC6 residency reporting.
 	 */
 	igt_subtest("rc6")
-		test_rc6(fd);
+		test_rc6(fd, 0);
+
+	igt_subtest("rc6-runtime-pm")
+		test_rc6(fd, TEST_RUNTIME_PM);
+
+	igt_subtest("rc6-runtime-pm-long")
+		test_rc6(fd, TEST_RUNTIME_PM | FLAG_LONG);
 
 	/**
 	 * Check render nodes are counted.
-- 
2.14.1



More information about the igt-dev mailing list