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.

v2:
- remove the 50MHz rounding that was done for non-VLV platforms, the new
  way of rounding should provide the correct value for all platforms
  (Ville)
Acked-by: Daniel Vetter's avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Imre Deak's avatarImre Deak <imre.deak@intel.com>
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);
wait_freq_settle();
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)
load_helper_stop();
}
/* 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;
read_freqs(freqs);
if (freqs[MIN] > target)
idx = MIN;
else
idx = MAX;
old_freq = freqs[idx];
writeval_nocheck(stuff[idx].filp, target);
read_freqs(freqs);
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
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