Added comments in tricky places for better feature understanding.
Added IGT_TEST_DESCRIPTION and short description for non-obvious
subtests.
Changed name of 'magic' checkit() function to something meaningfull.
Changed junk struct and stuff array names.
Made some minor coding style changes.
Cc: Vinay Belgaumkar <vinay.belgaumkar@xxxxxxxxx>
Cc: Petri Latvala <petri.latvala@xxxxxxxxx>
Cc: Arkadiusz Hiler <arkadiusz.hiler@xxxxxxxxx>
Cc: Daniel Vetter <daniel.vetter@xxxxxxxx>
Signed-off: Katarzyna Dec <katarzyna.dec@xxxxxxxxx>
---
tests/pm_rps.c | 108 ++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 64 insertions(+), 44 deletions(-)
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index e79f0ea7..1eeb6c6a 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -40,6 +40,8 @@
#include "intel_bufmgr.h"
+IGT_TEST_DESCRIPTION("Render P-States tests - verify GPU frequency changes");
+
static int drm_fd;
static const char sysfs_base_path[] = "/sys/class/drm/card%d/gt_%s_freq_mhz";
@@ -56,12 +58,19 @@ enum {
static int origfreqs[NUMFREQ];
-struct junk {
+struct sysfs_file {
const char *name;
const char *mode;
FILE *filp;
-} stuff[] = {
- { "cur", "r", NULL }, { "min", "rb+", NULL }, { "max", "rb+", NULL }, { "RP0", "r", NULL }, { "RP1", "r", NULL }, { "RPn", "r", NULL }, { "boost", "rb+", NULL }, { NULL, NULL, NULL }
+} sysfs_files[] = {
+ { "cur", "r", NULL },
+ { "min", "rb+", NULL },
+ { "max", "rb+", NULL },
+ { "RP0", "r", NULL },
+ { "RP1", "r", NULL },
+ { "RPn", "r", NULL },
+ { "boost", "rb+", NULL },
+ { NULL, NULL, NULL }
};
static int readval(FILE *filp)
@@ -81,7 +90,7 @@ static void read_freqs(int *freqs)
int i;
for (i = 0; i < NUMFREQ; i++)
- freqs[i] = readval(stuff[i].filp);
+ freqs[i] = readval(sysfs_files[i].filp);
}
static void nsleep(unsigned long ns)
@@ -143,7 +152,7 @@ static int do_writeval(FILE *filp, int val, int lerrno, bool readback_check)
#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)
+static void check_freq_constraints(const int *freqs)
{
igt_assert_lte(freqs[MIN], freqs[MAX]);
igt_assert_lte(freqs[CUR], freqs[MAX]);
@@ -162,7 +171,7 @@ static void dump(const int *freqs)
igt_debug("gt freq (MHz):");
for (i = 0; i < NUMFREQ; i++)
- igt_debug(" %s=%d", stuff[i].name, freqs[i]);
+ igt_debug(" %s=%d", sysfs_files[i].name, freqs[i]);
igt_debug("\n");
}
@@ -387,14 +396,18 @@ static int get_hw_rounded_freq(int target)
idx = MAX;
old_freq = freqs[idx];
- writeval_nocheck(stuff[idx].filp, target);
+ writeval_nocheck(sysfs_files[idx].filp, target);
read_freqs(freqs);
ret = freqs[idx];
- writeval_nocheck(stuff[idx].filp, old_freq);
+ writeval_nocheck(sysfs_files[idx].filp, old_freq);
return ret;
}
+/*
+ * Modify softlimit MIN and MAX freqs to valid and invalid levels. Depending
+ * on subtest run different check after each modification.
+ */
static void min_max_config(void (*check)(void), bool load_gpu)
{
int fmid = (origfreqs[RPn] + origfreqs[RP0]) / 2;
@@ -411,78 +424,78 @@ static void min_max_config(void (*check)(void), bool load_gpu)
check();
igt_debug("\nSet min=RPn and max=RP0...\n");
- writeval(stuff[MIN].filp, origfreqs[RPn]);
- writeval(stuff[MAX].filp, origfreqs[RP0]);
+ writeval(sysfs_files[MIN].filp, origfreqs[RPn]);
+ writeval(sysfs_files[MAX].filp, origfreqs[RP0]);
if (load_gpu)
do_load_gpu();
check();
igt_debug("\nIncrease min to midpoint...\n");
- writeval(stuff[MIN].filp, fmid);
+ writeval(sysfs_files[MIN].filp, fmid);
if (load_gpu)
do_load_gpu();
check();
igt_debug("\nIncrease min to RP0...\n");
- writeval(stuff[MIN].filp, origfreqs[RP0]);
+ writeval(sysfs_files[MIN].filp, origfreqs[RP0]);
if (load_gpu)
do_load_gpu();
check();
igt_debug("\nIncrease min above RP0 (invalid)...\n");
- writeval_inval(stuff[MIN].filp, origfreqs[RP0] + 1000);
+ writeval_inval(sysfs_files[MIN].filp, origfreqs[RP0] + 1000);
check();
igt_debug("\nDecrease max to RPn (invalid)...\n");
- writeval_inval(stuff[MAX].filp, origfreqs[RPn]);
+ writeval_inval(sysfs_files[MAX].filp, origfreqs[RPn]);
check();
igt_debug("\nDecrease min to midpoint...\n");
- writeval(stuff[MIN].filp, fmid);
+ writeval(sysfs_files[MIN].filp, fmid);
if (load_gpu)
do_load_gpu();
check();
igt_debug("\nDecrease min to RPn...\n");
- writeval(stuff[MIN].filp, origfreqs[RPn]);
+ writeval(sysfs_files[MIN].filp, origfreqs[RPn]);
if (load_gpu)
do_load_gpu();
check();
igt_debug("\nDecrease min below RPn (invalid)...\n");
- writeval_inval(stuff[MIN].filp, 0);
+ writeval_inval(sysfs_files[MIN].filp, 0);
check();
igt_debug("\nDecrease max to midpoint...\n");
- writeval(stuff[MAX].filp, fmid);
+ writeval(sysfs_files[MAX].filp, fmid);
check();
igt_debug("\nDecrease max to RPn...\n");
- writeval(stuff[MAX].filp, origfreqs[RPn]);
+ writeval(sysfs_files[MAX].filp, origfreqs[RPn]);
check();
igt_debug("\nDecrease max below RPn (invalid)...\n");
- writeval_inval(stuff[MAX].filp, 0);
+ writeval_inval(sysfs_files[MAX].filp, 0);
check();
igt_debug("\nIncrease min to RP0 (invalid)...\n");
- writeval_inval(stuff[MIN].filp, origfreqs[RP0]);
+ writeval_inval(sysfs_files[MIN].filp, origfreqs[RP0]);
check();
igt_debug("\nIncrease max to midpoint...\n");
- writeval(stuff[MAX].filp, fmid);
+ writeval(sysfs_files[MAX].filp, fmid);
check();
igt_debug("\nIncrease max to RP0...\n");
- writeval(stuff[MAX].filp, origfreqs[RP0]);
+ writeval(sysfs_files[MAX].filp, origfreqs[RP0]);
check();
igt_debug("\nIncrease max above RP0 (invalid)...\n");
- writeval_inval(stuff[MAX].filp, origfreqs[RP0] + 1000);
+ writeval_inval(sysfs_files[MAX].filp, origfreqs[RP0] + 1000);
check();
- writeval(stuff[MIN].filp, origfreqs[MIN]);
- writeval(stuff[MAX].filp, origfreqs[MAX]);
+ writeval(sysfs_files[MIN].filp, origfreqs[MIN]);
+ writeval(sysfs_files[MAX].filp, origfreqs[MAX]);
}
static void basic_check(void)
@@ -491,7 +504,7 @@ static void basic_check(void)
read_freqs(freqs);
dump(freqs);