[igt-dev] [CI i-g-t] tests/perf_pmu: Test RC6 during runtime suspend
Tvrtko Ursulin
tursulin at ursulin.net
Mon Feb 5 20:06:16 UTC 2018
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
...
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
tests/perf_pmu.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 87 insertions(+), 5 deletions(-)
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 60cff4eee152..26810bb032f6 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -151,6 +151,7 @@ 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)
static void end_spin(int fd, igt_spin_t *spin, unsigned int flags)
{
@@ -1223,7 +1224,84 @@ test_frequency(int gem_fd)
assert_within_epsilon(max[0], max_freq, tolerance);
}
-static bool wait_for_rc6(int fd)
+static void __terminate(char *buf, int sz)
+{
+ igt_assert(sz > 0);
+
+ if (buf[sz - 1] == '\n')
+ buf[sz - 1] = 0;
+ else
+ buf[sz] = 0;
+}
+
+static bool wait_autosuspend(int fd)
+{
+ bool res = false;
+ char buf[128], ref[128];
+ uint32_t delay;
+ int sysfs, ret;
+
+ sysfs = igt_sysfs_open(-1, NULL);
+ igt_assert_fd(sysfs);
+
+ ret = igt_sysfs_read(sysfs, "power/runtime_status", buf, sizeof(buf));
+ igt_assert(ret > 0);
+ __terminate(buf, ret);
+ if (!strcasecmp(buf, "unsupported")) {
+ igt_info("power/runtime_status='%s'\n", buf);
+ res = false;
+ goto out;
+ }
+
+ ret = igt_sysfs_read(sysfs, "power/control", buf, sizeof(buf));
+ igt_assert(ret > 0);
+ __terminate(buf, ret);
+ if (strcasecmp(buf, "auto")) {
+ igt_info("power/control='%s'\n", buf);
+ res = false;
+ goto out;
+ }
+
+ delay = igt_sysfs_get_u32(sysfs, "power/autosuspend_delay_ms");
+ if (!delay) {
+ ret = igt_sysfs_read(sysfs, "power/autosuspend_delay_ms",
+ buf, sizeof(buf));
+ igt_assert(ret > 0);
+ __terminate(buf, ret);
+ igt_info("power/autosuspend_delay_ms='%s'\n", buf);
+ res = false;
+ goto out;
+ }
+
+ ret = igt_sysfs_read(sysfs, "power/runtime_suspended_time",
+ ref, sizeof(ref));
+ igt_assert(ret > 0);
+ __terminate(ref, ret);
+
+ igt_until_timeout(delay + 2) {
+ ret = igt_sysfs_read(sysfs, "power/runtime_suspended_time",
+ buf, sizeof(buf));
+ igt_assert(ret > 0);
+ __terminate(buf, ret);
+
+ if (strncmp(ref, buf, sizeof(buf))) {
+ res = true;
+ goto out;
+ }
+
+ sleep(1);
+ }
+
+ igt_info("power/autosuspend_delay_ms='%u'\n", delay);
+ igt_info("power/runtime_suspended_time='%s'/'%s'\n", ref, buf);
+
+out:
+ close(sysfs);
+
+ return res;
+}
+
+static bool wait_for_rc6(int fd, unsigned int flags)
{
struct timespec tv = {};
uint64_t start, now;
@@ -1238,14 +1316,15 @@ static bool wait_for_rc6(int fd)
usleep(5000);
now = pmu_read_single(fd);
if (now - start > 1e6)
- return true;
+ return flags & TEST_RUNTIME_PM ?
+ wait_autosuspend(fd) : true;
} while (!igt_seconds_elapsed(&tv));
return false;
}
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;
@@ -1255,7 +1334,7 @@ test_rc6(int gem_fd)
fd = open_pmu(I915_PMU_RC6_RESIDENCY);
gem_quiescent_gpu(gem_fd);
- igt_require(wait_for_rc6(fd));
+ igt_require(wait_for_rc6(fd, flags));
/* Go idle and check full RC6. */
prev = pmu_read_single(fd);
@@ -1522,7 +1601,10 @@ 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);
/**
* Check render nodes are counted.
--
2.14.1
More information about the igt-dev
mailing list