Commit b32b5327 authored by Imre Deak's avatar Imre Deak

tests/pm_rps: vlv: round middle point to freq supported by HW

When setting the calculated middle frequency value the test assumes that
the HW/kernel rounds this value according to a 50MHz step value. This is
not so at least on VLV/CHV, on my B0 BYT-M for example this step value
is 22MHz, so there the test will fail.

To fix this get the nearest supported value by setting the target
frequency as a min or max frequency and read it back. The kernel will
round the returned value to the nearest supported.

- remove the 50MHz rounding that was done for non-VLV platforms, the new
  way of rounding should provide the correct value for all platforms
Acked-by: Daniel Vetter's avatarDaniel Vetter <>
Signed-off-by: Imre Deak's avatarImre Deak <>
parent f70afed4
......@@ -120,7 +120,7 @@ static void wait_freq_settle(void)
static int do_writeval(FILE *filp, int val, int lerrno)
static int do_writeval(FILE *filp, int val, int lerrno, bool readback_check)
int ret, orig;
......@@ -131,18 +131,21 @@ static int do_writeval(FILE *filp, int val, int lerrno)
if (lerrno) {
/* Expecting specific error */
igt_assert(ret == EOF && errno == lerrno);
igt_assert(readval(filp) == orig);
if (readback_check)
igt_assert_eq(readval(filp), orig);
} else {
/* Expecting no error */
igt_assert_neq(ret, 0);
igt_assert(readval(filp) == val);
if (readback_check)
igt_assert_eq(readval(filp), val);
return ret;
#define writeval(filp, val) do_writeval(filp, val, 0)
#define writeval_inval(filp, val) do_writeval(filp, val, EINVAL)
#define writeval(filp, val) do_writeval(filp, val, 0, true)
#define writeval_inval(filp, val) do_writeval(filp, val, EINVAL, true)
#define writeval_nocheck(filp, val) do_writeval(filp, val, 0, false)
static void checkit(const int *freqs)
......@@ -342,12 +345,39 @@ static void do_load_gpu(void)
/* Return a frequency rounded by HW to the nearest supported value */
static int get_hw_rounded_freq(int target)
int freqs[NUMFREQ];
int old_freq;
int idx;
int ret;
if (freqs[MIN] > target)
idx = MIN;
idx = MAX;
old_freq = freqs[idx];
writeval_nocheck(stuff[idx].filp, target);
ret = freqs[idx];
writeval_nocheck(stuff[idx].filp, old_freq);
return ret;
static void min_max_config(void (*check)(void), bool load_gpu)
int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
/* hw (and so kernel) currently rounds to 50 MHz ... */
fmid = fmid / 50 * 50;
* hw (and so kernel) rounds to the nearest value supported by
* the given platform.
fmid = get_hw_rounded_freq(fmid);
igt_debug("\nCheck original min and max...\n");
if (load_gpu)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment