All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH i-g-t] i915/gem_ctx_freq: Protect against absent sysfs nodes
@ 2019-12-07 21:04 ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2019-12-07 21:04 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

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>
---
 tests/i915/gem_ctx_freq.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/tests/i915/gem_ctx_freq.c b/tests/i915/gem_ctx_freq.c
index bc093654a..89f3d11ef 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")
-- 
2.24.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-08  0:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-07 21:04 [Intel-gfx] [PATCH i-g-t] i915/gem_ctx_freq: Protect against absent sysfs nodes Chris Wilson
2019-12-07 21:04 ` [igt-dev] " Chris Wilson
2019-12-07 21:32 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-12-08  0:54 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.