[PATCH i-g-t 2/2] tests/intel/xe_gt_freq: Skip GuC PC tests if SLPC not enabled

Badal Nilawar badal.nilawar at intel.com
Thu Jan 18 14:56:36 UTC 2024


Skip GuC PC tests if SLPC is disabled

Fixes: acaaca0bf317 ("tests/xe: Add Xe IGT tests")
Signed-off-by: Badal Nilawar <badal.nilawar at intel.com>
---
 tests/intel/xe_gt_freq.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tests/intel/xe_gt_freq.c b/tests/intel/xe_gt_freq.c
index bf63e4298..853720297 100644
--- a/tests/intel/xe_gt_freq.c
+++ b/tests/intel/xe_gt_freq.c
@@ -20,6 +20,7 @@
 #include "xe/xe_query.h"
 #include "xe/xe_util.h"
 
+#include <fcntl.h>
 #include <string.h>
 #include <sys/time.h>
 
@@ -319,6 +320,30 @@ static void test_reset(int fd, int gt_id, int cycles)
 	}
 }
 
+static bool xe_is_slpc_enabled_gt(int drm_fd, int gt)
+{
+	int gt_fd;
+	int freq_fd;
+
+	gt_fd = xe_sysfs_gt_open(drm_fd, gt);
+	igt_assert(gt_fd >= 0);
+
+	/*
+	 * When SLPC disabled xe kmd doesn't create sysfs freq entries
+	 * so its enough to check one of the entry present of not
+	 */
+	freq_fd = openat(gt_fd, "freq0/max_freq", O_RDONLY);
+
+	close(gt_fd);
+
+	if (freq_fd < 0)
+		return false;
+
+	close(freq_fd);
+
+	return true;
+}
+
 igt_main
 {
 	int fd;
@@ -329,6 +354,9 @@ igt_main
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_XE);
 
+		igt_skip_on_f(!xe_is_slpc_enabled_gt(fd, 0),
+			      "GuC PC tests are not supported when SLPC is disabled\n");
+
 		/* The defaults are the same. Stashing the gt0 is enough */
 		stash_min = get_freq(fd, 0, "min");
 		stash_max = get_freq(fd, 0, "max");
-- 
2.25.1



More information about the igt-dev mailing list