Skip to contentSkip to conversation

xe: Test LR and fault mode workloads across suspend/resume

PATCH Superseded Thomas Hellström 1 participant 4 messages May 21

lore
Share & tools
lore
#0 lore raw

cover xe: Test LR and fault mode workloads across suspend/resume

These patches extend xe_exec_compute_mode and xe_exec_fault_mode with tests that verify GPU workloads survive system suspend and resume.

The new subtests run a preemptible spinner on a copy engine and then trigger a full suspend/resume cycle — covering s2idle, S3 and S4 — while the workload is active. After resume, the tests confirm the workload is still making forward progress before stopping it cleanly. This exercises the driver's ability to park and restore LR-mode and fault-mode execution contexts across power state transitions.

Thomas Hellström (3):
tests/xe_exec_compute_mode: Make lr-mode-workload spinner preemptible tests/xe_exec_compute_mode: Add workload subtests with suspend
variants
tests/xe_exec_fault_mode: Add fault-mode workload subtests with
suspend variants

 tests/intel/xe_exec_compute_mode.c |  51 ++++++++++--
 tests/intel/xe_exec_fault_mode.c   | 123 ++++++++++++++++++++++++++++-
 2 files changed, 165 insertions(+), 9 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/3 tests/xe_exec_compute_mode: Make lr-mode-workload spinner preemptible

Enable preemption in the xe_spin used by lr-mode-workload by passing .preempt = true to xe_spin_init_opts(). This allows the workload to be preempted during the 30s stress run, which is needed to test LR mode behavior under preemption (e.g. during suspend/resume).

Assisted-by GitHub_Copilot:claude-sonnet-4.6
---
 tests/intel/xe_exec_compute_mode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tests/intel/xe_exec_compute_mode.c +3 -2
index 438ea163f..869f8fbe1 100644
@@ -324,7 +324,7 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
 #define LR_SPINNER_TIME 30
 /**
  * SUBTEST: lr-mode-workload
- * Description: Stress LR mode workload for 30s.
+ * Description: Stress preemptible LR mode workload for 30s.
  * Test category: functionality test
  */
 static void lr_mode_workload(int fd)
@@ -368,7 +368,8 @@ static void lr_mode_workload(int fd)
 	xe_vm_bind_async(fd, vm, 0, bo, 0, spin_addr, bo_size, &sync, 1);
 	xe_wait_ufence(fd, &vm_sync, USER_FENCE_VALUE, 0, NSEC_PER_SEC);
 
-	xe_spin_init_opts(spin, .addr = spin_addr, .write_timestamp = true);
+	xe_spin_init_opts(spin, .addr = spin_addr, .write_timestamp = true,
+			  .preempt = true);
 	sync.addr = spin_addr + (char *)&spin->exec_sync - (char *)spin;
 	exec.exec_queue_id = exec_queue;
 	exec.address = spin_addr;
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/3 tests/xe_exec_compute_mode: Add workload subtests with suspend variants

In reply to Thomas Hellström

Refactor lr_mode_workload() into run_lr_workload() taking an igt_suspend_state argument, using SUSPEND_STATE_NONE as a sentinel for the no-suspend case. Register all variants from a single table:

  lr-mode-workload         (no suspend, 30s stress)
  s2idle-lr-mode-workload  (SUSPEND_STATE_FREEZE)
  s3-lr-mode-workload      (SUSPEND_STATE_S3)
  s4-lr-mode-workload      (SUSPEND_STATE_DISK)

The suspend variants perform a full suspend/resume cycle while the preemptible spinner is running, then assert the workload resumes and can be cleanly stopped.

Assisted-by GitHub_Copilot:claude-sonnet-4.6
---
 tests/intel/xe_exec_compute_mode.c | 46 ++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 6 deletions(-)
tests/intel/xe_exec_compute_mode.c +40 -6
index 869f8fbe1..8fc9bb912 100644
@@ -322,12 +322,26 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
 }
 
 #define LR_SPINNER_TIME 30
+#define SUSPEND_STATE_NONE ((enum igt_suspend_state)-1)
+
 /**
  * SUBTEST: lr-mode-workload
  * Description: Stress preemptible LR mode workload for 30s.
  * Test category: functionality test
+ *
+ * SUBTEST: s2idle-lr-mode-workload
+ * Description: Suspend to idle (s2idle) with a preemptible LR mode workload running.
+ * Test category: functionality test
+ *
+ * SUBTEST: s3-lr-mode-workload
+ * Description: Suspend to RAM (s3) with a preemptible LR mode workload running.
+ * Test category: functionality test
+ *
+ * SUBTEST: s4-lr-mode-workload
+ * Description: Suspend to disk (s4) with a preemptible LR mode workload running.
+ * Test category: functionality test
  */
