On Thu, Dec 04, 2014 at 06:09:40PM +0200, Imre Deak wrote: > Atm the test assumes that the calculated middle frequency point is > supported by the HW, but it's not so at least on VLV. On my B0 > BYT-M there is a 22MHz step between the allowed values, so the test will > fail trying to set the calculated middle freq that isn't aligned to > this. > > 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. > > Signed-off-by: Imre Deak <imre.deak@xxxxxxxxx> > --- > tests/pm_rps.c | 39 +++++++++++++++++++++++++++++++++------ > 1 file changed, 33 insertions(+), 6 deletions(-) > > diff --git a/tests/pm_rps.c b/tests/pm_rps.c > index 1fd5995..8777a73 100644 > --- a/tests/pm_rps.c > +++ b/tests/pm_rps.c > @@ -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,36 @@ 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 ... */ This comment could use a bit of updating as well. > - fmid = fmid / 50 * 50; > + fmid = get_hw_rounded_freq(fmid / 50 * 50); > > igt_debug("\nCheck original min and max...\n"); > if (load_gpu) > -- > 1.8.4 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx