[PATCH 1/3] tests/pm_rps: vlv: wait for freq to settle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux