Skip to contentSkip to conversation

Add tests to help verify VF migration

PATCH Superseded Matthew Brost 1 participant 4 messages Sep 16, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Add tests to help verify VF migration

These are proving helpful to find VF migration issues.

Matt

Matthew Brost (3):
tests/intel/xe_exec_reset: Add job cancel tests tests/intel/xe_exec_reset: Add timeslice preempt test tests/intel/xe_exec_reset: Long spin tests

 lib/xe/xe_legacy.c          |  56 ++++++++++-
 tests/intel/xe_exec_reset.c | 193 +++++++++++++++++++++++++++++++++++-
 2 files changed, 241 insertions(+), 8 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 tests/intel/xe_exec_reset: Add job cancel tests

This test has pulled out when the ability to set the job timeout via IOCTL was removed from the uAPI while upstreaming Xe. Add this coverage back in but only run on a single hardware engine given by default jobs take 5 seconds to timeout.

---
 lib/xe/xe_legacy.c          |  3 ++-
 tests/intel/xe_exec_reset.c | 23 ++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)
lib/xe/xe_legacy.c +2 -1
index 6570cf1e6e..669ecff7aa 100644
@@ -12,6 +12,7 @@
 
 /* Batch buffer element count, in number of dwords(u32) */
 #define BATCH_DW_COUNT			16
+#define PREEMPT				(0x1 << 6)
 #define CAT_ERROR			(0x1 << 5)
 #define CLOSE_EXEC_QUEUES		(0x1 << 2)
 #define CLOSE_FD			(0x1 << 1)
@@ -56,7 +57,7 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 		u64 pad;
 		u32 data;
 	} *data;
-	struct xe_spin_opts spin_opts = { .preempt = false };
+	struct xe_spin_opts spin_opts = { .preempt = flags & PREEMPT };
 	int i, b;
 
 	igt_assert_lte(n_exec_queues, MAX_N_EXECQUEUES);