-static void lr_mode_workload(int fd)
+static void run_lr_workload(int fd, enum igt_suspend_state s_state)
 {
 	struct drm_xe_sync sync = {
 		.type = DRM_XE_SYNC_TYPE_USER_FENCE,
@@ -376,8 +390,15 @@ static void lr_mode_workload(int fd)
 	xe_exec(fd, &exec);
 	xe_spin_wait_started(spin);
 
-	/* Collect and check timestamps before stopping the spinner */
-	sleep(LR_SPINNER_TIME);
+	if (s_state != SUSPEND_STATE_NONE) {
+		enum igt_suspend_test test = s_state == SUSPEND_STATE_DISK ?
+					     SUSPEND_TEST_DEVICES : SUSPEND_TEST_NONE;
+		igt_system_suspend_autoresume(s_state, test);
+	} else {
+		sleep(LR_SPINNER_TIME);
+	}
+
+	/* Collect and check timestamps - workload should still be running */
 	ts_1 = spin->timestamp;
 	sleep(1);
 	ts_2 = spin->timestamp;
@@ -462,9 +483,22 @@ int igt_main()
 					  s->flags);
 	}
 
-	igt_subtest("lr-mode-workload")
-		lr_mode_workload(fd);
-
+	{
+		static const struct {
+			const char *name;
+			enum igt_suspend_state state;
+		} suspend_states[] = {
+			{ "",        SUSPEND_STATE_NONE },
+			{ "s2idle-", SUSPEND_STATE_FREEZE },
+			{ "s3-",     SUSPEND_STATE_S3 },
+			{ "s4-",     SUSPEND_STATE_DISK },
+			{ NULL },
+		};
+
+		for (const __typeof__(*suspend_states) *s = suspend_states; s->name; s++)
+			igt_subtest_f("%slr-mode-workload", s->name)
+				run_lr_workload(fd, s->state);
+	}
 
 	igt_fixture()
 		drm_close_driver(fd);
Signature · 1 line
2.54.0
#3 lore raw

PATCH 3/3 tests/xe_exec_fault_mode: Add fault-mode workload subtests with suspend variants

In reply to Thomas Hellström

Add run_fault_workload() using SUSPEND_STATE_NONE as a sentinel for the no-suspend case. All variants are registered from a single table:

  fault-mode-workload         (no suspend, 30s stress)
  s2idle-fault-mode-workload  (SUSPEND_STATE_FREEZE)
  s3-fault-mode-workload      (SUSPEND_STATE_S3)
  s4-fault-mode-workload      (SUSPEND_STATE_DISK)

The suspend variants perform a full suspend/resume cycle while the preemptible spinner is running on an LR+fault-mode VM, then assert the workload resumes and can be cleanly stopped.

To support the new code, include xe/xe_spin.h and hoist USER_FENCE_VALUE to file scope.

Assisted-by GitHub_Copilot:claude-sonnet-4.6
---
 tests/intel/xe_exec_fault_mode.c | 123 ++++++++++++++++++++++++++++++-
 1 file changed, 122 insertions(+), 1 deletion(-)
tests/intel/xe_exec_fault_mode.c +122 -1
index 3e92dfbd9..c0a067f04 100644
@@ -21,9 +21,11 @@
 
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
+#include "xe/xe_spin.h"
 #include <string.h>
 
 #define MAX_N_EXEC_QUEUES	16
+#define USER_FENCE_VALUE	0xdeadbeefdeadbeefull
 
 #define USERPTR		(0x1 << 0)
 #define REBIND		(0x1 << 1)
@@ -145,7 +147,6 @@ test_exec(int fd, struct drm_xe_engine_class_instance *eci,
 	uint32_t vm;
 	uint64_t addr = 0x1a0000;
 	uint64_t sync_addr = 0x101a0000;
-#define USER_FENCE_VALUE	0xdeadbeefdeadbeefull
 	struct drm_xe_sync sync[1] = {
 		{ .type = DRM_XE_SYNC_TYPE_USER_FENCE, .flags = DRM_XE_SYNC_FLAG_SIGNAL,
 	          .timeline_value = USER_FENCE_VALUE },
@@ -453,6 +454,109 @@ test_exec_main(int fd, int n_exec_queues, int n_execs, unsigned int flags)
 	}
 }
 
+#define SUSPEND_STATE_NONE ((enum igt_suspend_state)-1)
+
+/**
+ * SUBTEST: fault-mode-workload
+ * Description: Stress preemptible fault mode workload for 30s.
+ * Test category: functionality test
+ *
+ * SUBTEST: s2idle-fault-mode-workload
+ * Description: Suspend to idle (s2idle) with a preemptible fault mode workload running.
+ * Test category: functionality test
+ *
+ * SUBTEST: s3-fault-mode-workload
+ * Description: Suspend to RAM (s3) with a preemptible fault mode workload running.
+ * Test category: functionality test
+ *
+ * SUBTEST: s4-fault-mode-workload
+ * Description: Suspend to disk (s4) with a preemptible fault mode workload running.
+ * Test category: functionality test
+ */
+static void run_fault_workload(int fd, enum igt_suspend_state s_state)
+{
+	struct drm_xe_sync sync = {
+		.type = DRM_XE_SYNC_TYPE_USER_FENCE,
+		.flags = DRM_XE_SYNC_FLAG_SIGNAL,
+		.timeline_value = USER_FENCE_VALUE,
+	};
+	struct drm_xe_exec exec = {
+		.num_batch_buffer = 1,
+		.num_syncs = 1,
+		.syncs = to_user_pointer(&sync),
+	};
+	struct xe_spin *spin;
+	struct drm_xe_engine *engine;
+	uint64_t vm_sync;
+	size_t bo_size;
+	uint32_t vm;
+	uint32_t exec_queue;
+	uint64_t spin_addr;
+	uint64_t ahnd;
+	uint32_t bo;
+	uint32_t ts_1, ts_2;
+
+	vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE |
+			  DRM_XE_VM_CREATE_FLAG_FAULT_MODE, 0);
+	ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_RELOC);
+	bo_size = xe_bb_size(fd, sizeof(*spin));
+	engine = xe_find_engine_by_class(fd, DRM_XE_ENGINE_CLASS_COPY);
+	igt_assert(engine);
+
+	bo = xe_bo_create(fd, vm, bo_size, vram_if_possible(fd, engine->instance.gt_id),
+			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+	spin = xe_bo_map(fd, bo, bo_size);
+
+	exec_queue = xe_exec_queue_create(fd, vm, &engine->instance, 0);
+	spin_addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0,
+							ALLOC_STRATEGY_LOW_TO_HIGH);
+
+	sync.addr = to_user_pointer(&vm_sync);
+	xe_vm_bind_async(fd, vm, 0, bo, 0, spin_addr, bo_size, &sync, 1);
+	xe_wait_ufence(fd, &vm_sync, USER_FENCE_VALUE, 0, NSEC_PER_SEC);
+
+	xe_spin_init_opts(spin, .addr = spin_addr, .write_timestamp = true,
+			  .preempt = true);
+	sync.addr = spin_addr + (char *)&spin->exec_sync - (char *)spin;
+	exec.exec_queue_id = exec_queue;
+	exec.address = spin_addr;
+	xe_exec(fd, &exec);
+	xe_spin_wait_started(spin);
+
+	if (s_state != SUSPEND_STATE_NONE) {
+		enum igt_suspend_test test = s_state == SUSPEND_STATE_DISK ?
+					     SUSPEND_TEST_DEVICES : SUSPEND_TEST_NONE;
+		igt_system_suspend_autoresume(s_state, test);
+	} else {
+		sleep(30);
+	}
+
+	/* Collect and check timestamps - workload should still be running */
+	ts_1 = spin->timestamp;
+	sleep(1);
+	ts_2 = spin->timestamp;
+	igt_assert_neq_u32(ts_1, ts_2);
+
+	xe_spin_end(spin);
+	xe_wait_ufence(fd, &spin->exec_sync, USER_FENCE_VALUE, 0, NSEC_PER_SEC);
+
+	/* Check timestamps to make sure spinner is stopped */
+	ts_1 = spin->timestamp;
+	sleep(1);
+	ts_2 = spin->timestamp;
+	igt_assert_eq_u32(ts_1, ts_2);
+
+	sync.addr = to_user_pointer(&vm_sync);
+	xe_vm_unbind_async(fd, vm, 0, 0, spin_addr, bo_size, &sync, 1);
+	xe_wait_ufence(fd, &vm_sync, USER_FENCE_VALUE, 0, NSEC_PER_SEC);
+	munmap(spin, bo_size);
+	gem_close(fd, bo);
+
+	xe_exec_queue_destroy(fd, exec_queue);
+	xe_vm_destroy(fd, vm);
+	put_ahnd(ahnd);
+}
+
 int igt_main()
 {
 	struct drm_xe_engine_class_instance *hwe;
@@ -589,6 +693,23 @@ int igt_main()
 		xe_for_each_engine(fd, hwe)
 			test_exec(fd, hwe, 1, 1, ENABLE_SCRATCH | INVALID_VA);
 
+	{
+		static const struct {
+			const char *name;
+			enum igt_suspend_state state;
+		} suspend_states[] = {
+			{ "",        SUSPEND_STATE_NONE },
+			{ "s2idle-", SUSPEND_STATE_FREEZE },
+			{ "s3-",     SUSPEND_STATE_S3 },
+			{ "s4-",     SUSPEND_STATE_DISK },
+			{ NULL },
+		};
+
+		for (const __typeof__(*suspend_states) *s = suspend_states; s->name; s++)
+			igt_subtest_f("%sfault-mode-workload", s->name)
+				run_fault_workload(fd, s->state);
+	}
+
 	igt_fixture() {
 		drm_close_driver(fd);
 	}
Signature · 1 line
2.54.0