summaryrefslogtreecommitdiff
path: root/tests/pm_rc6_residency.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-12-05 10:37:13 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-12-05 12:39:09 +0000
commit66b399b61b5051ac5a1933da0291dbc547a921ca (patch)
tree978c0882a823174590d32f69c44c4320d1216729 /tests/pm_rc6_residency.c
parentece35d37e6b0afc0ba99f66179279960042c87bc (diff)
igt/pm_rc6_residency: Replace hard-coded sleep before rc6 with a probe
Instead of trying to sleep for 2 evaluations intervals and then assuming that rc6 is working, poll the rc6 residency instead. References: https://bugs.freedesktop.org/show_bug.cgi?id=104099 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'tests/pm_rc6_residency.c')
-rw-r--r--tests/pm_rc6_residency.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/tests/pm_rc6_residency.c b/tests/pm_rc6_residency.c
index 3f686019..16f4b142 100644
--- a/tests/pm_rc6_residency.c
+++ b/tests/pm_rc6_residency.c
@@ -122,9 +122,6 @@ static void measure_residencies(int devid, unsigned int mask,
struct residencies end = { };
int retry;
- if (!mask)
- return;
-
/*
* Retry in case of counter wrap-around. We simply re-run the
* measurement, since the valid counter range is different on
@@ -168,17 +165,18 @@ static void measure_residencies(int devid, unsigned int mask,
res->rc6 += res->rc6p;
}
-static unsigned long rc6_enable_us(void)
+static bool wait_for_rc6(void)
{
- /*
- * To know how long we need to wait for the device to enter rc6 once
- * idle, we need to look at GEN6_RC_EVALUATION_INTERVAL. Currently,
- * this is set to 125000 (12500 * 1280ns or 0.16s) on all platforms.
- * We must complete at least one EI with activity below the
- * per-platform threshold for RC6 to kick. Therefore, we must wait
- * at least 2 EI cycles, before we can expect rc6 to start ticking.
- */
- return 2 * 160 * 1000;
+ struct timespec tv = {};
+ unsigned long start, now;
+
+ start = read_rc6_residency("rc6");
+ do {
+ usleep(50);
+ now = read_rc6_residency("rc6");
+ } while (now == start && !igt_seconds_elapsed(&tv));
+
+ return now != start;
}
igt_main
@@ -198,19 +196,17 @@ igt_main
/* Make sure rc6 counters are running */
igt_drop_caches_set(fd, DROP_IDLE);
- usleep(rc6_enable_us());
+ igt_require(wait_for_rc6());
close(fd);
rc6_enabled = get_rc6_enabled_mask();
- igt_require(rc6_enabled);
+ igt_require(rc6_enabled & RC6_ENABLED);
}
igt_subtest("rc6-accuracy") {
struct residencies res;
- igt_require(rc6_enabled & RC6_ENABLED);
-
measure_residencies(devid, rc6_enabled, &res);
residency_accuracy(res.rc6, res.duration, "rc6");
}
@@ -218,8 +214,7 @@ igt_main
igt_subtest("media-rc6-accuracy") {
struct residencies res;
- igt_require((rc6_enabled & RC6_ENABLED) &&
- (IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid)));
+ igt_require(IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid));
measure_residencies(devid, rc6_enabled, &res);
residency_accuracy(res.media_rc6, res.duration, "media_rc6");