summaryrefslogtreecommitdiff
path: root/tests/pm_rc6_residency.c
diff options
context:
space:
mode:
authorImre Deak <imre.deak@intel.com>2015-05-15 16:58:30 +0300
committerImre Deak <imre.deak@intel.com>2015-05-19 11:35:55 +0300
commit05e9edb2b938143677254cab1d122cd8b0ecd4c0 (patch)
treea9ef1d765048943a2f9ef909bb2e157bf6607897 /tests/pm_rc6_residency.c
parenta2ce95eb9ec1b90a5697d8f8c41ae781328e29bf (diff)
tests/pm_rc6_residency: remove redundant idle loops
Currently the test runs a separate idle loop when reading out each RC6 counter. But there is no need for this, we can have a signle idle loop and read out all the counters at once. This prepares for an upcoming patch where we need to consider the RC6P and RC6PP counters as well when checking RC6. Signed-off-by: Imre Deak <imre.deak@intel.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/pm_rc6_residency.c')
-rw-r--r--tests/pm_rc6_residency.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/tests/pm_rc6_residency.c b/tests/pm_rc6_residency.c
index 276fd41b..7c893629 100644
--- a/tests/pm_rc6_residency.c
+++ b/tests/pm_rc6_residency.c
@@ -82,26 +82,18 @@ static unsigned long get_rc6_enabled_mask(void)
static int read_rc6_residency(const char *name_of_rc6_residency)
{
- unsigned int i;
+ unsigned int residency;
const int device = drm_get_card();
char *path ;
int ret;
- int value[2];
-
- /* For some reason my ivb isn't idle even after syncing up with the gpu.
- * Let's add a sleept just to make it happy. */
- sleep(5);
-
- for(i = 0; i < 2; i++)
- {
- sleep(SLEEP_DURATION / 1000);
- ret = asprintf(&path, "/sys/class/drm/card%d/power/%s_residency_ms",device,name_of_rc6_residency);
- igt_assert_neq(ret, -1);
- value[i] = readit(path);
- }
+
+ ret = asprintf(&path, "/sys/class/drm/card%d/power/%s_residency_ms",
+ device, name_of_rc6_residency);
+ igt_assert_neq(ret, -1);
+ residency = readit(path);
free(path);
- return value[1] - value[0];
+ return residency;
}
static void residency_accuracy(unsigned int diff,
@@ -117,8 +109,8 @@ static void residency_accuracy(unsigned int diff,
"Sysfs RC6 residency counter is inaccurate.\n");
}
-static void measure_residencies(int devid, unsigned int rc6_mask,
- struct residencies *res)
+static void read_residencies(int devid, unsigned int rc6_mask,
+ struct residencies *res)
{
if (rc6_mask & RC6_ENABLED)
res->rc6 = read_rc6_residency("rc6");
@@ -134,6 +126,31 @@ static void measure_residencies(int devid, unsigned int rc6_mask,
res->rc6pp = read_rc6_residency("rc6pp");
}
+static void measure_residencies(int devid, unsigned int rc6_mask,
+ struct residencies *res)
+{
+ struct residencies start = { };
+ struct residencies end = { };
+
+ if (!rc6_mask)
+ return;
+
+ /*
+ * For some reason my ivb isn't idle even after syncing up with the gpu.
+ * Let's add a sleep just to make it happy.
+ */
+ sleep(8);
+
+ read_residencies(devid, rc6_mask, &start);
+ sleep(SLEEP_DURATION / 1000);
+ read_residencies(devid, rc6_mask, &end);
+
+ res->rc6 = end.rc6 - start.rc6;
+ res->rc6p = end.rc6p - start.rc6p;
+ res->rc6pp = end.rc6pp - start.rc6pp;
+ res->media_rc6 = end.media_rc6 - start.media_rc6;
+}
+
igt_main
{
unsigned int rc6_mask;