[Intel-gfx] [PATCH 1/3] tests/pm_rps: vlv: wait for freq to settle
Imre Deak
imre.deak at intel.com
Thu Dec 4 08:09:38 PST 2014
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.
Signed-off-by: Imre Deak <imre.deak at intel.com>
---
tests/pm_rps.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index 101f65d..9ed2125 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -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);
}
--
1.8.4
More information about the Intel-gfx
mailing list