[PATCH i-g-t v1] tests/intel/xe_gt_freq: Use spinner for throttle test

Raag Jadav raag.jadav at intel.com
Mon Mar 3 09:57:12 UTC 2025


Since throttling requires running workload on GPU, make use of spinner
to get consistent results from throttle API test.

Signed-off-by: Raag Jadav <raag.jadav at intel.com>
---
 tests/intel/xe_gt_freq.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/tests/intel/xe_gt_freq.c b/tests/intel/xe_gt_freq.c
index 1fb6d2b53..b501c62db 100644
--- a/tests/intel/xe_gt_freq.c
+++ b/tests/intel/xe_gt_freq.c
@@ -36,6 +36,12 @@
  */
 #define SLPC_FREQ_LATENCY_US 100000
 
+enum spin_test {
+	SPIN_THROTTLE,
+	SPIN_FIXED_FREQ,
+	SPIN_RANGE_FREQ,
+};
+
 static int set_freq(int fd, int gt_id, const char *freq_name, uint32_t freq)
 {
 	int ret = -EAGAIN;
@@ -352,7 +358,7 @@ static void test_reset(int fd, int gt_id, int cycles)
 	}
 }
 
-static void test_spin(int fd, struct drm_xe_engine_class_instance *eci, bool fixed)
+static void test_spin(int fd, struct drm_xe_engine_class_instance *eci, enum spin_test test)
 {
 	struct drm_xe_sync sync[2] = {
 		{ .type = DRM_XE_SYNC_TYPE_SYNCOBJ, .flags = DRM_XE_SYNC_FLAG_SIGNAL, },
@@ -406,10 +412,17 @@ static void test_spin(int fd, struct drm_xe_engine_class_instance *eci, bool fix
 	igt_info("Running on GT %d Engine %s:%d\n", eci->gt_id,
 		 xe_engine_class_string(eci->engine_class), eci->engine_instance);
 
-	if (fixed)
+	switch (test) {
+	case SPIN_THROTTLE:
+		test_throttle_basic_api(fd, eci->gt_id);
+		break;
+	case SPIN_FIXED_FREQ:
 		test_freq_fixed(fd, eci->gt_id, false);
-	else
+		break;
+	case SPIN_RANGE_FREQ:
 		test_freq_range(fd, eci->gt_id, false);
+		break;
+	};
 
 	xe_spin_end(spin);
 
@@ -454,8 +467,13 @@ igt_main
 	}
 
 	igt_subtest("throttle_basic_api") {
-		xe_for_each_gt(fd, gt)
-			test_throttle_basic_api(fd, gt);
+		xe_for_each_gt(fd, gt) {
+			xe_for_each_engine(fd, hwe) {
+				if (hwe->gt_id != gt)
+					continue;
+				test_spin(fd, hwe, SPIN_THROTTLE);
+			}
+		}
 	}
 
 	igt_subtest("freq_basic_api") {
@@ -476,7 +494,7 @@ igt_main
 			xe_for_each_engine(fd, hwe) {
 				if (hwe->gt_id != gt)
 					continue;
-				test_spin(fd, hwe, true);
+				test_spin(fd, hwe, SPIN_FIXED_FREQ);
 			}
 		}
 	}
@@ -494,7 +512,7 @@ igt_main
 			xe_for_each_engine(fd, hwe) {
 				if (hwe->gt_id != gt)
 					continue;
-				test_spin(fd, hwe, false);
+				test_spin(fd, hwe, SPIN_RANGE_FREQ);
 			}
 		}
 	}
-- 
2.34.1



More information about the igt-dev mailing list