summaryrefslogtreecommitdiff
path: root/tests/i915/gem_ctx_freq.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-12-07 20:57:26 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2019-12-07 21:15:28 +0000
commita43a757fa998c21def5959568380fa4d34fef59f (patch)
tree804e8eab1207499a4220a13eb46cb561e3fbc4e3 /tests/i915/gem_ctx_freq.c
parent834e3127c747040b87f12a20b653cba27d980e00 (diff)
i915/gem_ctx_freq: Protect against absent sysfs nodes
Not all machines expose the RPS control nodes (e.g. Ironlake and earlier) as they don't support RPS. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Diffstat (limited to 'tests/i915/gem_ctx_freq.c')
-rw-r--r--tests/i915/gem_ctx_freq.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/i915/gem_ctx_freq.c b/tests/i915/gem_ctx_freq.c
index bc093654..89f3d11e 100644
--- a/tests/i915/gem_ctx_freq.c
+++ b/tests/i915/gem_ctx_freq.c
@@ -109,10 +109,10 @@ static void set_sysfs_freq(uint32_t min, uint32_t max)
igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%u", max);
}
-static void get_sysfs_freq(uint32_t *min, uint32_t *max)
+static bool get_sysfs_freq(uint32_t *min, uint32_t *max)
{
- igt_sysfs_scanf(sysfs, "gt_min_freq_mhz", "%u", min);
- igt_sysfs_scanf(sysfs, "gt_max_freq_mhz", "%u", max);
+ return (igt_sysfs_scanf(sysfs, "gt_min_freq_mhz", "%u", min) == 1 &&
+ igt_sysfs_scanf(sysfs, "gt_max_freq_mhz", "%u", max) == 1);
}
static void sysfs_range(int i915)
@@ -131,7 +131,7 @@ static void sysfs_range(int i915)
* constriained sysfs range.
*/
- get_sysfs_freq(&sys_min, &sys_max);
+ igt_require(get_sysfs_freq(&sys_min, &sys_max));
igt_info("System min freq: %dMHz; max freq: %dMHz\n", sys_min, sys_max);
triangle_fill(frequencies, N_STEPS, sys_min, sys_max);
@@ -182,18 +182,17 @@ static void restore_sysfs_freq(int sig)
}
}
-static void disable_boost(int i915)
+static void disable_boost(void)
{
- char *value;
+ char buf[256];
- value = igt_sysfs_get(i915, "gt_RPn_freq_mhz");
- igt_sysfs_set(i915, "gt_min_freq_mhz", value);
- igt_sysfs_set(i915, "gt_boost_freq_mhz", value);
- free(value);
+ if (igt_sysfs_read(sysfs, "gt_RPn_freq_mhz", buf, sizeof(buf)) > 0) {
+ igt_sysfs_set(sysfs, "gt_min_freq_mhz", buf);
+ igt_sysfs_set(sysfs, "gt_boost_freq_mhz", buf);
+ }
- value = igt_sysfs_get(i915, "gt_RP0_freq_mhz");
- igt_sysfs_set(i915, "gt_max_freq_mhz", value);
- free(value);
+ if (igt_sysfs_read(sysfs, "gt_RP0_freq_mhz", buf, sizeof(buf)) > 0)
+ igt_sysfs_set(sysfs, "gt_max_freq_mhz", buf);
}
igt_main
@@ -208,7 +207,7 @@ igt_main
igt_assert(sysfs != -1);
igt_install_exit_handler(restore_sysfs_freq);
- disable_boost(sysfs);
+ disable_boost();
}
igt_subtest_f("sysfs")