Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pravalika Gurram <pravalika.gurram@intel.com>
To: igt-dev@lists.freedesktop.org, francois.dugast@intel.com,
	kamil.konieczny@linux.intel.com
Cc: Pravalika Gurram <pravalika.gurram@intel.com>
Subject: [PATCH v4] tests/intel/xe_fault_injection: Inject errors during exec queue create IOCTL
Date: Wed,  5 Mar 2025 11:08:52 +0530	[thread overview]
Message-ID: <20250305053852.324282-1-pravalika.gurram@intel.com> (raw)

Use the fault injection infrastructure to make targeted internal KMD
functions fail when executing xe_exec_queue_create_ioctl()
so that more code paths are tested, such as error handling and unwinding.
include xe_exec_queue_create_bind only for VM_BIND engine class.
xe_exec_queue_destroy_ioctl() and
xe_exec_queue_get_property_ioctl() are not considered as there is
no unwinding code to test with fault injection.

v2: Added separate case for vm_bind engine class

Signed-off-by: Pravalika Gurram <pravalika.gurram@intel.com>
---
 tests/intel/xe_fault_injection.c | 56 ++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index 7ae941367..1f107ec93 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -185,6 +185,37 @@ inject_fault_probe(int fd, char pci_slot[], const char function_name[])
 	injection_list_do(INJECTION_LIST_REMOVE, function_name);
 }
 
+/**
+ * SUBTEST: exec-queue-create-fail-%s
+ * Description: inject an error in function %arg[1] used in exec queue create IOCTL to make it fail
+ * Functionality: fault
+ *
+ * arg[1]:
+ * @xe_exec_queue_create:                 xe_exec_queue_create
+ * @xe_hw_engine_group_add_exec_queue:    xe_hw_engine_group_add_exec_queue
+ * @xe_vm_add_compute_exec_queue:         xe_vm_add_compute_exec_queue
+ * @xe_exec_queue_create_bind:            xe_exec_queue_create_bind
+ */
+static void
+exec_queue_create_fail(int fd, struct drm_xe_engine_class_instance *instance,
+		const char function_name[], unsigned int flags)
+{
+	uint32_t exec_queue_id;
+	uint32_t vm = xe_vm_create(fd, flags, 0);
+	/* sanity check */
+	igt_assert_eq(__xe_exec_queue_create(fd, vm, 1, 1, instance, 0, &exec_queue_id), 0);
+	xe_exec_queue_destroy(fd, exec_queue_id);
+
+	ignore_faults_in_dmesg(function_name);
+	injection_list_do(INJECTION_LIST_ADD, function_name);
+	set_retval(function_name, INJECT_ERRNO);
+	igt_assert(__xe_exec_queue_create(fd, vm, 1, 1, instance, 0, &exec_queue_id) != 0);
+	injection_list_do(INJECTION_LIST_REMOVE, function_name);
+
+	igt_assert_eq(__xe_exec_queue_create(fd, vm, 1, 1, instance, 0, &exec_queue_id), 0);
+	xe_exec_queue_destroy(fd, exec_queue_id);
+}
+
 static int
 simple_vm_create(int fd, unsigned int flags)
 {
@@ -283,6 +314,7 @@ vm_bind_fail(int fd, const char function_name[])
 igt_main
 {
 	int fd;
+	struct drm_xe_engine_class_instance *hwe;
 	char pci_slot[NAME_MAX];
 	const struct section {
 		const char *name;
@@ -318,6 +350,18 @@ igt_main
 		{ }
 	};
 
+	const struct section exec_queue_create_fail_functions[] = {
+		{ "xe_exec_queue_create", 0 },
+		{ "xe_hw_engine_group_add_exec_queue", 0 },
+		{ "xe_vm_add_compute_exec_queue", DRM_XE_VM_CREATE_FLAG_LR_MODE },
+		{ }
+	};
+
+	const struct section exec_queue_create_vmbind_fail_functions[] = {
+		{ "xe_exec_queue_create_bind", 0 },
+		{ }
+	};
+
 	igt_fixture {
 		igt_require(fail_function_injection_enabled());
 		fd = drm_open_driver(DRIVER_XE);
@@ -333,6 +377,18 @@ igt_main
 		igt_subtest_f("vm-bind-fail-%s", s->name)
 			vm_bind_fail(fd, 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)
+				if (hwe->engine_class != DRM_XE_ENGINE_CLASS_VM_BIND)
+					exec_queue_create_fail(fd, hwe, s->name, s->flags);
+
+	for (const struct section *s = exec_queue_create_vmbind_fail_functions; s->name; s++)
+		igt_subtest_f("exec-queue-create-fail-%s", s->name)
+			xe_for_each_engine(fd, hwe)
+				if (hwe->engine_class == DRM_XE_ENGINE_CLASS_VM_BIND)
+					exec_queue_create_fail(fd, hwe, s->name, s->flags);
+
 	igt_fixture {
 		xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_UNBIND);
 	}
-- 
2.34.1


             reply	other threads:[~2025-03-05  5:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05  5:38 Pravalika Gurram [this message]
2025-03-05  5:43 ` [PATCH v4] tests/intel/xe_fault_injection: Inject errors during exec queue create IOCTL Dandamudi, Priyanka
2025-03-05 11:27 ` ✗ Xe.CI.BAT: failure for tests/intel/xe_fault_injection: Inject errors during exec queue create IOCTL (rev4) Patchwork
2025-03-07 13:28   ` Gurram, Pravalika
2025-03-05 11:42 ` ✓ i915.CI.BAT: success " Patchwork
2025-03-05 12:17 ` [PATCH v4] tests/intel/xe_fault_injection: Inject errors during exec queue create IOCTL Kamil Konieczny
2025-03-05 13:47 ` ✗ Xe.CI.Full: failure for tests/intel/xe_fault_injection: Inject errors during exec queue create IOCTL (rev4) Patchwork
2025-03-07 13:31   ` Gurram, Pravalika

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250305053852.324282-1-pravalika.gurram@intel.com \
    --to=pravalika.gurram@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox