Skip to contentSkip to conversation

tests/xe: Verify actual frequency on the basis of GT state

PATCH Superseded Badal Nilawar 1 participant 1 message Jul 20, 2023 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 tests/xe: Verify actual frequency on the basis of GT state

When GT is in RC6 actual frequency reported will be 0. So verify actual on the basic of GT state.

v2:
- Rebased
- Move function xe_is_gt_in_c6, to check rc6 state, to igt_pm library
- Assert if freq reported is not 0 when idle (Ashutosh)
v3:
- Fix review comments (Ashutosh)
v4:
- Move igt_require to igt_main under idle test cases (Ashutosh)
- For idle case wait for C6 instead of usleep (Ashutosh)
v5:
- Remove igt_require from test_freq_range
v6:
- Move xe_is_gt_in_c6 to xe/xe_util.c (Anshuman)

Fixes acaaca0bf317 ("tests/xe: Add Xe IGT tests")
---
 lib/igt_pm.h               |  1 +
 lib/xe/xe_util.c           | 21 +++++++++++++++++
 tests/xe/xe_guc_pc.c       | 46 +++++++++++++++++++++++++++++---------
 tests/xe/xe_pm_residency.c | 38 ++++++++++---------------------
 4 files changed, 70 insertions(+), 36 deletions(-)
lib/igt_pm.h +1 -0
index 71ec2f239..2fc7b98a1 100644
@@ -89,5 +89,6 @@ bool i915_is_slpc_enabled(int drm_fd);
 int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 int igt_pm_get_runtime_usage(struct pci_device *pci_dev);
 void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val);
+bool xe_is_gt_in_c6(int fd, int gt);
 
 #endif /* IGT_PM_H */
lib/xe/xe_util.c +21 -0
index 00506b5ad..2f9ffe2f1 100644
@@ -5,6 +5,7 @@
 
 #include "igt.h"
 #include "igt_syncobj.h"
+#include "igt_sysfs.h"
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
 #include "xe/xe_util.h"
@@ -227,3 +228,23 @@ void xe_bind_unbind_async(int xe, uint32_t vm, uint32_t bind_engine,
 
 	free(bind_ops);
 }
+
+/**
+ * xe_is_gt_in_c6:
+ * @fd: pointer to xe drm fd
+ * @gt: gt number
+ *
+ * Check if GT is in C6 state
+ */
+bool xe_is_gt_in_c6(int fd, int gt)
+{
+	char gt_c_state[16];
+	int gt_fd;
+
+	gt_fd = xe_sysfs_gt_open(fd, gt);
+	igt_assert(gt_fd >= 0);
+	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s", gt_c_state) == 1);
+	close(gt_fd);
+
+	return strcmp(gt_c_state, "gt-c6") == 0;
+}
tests/xe/xe_guc_pc.c +36 -10

105 lines not on this page · raw message

tests/xe/xe_pm_residency.c +12 -26
index a20c4449c..5c4516d03 100644
@@ -28,6 +28,16 @@ const double tolerance = 0.1;
 		     (tol) * 100.0, (tol) * 100.0, \
 		     (double)(ref))
 
+/**
+ * SUBTEST: gt-c6-on-idle
+ * Description: Validate GT C6 state on idle
+ * Run type: BAT
+ *
+ * SUBTEST: idle-residency
+ * Description: basic residency test to validate idle residency
+ *		measured over a time interval is within the tolerance
+ * Run type: FULL
+ */
 IGT_TEST_DESCRIPTION("Tests for gtidle properties");
 
 static unsigned int measured_usleep(unsigned int usec)
@@ -45,24 +55,6 @@ static unsigned int measured_usleep(unsigned int usec)
 	return igt_nsec_elapsed(&ts) / 1000;
 }
 
-/**
- * SUBTEST: gt-c6-on-idle
- * Description: Validate GT C6 state on idle
- * Run type: BAT
- */
-static bool is_gt_in_c6(int fd, int gt)
-{
-	char gt_c_state[16];
-	int gt_fd;
-
-	gt_fd = xe_sysfs_gt_open(fd, gt);
-	igt_assert(gt_fd >= 0);
-	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s", gt_c_state) == 1);
-	close(gt_fd);
-
-	return strcmp(gt_c_state, "gt-c6") == 0;
-}
-
 static unsigned long read_idle_residency(int fd, int gt)
 {
 	unsigned long residency = 0;
@@ -76,17 +68,11 @@ static unsigned long read_idle_residency(int fd, int gt)
 	return residency;
 }
 
-/**
- * SUBTEST: idle-residency
- * Description: basic residency test to validate idle residency
- *		measured over a time interval is within the tolerance
- * Run type: FULL
- */
 static void test_idle_residency(int fd, int gt)
 {
 	unsigned long elapsed_ms, residency_start, residency_end;
 
-	igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
+	igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
 
 	residency_start = read_idle_residency(fd, gt);
 	elapsed_ms = measured_usleep(SLEEP_DURATION * 1000) / 1000;
@@ -110,7 +96,7 @@ igt_main
 	igt_describe("Validate GT C6 on idle");
 	igt_subtest("gt-c6-on-idle")
 		xe_for_each_gt(fd, gt)
-			igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
+			igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
 
 	igt_describe("Validate idle residency measured over a time interval is within the tolerance");
 	igt_subtest("idle-residency")
Signature · 1 line
2.25.1