tests/intel/xe_exec_reset.c +22 -1
index 7ae53c6790..72b85d3e7b 100644
@@ -116,6 +116,7 @@ static void test_spin(int fd, struct drm_xe_engine_class_instance *eci,
 #define VIRTUAL				(0x1 << 3)
 #define PARALLEL			(0x1 << 4)
 #define CAT_ERROR			(0x1 << 5)
+#define PREEMPT				(0x1 << 6)
 
 /**
  * SUBTEST: %s-cat-error
@@ -295,6 +296,12 @@ test_balancer(int fd, int gt, int class, int n_exec_queues, int n_execs,
  * SUBTEST: cat-error
  * Description: Test cat error
  *
+ * SUBTEST: cancel
+ * Description: Test job cancel
+ *
+ * SUBTEST: cancel-preempt
+ * Description: Test job cancel with a preemptable job
+ *
  * SUBTEST: gt-reset
  * Description: Test GT reset
  *
@@ -350,7 +357,7 @@ test_compute_mode(int fd, struct drm_xe_engine_class_instance *eci,
 		uint64_t exec_sync;
 		uint32_t data;
 	} *data;
-	struct xe_spin_opts spin_opts = { .preempt = false };
+	struct xe_spin_opts spin_opts = { .preempt = flags & PREEMPT };
 	int i, b;
 
 	igt_assert_lte(n_exec_queues, MAX_N_EXECQUEUES);
@@ -659,6 +666,20 @@ igt_main
 			xe_legacy_test_mode(fd, hwe, 2, 2, CAT_ERROR,
 					    LEGACY_MODE_ADDR, false);
 
+	igt_subtest("cancel")
+		xe_for_each_engine(fd, hwe) {
+			xe_legacy_test_mode(fd, hwe, 1, 1, 0,
+					    LEGACY_MODE_ADDR, false);
+			break;
+		}
+
+	igt_subtest("cancel-preempt")
+		xe_for_each_engine(fd, hwe) {
+			xe_legacy_test_mode(fd, hwe, 1, 1, PREEMPT,
+					    LEGACY_MODE_ADDR, false);
+			break;
+		}
+
 	igt_subtest("gt-reset")
 		xe_for_each_engine(fd, hwe)
 			xe_legacy_test_mode(fd, hwe, 2, 2, GT_RESET,
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 tests/intel/xe_exec_reset: Add timeslice preempt test

In reply to Matthew Brost

Add tests in which submit multiple preemptable spinners to same hardware engine ensuring a cumulative longer timeout and validating the restart paths in the DRM scheduler TDR (Timeout Detection and Recovery).

v3:
- Spell out TDR (Kamal)

---
 lib/xe/xe_legacy.c          |  5 +++--
 tests/intel/xe_exec_reset.c | 25 +++++++++++++++++++++++--
 2 files changed, 26 insertions(+), 4 deletions(-)
lib/xe/xe_legacy.c +3 -2
index 669ecff7aa..9d2da7f413 100644
@@ -12,6 +12,7 @@
 
 /* Batch buffer element count, in number of dwords(u32) */
 #define BATCH_DW_COUNT			16
+#define CANCEL				(0x1 << 7)
 #define PREEMPT				(0x1 << 6)
 #define CAT_ERROR			(0x1 << 5)
 #define CLOSE_EXEC_QUEUES		(0x1 << 2)
@@ -100,7 +101,7 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 		u64 exec_addr;
 		int e = i % n_exec_queues;
 
-		if (!i) {
+		if (!i || flags & CANCEL) {
 			spin_opts.addr = base_addr + spin_offset;
 			xe_spin_init(&data[i].spin, &spin_opts);
 			exec_addr = spin_opts.addr;
@@ -155,7 +156,7 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
 	igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0, NULL));
 
-	if (!use_capture_mode && !(flags & GT_RESET)) {
+	if (!use_capture_mode && !(flags & (GT_RESET | CANCEL))) {
 		for (i = 1; i < n_execs; i++)
 			igt_assert_eq(data[i].data, 0xc0ffee);
 	}
tests/intel/xe_exec_reset.c +23 -2
index 72b85d3e7b..88e9df6fbb 100644
@@ -117,6 +117,7 @@ static void test_spin(int fd, struct drm_xe_engine_class_instance *eci,
 #define PARALLEL			(0x1 << 4)
 #define CAT_ERROR			(0x1 << 5)
 #define PREEMPT				(0x1 << 6)
+#define CANCEL				(0x1 << 7)
 
 /**
  * SUBTEST: %s-cat-error
@@ -302,6 +303,12 @@ test_balancer(int fd, int gt, int class, int n_exec_queues, int n_execs,
  * SUBTEST: cancel-preempt
  * Description: Test job cancel with a preemptable job
  *
+ * SUBTEST: cancel-timeslice-preempt
+ * Description: Test job cancel with 2 preemptable jobs
+ *
+ * SUBTEST: cancel-timeslice-many-preempt
+ * Description: Test job cancel with many preemptable jobs
+ *
  * SUBTEST: gt-reset
  * Description: Test GT reset
  *
@@ -396,7 +403,7 @@ test_compute_mode(int fd, struct drm_xe_engine_class_instance *eci,
 		uint64_t exec_addr;
 		int e = i % n_exec_queues;
 
-		if (!i) {
+		if (!i || flags & CANCEL) {
 			spin_opts.addr = base_addr + spin_offset;
 			xe_spin_init(&data[i].spin, &spin_opts);
 			exec_addr = spin_opts.addr;
@@ -451,7 +458,7 @@ test_compute_mode(int fd, struct drm_xe_engine_class_instance *eci,
 	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
 	xe_wait_ufence(fd, &data[0].vm_sync, USER_FENCE_VALUE, 0, 3 * NSEC_PER_SEC);
 
-	if (!(flags & GT_RESET)) {
+	if (!(flags & (GT_RESET | CANCEL))) {
 		for (i = 1; i < n_execs; i++)
 			igt_assert_eq(data[i].data, 0xc0ffee);
 	}
@@ -680,6 +687,20 @@ igt_main
 			break;
 		}
 
+	igt_subtest("cancel-timeslice-preempt")
+		xe_for_each_engine(fd, hwe) {
+			xe_legacy_test_mode(fd, hwe, 2, 2, CANCEL | PREEMPT,
+					    LEGACY_MODE_ADDR, false);
+			break;
+		}
+
+	igt_subtest("cancel-timeslice-many-preempt")
+		xe_for_each_engine(fd, hwe) {
+			xe_legacy_test_mode(fd, hwe, 4, 4, CANCEL | PREEMPT,
+					    LEGACY_MODE_ADDR, false);
+			break;
+		}
+
 	igt_subtest("gt-reset")
 		xe_for_each_engine(fd, hwe)
 			xe_legacy_test_mode(fd, hwe, 2, 2, GT_RESET,
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/3 tests/intel/xe_exec_reset: Long spin tests

In reply to Matthew Brost

Add a long spin test places multiple spinners on an engine instance to ensure they can properly timeslice and complete successfully. This extends the single engine instance tests to multiple threads as well.

These tests are particularly useful for verifying that VF migration works as expected while jobs are actively running on the hardware during the migration process.

---
 lib/xe/xe_legacy.c          |  52 ++++++++++++-
 tests/intel/xe_exec_reset.c | 145 ++++++++++++++++++++++++++++++++++++
 2 files changed, 193 insertions(+), 4 deletions(-)
lib/xe/xe_legacy.c +48 -4
index 9d2da7f413..c0c0c4605c 100644
@@ -12,6 +12,8 @@
 
 /* Batch buffer element count, in number of dwords(u32) */
 #define BATCH_DW_COUNT			16
+#define LONG_SPIN_REUSE_QUEUE		(0x1 << 11)
+#define LONG_SPIN			(0x1 << 8)
 #define CANCEL				(0x1 << 7)
 #define PREEMPT				(0x1 << 6)
 #define CAT_ERROR			(0x1 << 5)
@@ -58,8 +60,14 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 		u64 pad;
 		u32 data;
 	} *data;
-	struct xe_spin_opts spin_opts = { .preempt = flags & PREEMPT };
+	struct xe_spin_opts spin_opts = {
+		.preempt = flags & PREEMPT,
+#define THREE_SEC	(3 * 1000000000ull)
+		.ctx_ticks = flags & LONG_SPIN ?
+			xe_spin_nsec_to_ticks(fd, 0, THREE_SEC) : 0,
+	};
 	int i, b;
+	int extra_execs = (flags & LONG_SPIN_REUSE_QUEUE) ? n_exec_queues : 0;
 
 	igt_assert_lte(n_exec_queues, MAX_N_EXECQUEUES);
 
@@ -67,7 +75,7 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 		fd = drm_open_driver(DRIVER_XE);
 
 	vm = xe_vm_create(fd, 0, 0);
-	bo_size = sizeof(*data) * n_execs;
+	bo_size = sizeof(*data) * (n_execs + extra_execs);
 	bo_size = xe_bb_size(fd, bo_size);
 
 	bo = xe_bo_create(fd, vm, bo_size,
@@ -101,7 +109,8 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 		u64 exec_addr;
 		int e = i % n_exec_queues;
 
-		if (!i || flags & CANCEL) {
+		if (!i || flags & CANCEL ||
+		    (flags & LONG_SPIN && i < n_exec_queues)) {
 			spin_opts.addr = base_addr + spin_offset;
 			xe_spin_init(&data[i].spin, &spin_opts);
 			exec_addr = spin_opts.addr;
@@ -152,12 +161,47 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 
 	igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0, NULL));
 
+	for (i = n_execs; i < n_execs + extra_execs; i++) {
+		u64 base_addr = (!use_capture_mode && (flags & CAT_ERROR) && !i)
+			? (addr + bo_size * 128) : addr;
+		u64 batch_offset = (char *)&data[i].batch - (char *)data;
+		u64 batch_addr = base_addr + batch_offset;
+		u64 sdi_offset = (char *)&data[i].data - (char *)data;
+		u64 sdi_addr = base_addr + sdi_offset;
+		u64 exec_addr;
+		int e = i % n_exec_queues;
+
+		b = 0;
+		data[i].batch[b++] = MI_STORE_DWORD_IMM_GEN4;
+		data[i].batch[b++] = sdi_addr;
+		data[i].batch[b++] = sdi_addr >> 32;
+		data[i].batch[b++] = 0xc0ffee;
+		data[i].batch[b++] = MI_BATCH_BUFFER_END;
+		igt_assert(b <= ARRAY_SIZE(data[i].batch));
+
+		exec_addr = batch_addr;
+
+		sync[0].flags &= ~DRM_XE_SYNC_FLAG_SIGNAL;
+		sync[1].flags |= DRM_XE_SYNC_FLAG_SIGNAL;
+		sync[1].handle = syncobjs[e];
+
+		exec.exec_queue_id = exec_queues[e];
+		exec.address = exec_addr;
+
+		syncobj_reset(fd, &syncobjs[e], 1);
+		xe_exec(fd, &exec);
+	}
+
+	for (i = 0; i < n_exec_queues && extra_execs; i++)
+		igt_assert(syncobj_wait(fd, &syncobjs[i], 1, INT64_MAX, 0, NULL));
+
 	sync[0].flags |= DRM_XE_SYNC_FLAG_SIGNAL;
 	xe_vm_unbind_async(fd, vm, 0, 0, addr, bo_size, sync, 1);
 	igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0, NULL));
 
 	if (!use_capture_mode && !(flags & (GT_RESET | CANCEL))) {
-		for (i = 1; i < n_execs; i++)
+		for (i = flags & LONG_SPIN ? n_exec_queues : 1;
+		     i < n_execs + extra_execs; i++)
 			igt_assert_eq(data[i].data, 0xc0ffee);
 	}
 
tests/intel/xe_exec_reset.c +145 -0

163 lines not on this page · raw message

Signature · 1 line
2.34.1