Commit aabf2d09 authored by Imre Deak's avatar Imre Deak

tests/pm_rps: vlv: wait for freq to settle

At least on VLV when forcing a new GT frequency by writing to the
min/max freq sysfs entries the kernel doesn't wait until the new
frequency settles, so the subsequent readback check might fail. To fix
this wait until the current frequency is between the min/max values
using a 10ms timeout.
Acked-by: Daniel Vetter's avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Imre Deak's avatarImre Deak <imre.deak@intel.com>
parent 470071d4
......@@ -34,6 +34,7 @@
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <sys/wait.h>
#include "drmtest.h"
......@@ -87,6 +88,38 @@ static void read_freqs(int *freqs)
freqs[i] = readval(stuff[i].filp);
}
static void nsleep(unsigned long ns)
{
struct timespec ts;
int ret;
ts.tv_sec = 0;
ts.tv_nsec = ns;
do {
struct timespec rem;
ret = nanosleep(&ts, &rem);
igt_assert(ret == 0 || errno == EINTR);
ts = rem;
} while (ret && errno == EINTR);
}
static void wait_freq_settle(void)
{
int timeout = 10;
while (1) {
int freqs[NUMFREQ];
read_freqs(freqs);
if (freqs[CUR] >= freqs[MIN] && freqs[CUR] <= freqs[MAX])
break;
nsleep(1000000);
if (!timeout--)
break;
}
}
static int do_writeval(FILE *filp, int val, int lerrno)
{
int ret, orig;
......@@ -102,6 +135,7 @@ static int do_writeval(FILE *filp, int val, int lerrno)
} else {
/* Expecting no error */
igt_assert_neq(ret, 0);
wait_freq_settle();
igt_assert(readval(filp) == val);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment