[PATCH v2 2/4] tests/intel/xe_vm: Use fault injection interface for error injection test

Jonathan Cavitt jonathan.cavitt at intel.com
Tue Aug 26 20:18:27 UTC 2025


The test xe_vm at bind-array-conflict-error-inject currently uses a
separate error injection mechanism that isn't unified with the existing
error injection framework.  This separate error injection framework is
disabled when CONFIG_DRM_XE_DEBUG is not set, which violates the
guarantee CONFIG_DRM_XE_DEBUG has no functional impact.  Modify the test
to use the fault injection framework that the other xe_fault_injection
tests use.

v2: Allow error injection into xe_pt_update_ops_prepare and
xe_pt_update_ops_run as a part of the bind-array-conflict-error-inject
test.  Additionally, update the name of the test to denote which
function is being error injected (Brost, Harrison)

Suggested-by: John Harrison <john.c.harrison at intel.com>
Signed-off-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
Cc: Matthew Brost <matthew.d.brost at intel.com>
---
 tests/intel/xe_vm.c | 46 +++++++++++++++++++++++++++++++++------------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index 7a37bfe052..6bef25851e 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -16,6 +16,7 @@
 #include "lib/intel_reg.h"
 #include "xe_drm.h"
 
+#include "xe/xe_fault_injection.h"
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
 #include "xe/xe_spin.h"
@@ -1038,14 +1039,18 @@ test_bind_array(int fd, struct drm_xe_engine_class_instance *eci, int n_execs,
  * Description: Test binding with conflicting address
  * Test category: functionality test
  *
- * SUBTEST: bind-array-conflict-error-inject
- * Functionality: bind exec_queues and page table updates error paths
+ * SUBTEST: bind-array-conflict-error-inject-%s
+ * Functionality: bind exec_queues and page table updates error paths by injecting into %arg[1]
  * Description: Test bind array with conflicting address plus error injection
  * Test category: functionality test
+ *
+ * arg[1].values: vm_bind_ioctl_ops_lock_and_prep
+ * arg[1].values: xe_pt_update_ops_prepare
+ * arg[1].values: xe_pt_update_ops_run
  */
 static void
 test_bind_array_conflict(int fd, struct drm_xe_engine_class_instance *eci,
-			 bool no_array, bool error_inject)
+			 bool no_array, const char error_inject[])
 {
 	uint32_t vm;
 	uint64_t addr = 0x1a00000;
@@ -1178,13 +1183,12 @@ test_bind_array_conflict(int fd, struct drm_xe_engine_class_instance *eci,
 
 		if (error_inject) {
 			sync[0].flags |= DRM_XE_SYNC_FLAG_SIGNAL;
-			bind_ops[BIND_ARRAY_CONFLICT_NUM_BINDS - 1].flags |=
-				0x1 << 31;
+			injection_list_add(error_inject);
+			injection_set_retval(error_inject, -ENOSPC);
 			xe_vm_bind_array_err(fd, vm, 0, bind_ops,
 					     BIND_ARRAY_CONFLICT_NUM_BINDS,
 					     sync, 1, ENOSPC);
-			bind_ops[BIND_ARRAY_CONFLICT_NUM_BINDS - 1].flags &=
-				~(0x1 << 31);
+			injection_list_remove(error_inject);
 
 			/* Verify existing mappings still works */
 			i = 1;
@@ -2573,6 +2577,12 @@ igt_main
                 { }
         };
 
+	const char *error_inject_list[] = {
+		"vm_bind_ioctl_ops_lock_and_prep",
+		"xe_pt_update_ops_prepare",
+		"xe_pt_update_ops_run",
+	};
+
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_XE);
 
@@ -2667,15 +2677,27 @@ igt_main
 
 	igt_subtest("bind-array-conflict")
 		xe_for_each_engine(fd, hwe)
-			test_bind_array_conflict(fd, hwe, false, false);
+			test_bind_array_conflict(fd, hwe, false, NULL);
 
 	igt_subtest("bind-no-array-conflict")
 		xe_for_each_engine(fd, hwe)
-			test_bind_array_conflict(fd, hwe, true, false);
+			test_bind_array_conflict(fd, hwe, true, NULL);
 
-	igt_subtest("bind-array-conflict-error-inject")
-		xe_for_each_engine(fd, hwe)
-			test_bind_array_conflict(fd, hwe, false, true);
+	igt_subtest_group {
+		igt_fixture {
+			igt_require(fail_function_injection_enabled());
+			injection_setup_fault(&default_fault_params);
+			injection_exit_handler();
+		}
+
+		for (int i = 0; i < ARRAY_SIZE(error_inject_list); i++) {
+			const char *func_name = error_inject_list[i];
+			igt_subtest_f("bind-array-conflict-error-inject-%s", func_name) {
+				xe_for_each_engine(fd, hwe)
+					test_bind_array_conflict(fd, hwe, false, func_name);
+			}
+		}
+	}
 
 	igt_subtest("bind-array-flag-invalid")
 		test_bind_flag_invalid(fd, 16);
-- 
2.43.0



More information about the igt-dev mailing list