From: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Satyanarayana K V P" <satyanarayana.k.v.p@intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Michał Wajdeczko" <michal.wajdeczko@intel.com>,
"Francois Dugast" <francois.dugast@intel.com>,
"Marcin Bernatowicz" <marcin.bernatowicz@linux.intel.com>
Subject: [PATCH i-g-t v4 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv
Date: Wed, 22 Jan 2025 13:08:08 +0530 [thread overview]
Message-ID: <20250122073808.16288-3-satyanarayana.k.v.p@intel.com> (raw)
In-Reply-To: <20250122073808.16288-1-satyanarayana.k.v.p@intel.com>
Use the kernel fault injection infrastructure to test error handling
of xe at enabling of VFs stage when executing xe_guc_ct_send_recv()
so that more code paths are tested, such as error handling and unwinding.
Error can be injected using:
igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
v2: Updated guc_fail_* to enable_vfs_*
Added igt_skip_on(!igt_sriov_is_pf(fd)) to skip test when run without
enabling sriov.
v3: Fixed documentation build error
ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-xe_guc_ct_send_recv
v4: Fixed review comments.
Updated igt_skip_on to igt_require.
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Reviewed-by: Francois Dugast <francois.dugast@intel.com>
Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
---
tests/intel/xe_fault_injection.c | 62 ++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index 3a0e2aa29..f92f955cd 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -19,12 +19,14 @@
#include "igt_sysfs.h"
#include "lib/igt_syncobj.h"
#include "lib/intel_pat.h"
+#include "lib/igt_sriov_device.h"
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
#define INJECT_ERRNO -ENOMEM
#define BO_ADDR 0x1a0000
#define BO_SIZE (1024*1024)
+#define NUM_VFS 1
enum injection_list_action {
INJECTION_LIST_ADD,
@@ -281,6 +283,55 @@ vm_bind_fail(int fd, const char function_name[])
igt_assert_eq(simple_vm_bind(fd, vm), 0);
}
+static int sriov_enable_vfs(int fd, int num_vfs)
+{
+ int sysfs;
+ bool ret;
+
+ sysfs = igt_sysfs_open(fd);
+ igt_assert_fd(sysfs);
+
+ ret = __igt_sysfs_set_u32(sysfs, "device/sriov_numvfs", num_vfs);
+ close(sysfs);
+
+ return ret;
+}
+
+/**
+ * SUBTEST: enable-vfs-fail-%s
+ * Description: inject an error in function %arg[1] used when xe interacts with guc to make it fail
+ * Functionality: fault
+ *
+ * arg[1]:
+ * @xe_guc_ct_send_recv: xe_guc_ct_send_recv
+ */
+
+static void
+enable_vfs_fail(int fd, int num_vfs, const char function_name[])
+{
+ bool autoprobe = 0;
+
+ ignore_faults_in_dmesg(function_name);
+ injection_list_do(INJECTION_LIST_ADD, function_name);
+ set_retval(function_name, INJECT_ERRNO);
+
+ autoprobe = igt_sriov_is_driver_autoprobe_enabled(fd);
+
+ if (autoprobe)
+ igt_sriov_disable_driver_autoprobe(fd);
+
+ /* igt_sriov_enable_vfs can't be used here as it is causing abort on any error.
+ * Since error in this test is expected, we have written our own static function here.
+ */
+ sriov_enable_vfs(fd, num_vfs);
+
+ igt_assert_eq(-errno, INJECT_ERRNO);
+ injection_list_do(INJECTION_LIST_REMOVE, function_name);
+
+ if (autoprobe)
+ igt_sriov_enable_driver_autoprobe(fd);
+}
+
igt_main
{
int fd;
@@ -319,6 +370,10 @@ igt_main
{ "xe_vma_ops_alloc" },
{ }
};
+ const struct section enable_vfs_fail_functions[] = {
+ { "xe_guc_ct_send_recv" },
+ { }
+ };
igt_fixture {
igt_require(fail_function_injection_enabled());
@@ -335,6 +390,13 @@ igt_main
igt_subtest_f("vm-bind-fail-%s", s->name)
vm_bind_fail(fd, s->name);
+ for (const struct section *s = enable_vfs_fail_functions; s->name; s++)
+ igt_subtest_f("enable-vfs-fail-%s", s->name) {
+ /* Skip the test if not running with SRIOV */
+ igt_require(igt_sriov_is_pf(fd));
+ enable_vfs_fail(fd, NUM_VFS, s->name);
+ }
+
igt_fixture {
xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_UNBIND);
}
--
2.35.3
next prev parent reply other threads:[~2025-01-22 7:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 7:38 [PATCH i-g-t v4 0/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv Satyanarayana K V P
2025-01-22 7:38 ` [PATCH i-g-t v4 1/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_mmio_send_recv Satyanarayana K V P
2025-01-22 14:54 ` Michal Wajdeczko
2025-01-22 7:38 ` Satyanarayana K V P [this message]
2025-01-22 15:22 ` [PATCH i-g-t v4 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv Michal Wajdeczko
2025-01-22 10:44 ` ✓ i915.CI.BAT: success for tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv (rev4) Patchwork
2025-01-22 11:54 ` ✓ Xe.CI.BAT: " Patchwork
2025-01-22 21:42 ` ✗ Xe.CI.Full: failure " Patchwork
2025-01-23 15:00 ` ✗ i915.CI.Full: " Patchwork
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=20250122073808.16288-3-satyanarayana.k.v.p@intel.com \
--to=satyanarayana.k.v.p@intel.com \
--cc=francois.dugast@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=marcin.bernatowicz@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=michal.wajdeczko@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