tests/pm_rc6_residency: fix counter readout in case of wrap-around

Signed-off-by: Imre Deak <imre.deak@intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Imre Deak 2015-05-15 17:29:37 +03:00
parent 05e9edb2b9
commit 2b47e219be

View File

@ -131,6 +131,7 @@ static void measure_residencies(int devid, unsigned int rc6_mask,
{ {
struct residencies start = { }; struct residencies start = { };
struct residencies end = { }; struct residencies end = { };
int retry;
if (!rc6_mask) if (!rc6_mask)
return; return;
@ -141,9 +142,21 @@ static void measure_residencies(int devid, unsigned int rc6_mask,
*/ */
sleep(8); sleep(8);
read_residencies(devid, rc6_mask, &start); /*
sleep(SLEEP_DURATION / 1000); * Retry in case of counter wrap-around. We simply re-run the
read_residencies(devid, rc6_mask, &end); * measurement, since the valid counter range is different on
* different platforms and so fixing it up would be non-trivial.
*/
for (retry = 0; retry < 2; retry++) {
read_residencies(devid, rc6_mask, &start);
sleep(SLEEP_DURATION / 1000);
read_residencies(devid, rc6_mask, &end);
if (end.rc6 >= start.rc6 && end.media_rc6 >= start.media_rc6 &&
end.rc6p >= start.rc6p && end.rc6pp >= start.rc6pp)
break;
}
igt_assert_f(retry < 2, "residency values are not consistent\n");
res->rc6 = end.rc6 - start.rc6; res->rc6 = end.rc6 - start.rc6;
res->rc6p = end.rc6p - start.rc6p; res->rc6p = end.rc6p - start.rc6p;