[PATCH 4/4] tests/intel/xe_vm: Move vm fault tests from xe_fault_injection to xe_vm
Jonathan Cavitt
jonathan.cavitt at intel.com
Fri Aug 22 20:57:10 UTC 2025
Move the fault injection tests that exercise the xe vm ioctl from the
xe_fault_injection test suite to the xe_vm test suite.
Signed-off-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
---
tests/intel/xe_fault_injection.c | 121 ---------------------------
tests/intel/xe_vm.c | 138 +++++++++++++++++++++++++++++++
2 files changed, 138 insertions(+), 121 deletions(-)
diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index 92b09cbb90..06b7bcab3d 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -172,104 +172,6 @@ exec_queue_create_fail(int fd, struct drm_xe_engine_class_instance *instance,
xe_exec_queue_destroy(fd, exec_queue_id);
}
-static int
-simple_vm_create(int fd, unsigned int flags)
-{
- struct drm_xe_vm_create create = {
- .flags = flags,
- };
-
- return igt_ioctl(fd, DRM_IOCTL_XE_VM_CREATE, &create);
-}
-
-/**
- * SUBTEST: vm-create-fail-%s
- * Description: inject an error in function %arg[1] used in vm create IOCTL to make it fail
- * Functionality: fault
- *
- * arg[1]:
- * @xe_exec_queue_create_bind: xe_exec_queue_create_bind
- * @xe_pt_create: xe_pt_create
- * @xe_vm_create_scratch: xe_vm_create_scratch
- */
-static void
-vm_create_fail(int fd, const char pci_slot[],
- const char function_name[], unsigned int flags)
-{
- igt_assert_eq(simple_vm_create(fd, flags), 0);
-
- injection_ignore_dmesg_errors_from_dut(pci_slot);
- injection_list_add(function_name);
- injection_set_retval(function_name, INJECT_ERRNO);
- igt_assert(simple_vm_create(fd, flags) != 0);
- injection_list_remove(function_name);
-
- igt_assert_eq(simple_vm_create(fd, flags), 0);
-}
-
-static int
-simple_vm_bind(int fd, uint32_t vm)
-{
- struct {
- uint32_t batch[16];
- uint64_t pad;
- uint32_t data;
- } *data;
- struct drm_xe_sync syncobj = {
- .type = DRM_XE_SYNC_TYPE_SYNCOBJ,
- .flags = DRM_XE_SYNC_FLAG_SIGNAL,
- .handle = syncobj_create(fd, 0),
- };
- struct drm_xe_vm_bind bind = {
- .vm_id = vm,
- .num_binds = 1,
- .bind.obj = 0,
- .bind.range = BO_SIZE,
- .bind.addr = BO_ADDR,
- .bind.op = DRM_XE_VM_BIND_OP_MAP_USERPTR,
- .bind.pat_index = intel_get_pat_idx_wb(fd),
- .bind.flags = 0,
- .num_syncs = 1,
- .syncs = (uintptr_t)&syncobj,
- .exec_queue_id = 0,
- };
-
- data = aligned_alloc(xe_get_default_alignment(fd), BO_SIZE);
- bind.bind.obj_offset = to_user_pointer(data);
-
- return igt_ioctl(fd, DRM_IOCTL_XE_VM_BIND, &bind);
-}
-
-/**
- * SUBTEST: vm-bind-fail-%s
- * Description: inject an error in function %arg[1] used in vm bind IOCTL
- * to make it fail
- * Functionality: fault
- *
- * arg[1]:
- * @vm_bind_ioctl_ops_create: vm_bind_ioctl_ops_create
- * @vm_bind_ioctl_ops_execute: vm_bind_ioctl_ops_execute
- * @xe_pt_update_ops_prepare: xe_pt_update_ops_prepare
- * @xe_pt_update_ops_run: xe_pt_update_ops_run
- * @xe_vma_ops_alloc: xe_vma_ops_alloc
- * @xe_sync_entry_parse: xe_sync_entry_parse
- */
-static void
-vm_bind_fail(int fd, const char pci_slot[], const char function_name[])
-{
- uint32_t vm = xe_vm_create(fd, 0, 0);
-
- igt_assert_eq(simple_vm_bind(fd, vm), 0);
-
- injection_ignore_dmesg_errors_from_dut(pci_slot);
- injection_list_add(function_name);
- injection_set_retval(function_name, INJECT_ERRNO);
- igt_assert(simple_vm_bind(fd, vm) != 0);
- injection_list_remove(function_name);
-
- igt_assert_eq(simple_vm_bind(fd, vm), 0);
-}
-
static int opt_handler(int opt, int opt_index, void *data)
{
int in_param;
@@ -325,21 +227,6 @@ igt_main_args("I:", NULL, help_str, opt_handler, NULL)
{ "xe_wopcm_init", 0, true },
{ }
};
- const struct section vm_create_fail_functions[] = {
- { "xe_exec_queue_create_bind", 0 },
- { "xe_pt_create", 0 },
- { "xe_vm_create_scratch", DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE },
- { }
- };
- const struct section vm_bind_fail_functions[] = {
- { "vm_bind_ioctl_ops_create" },
- { "vm_bind_ioctl_ops_execute" },
- { "xe_pt_update_ops_prepare" },
- { "xe_pt_update_ops_run" },
- { "xe_vma_ops_alloc" },
- { "xe_sync_entry_parse" },
- { }
- };
const struct section exec_queue_create_fail_functions[] = {
{ "xe_exec_queue_create", 0 },
@@ -369,14 +256,6 @@ igt_main_args("I:", NULL, help_str, opt_handler, NULL)
is_vf_device = intel_is_vf_device(fd);
}
- for (const struct section *s = vm_create_fail_functions; s->name; s++)
- igt_subtest_f("vm-create-fail-%s", s->name)
- vm_create_fail(fd, pci_slot, s->name, s->flags);
-
- for (const struct section *s = vm_bind_fail_functions; s->name; s++)
- igt_subtest_f("vm-bind-fail-%s", s->name)
- vm_bind_fail(fd, pci_slot, s->name);
-
for (const struct section *s = exec_queue_create_fail_functions; s->name; s++)
igt_subtest_f("exec-queue-create-fail-%s", s->name)
xe_for_each_engine(fd, hwe)
diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index 7271ee4123..18774268de 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -11,6 +11,7 @@
*/
#include "igt.h"
+#include "igt_device.h"
#include "intel_pat.h"
#include "lib/igt_syncobj.h"
#include "lib/intel_reg.h"
@@ -2462,10 +2463,109 @@ static void test_oom(int fd)
}
}
+static int
+simple_vm_create(int fd, unsigned int flags)
+{
+ struct drm_xe_vm_create create = {
+ .flags = flags,
+ };
+
+ return igt_ioctl(fd, DRM_IOCTL_XE_VM_CREATE, &create);
+}
+
+/**
+ * SUBTEST: vm-create-fail-%s
+ * Description: inject an error in function %arg[1] used in vm create IOCTL to make it fail
+ * Functionality: fault
+ *
+ * arg[1]:
+ * @xe_exec_queue_create_bind: xe_exec_queue_create_bind
+ * @xe_pt_create: xe_pt_create
+ * @xe_vm_create_scratch: xe_vm_create_scratch
+ */
+static void
+vm_create_fail(int fd, const char pci_slot[],
+ const char function_name[], unsigned int flags)
+{
+ igt_assert_eq(simple_vm_create(fd, flags), 0);
+
+ injection_ignore_dmesg_errors_from_dut(pci_slot);
+ injection_list_add(function_name);
+ injection_set_retval(function_name, -ENOMEM);
+ igt_assert(simple_vm_create(fd, flags) != 0);
+ injection_list_remove(function_name);
+
+ igt_assert_eq(simple_vm_create(fd, flags), 0);
+}
+
+static int
+simple_vm_bind(int fd, uint32_t vm)
+{
+ struct {
+ uint32_t batch[16];
+ uint64_t pad;
+ uint32_t data;
+ } *data;
+ struct drm_xe_sync syncobj = {
+ .type = DRM_XE_SYNC_TYPE_SYNCOBJ,
+ .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+ .handle = syncobj_create(fd, 0),
+ };
+ struct drm_xe_vm_bind bind = {
+ .vm_id = vm,
+ .num_binds = 1,
+ .bind.obj = 0,
+ .bind.range = BO_SIZE,
+ .bind.addr = 0x1a0000,
+ .bind.op = DRM_XE_VM_BIND_OP_MAP_USERPTR,
+ .bind.pat_index = intel_get_pat_idx_wb(fd),
+ .bind.flags = 0,
+ .num_syncs = 1,
+ .syncs = (uintptr_t)&syncobj,
+ .exec_queue_id = 0,
+ };
+
+ data = aligned_alloc(xe_get_default_alignment(fd), BO_SIZE);
+ bind.bind.obj_offset = to_user_pointer(data);
+
+ return igt_ioctl(fd, DRM_IOCTL_XE_VM_BIND, &bind);
+}
+
+/**
+ * SUBTEST: vm-bind-fail-%s
+ * Description: inject an error in function %arg[1] used in vm bind IOCTL
+ * to make it fail
+ * Functionality: fault
+ *
+ * arg[1]:
+ * @vm_bind_ioctl_ops_create: vm_bind_ioctl_ops_create
+ * @vm_bind_ioctl_ops_execute: vm_bind_ioctl_ops_execute
+ * @xe_pt_update_ops_prepare: xe_pt_update_ops_prepare
+ * @xe_pt_update_ops_run: xe_pt_update_ops_run
+ * @xe_vma_ops_alloc: xe_vma_ops_alloc
+ * @xe_sync_entry_parse: xe_sync_entry_parse
+ */
+static void
+vm_bind_fail(int fd, const char pci_slot[], const char function_name[])
+{
+ uint32_t vm = xe_vm_create(fd, 0, 0);
+
+ igt_assert_eq(simple_vm_bind(fd, vm), 0);
+
+ injection_ignore_dmesg_errors_from_dut(pci_slot);
+ injection_list_add(function_name);
+ injection_set_retval(function_name, -ENOMEM);
+ igt_assert(simple_vm_bind(fd, vm) != 0);
+ injection_list_remove(function_name);
+
+ igt_assert_eq(simple_vm_bind(fd, vm), 0);
+}
+
igt_main
{
struct drm_xe_engine_class_instance *hwe, *hwe_non_copy = NULL;
uint64_t bind_size;
+ char pci_slot[NAME_MAX];
int fd;
const struct section {
const char *name;
@@ -2574,6 +2674,27 @@ igt_main
{ }
};
+ const struct fault_section {
+ const char *name;
+ unsigned int flags;
+ bool pf_only;
+ } vm_create_fail_functions[] = {
+ { "xe_exec_queue_create_bind", 0 },
+ { "xe_pt_create", 0 },
+ { "xe_vm_create_scratch", DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE },
+ { }
+ };
+
+ const struct fault_section vm_bind_fail_functions[] = {
+ { "vm_bind_ioctl_ops_create" },
+ { "vm_bind_ioctl_ops_execute" },
+ { "xe_pt_update_ops_prepare" },
+ { "xe_pt_update_ops_run" },
+ { "xe_vma_ops_alloc" },
+ { "xe_sync_entry_parse" },
+ { }
+ };
+
igt_fixture {
fd = drm_open_driver(DRIVER_XE);
@@ -2866,6 +2987,23 @@ igt_main
test_oom(fd);
}
+ igt_subtest_group {
+ igt_fixture {
+ igt_require(fail_function_injection_enabled());
+ injection_setup_fault(&default_fault_params);
+ injection_exit_handler();
+ igt_device_get_pci_slot_name(fd, pci_slot);
+ }
+
+ for (const struct fault_section *s = vm_create_fail_functions; s->name; s++)
+ igt_subtest_f("vm-create-fail-%s", s->name)
+ vm_create_fail(fd, pci_slot, s->name, s->flags);
+
+ for (const struct fault_section *s = vm_bind_fail_functions; s->name; s++)
+ igt_subtest_f("vm-bind-fail-%s", s->name)
+ vm_bind_fail(fd, pci_slot, s->name);
+ }
+
igt_fixture
drm_close_driver(fd);
}
--
2.43.0
More information about the igt-dev
mailing list