[RFC] [PATCH i-g-t v2] tests/intel/xe_fault_injection: Inject errors for VF provision
Satyanarayana K V P
satyanarayana.k.v.p at intel.com
Wed May 28 13:06:03 UTC 2025
Use the kernel fault injection infrastructure to test error handling of
the XE during reading VF provisioning data of various resources like GGTT,
contexts, LMEM (in case of DGFX) and doorbells so that more code paths are
tested, such as error handling and unwinding.
The test injects multiple errors into each resource and tests all possible
ways of error handling.
Error can be injected using:
igt at xe_fault_injection@probe-fail-vf-provision-xe_should_fail_vf_provisioning
Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p at intel.com>
---
Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Francois Dugast <francois.dugast at intel.com>
Cc: Marcin Bernatowicz <marcin.bernatowicz at linux.intel.com>
Cc: Lukasz Laguna <lukasz.laguna at intel.com>
Test-With: 20250523073638.24842-1-satyanarayana.k.v.p at intel.com
V1 -> V2:
- Fixed review comments.
---
tests/intel/xe_fault_injection.c | 102 +++++++++++++++++++++++++++++++
1 file changed, 102 insertions(+)
diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index f9bd5c761..18ea78bfb 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -29,6 +29,19 @@
#define BO_SIZE (1024*1024)
#define INJECT_ITERATIONS 100
+#define VF_PROVISION_MAX_PARAMS 4
+#define INJECT_VF_PROVISION_ERR_MAX 6
+
+int vf_provision_err_inject_list[INJECT_VF_PROVISION_ERR_MAX] = {
+ -22, /* -EINVAL */
+ -28, /* -ENOSPC */
+ -61, /* -ENODATA */
+ -69, /* -ESRMNT */
+ -78, /* -EREMCHG */
+ -122, /* -EDQUOT */
+};
+
+
int32_t inject_iters_raw;
struct fault_injection_params {
/* @probability: Likelihood of failure injection, in percent. */
@@ -71,6 +84,11 @@ static bool function_is_part_of_guc(const char function_name[])
strstr(function_name, "_wopcm_") != NULL;
}
+static bool function_is_part_of_vf(const char function_name[])
+{
+ return strstr(function_name, "_vf_") != NULL;
+}
+
static void ignore_faults_in_dmesg(const char function_name[])
{
/* Driver probe is expected to fail in all cases, so ignore in igt_runner */
@@ -87,6 +105,19 @@ static void ignore_faults_in_dmesg(const char function_name[])
strcat(regex, "|GT[0-9a-fA-F]*: GuC PC query task state failed: -ENOMEM");
}
+ /*
+ * If VF provisiong faults are injected, Guc and VF provision is
+ * expected fail. So, ignore failures in igt_runner.
+ */
+ if (function_is_part_of_vf(function_name)) {
+ strcat(regex, "|GT[0-9a-fA-F]*: GuC init failed with -ENOMEM");
+ strcat(regex, "|GT[0-9a-fA-F]*: Failed to initialize uC .-ENOMEM");
+ strcat(regex, "|GT[0-9a-fA-F]*: VF: Unexpected GGTT reassignment: [0-9] != [0-9]");
+ strcat(regex, "|GT[0-9a-fA-F]*: VF: Unexpected CTXs reassignment: [0-9] != [0-9]");
+ strcat(regex, "|GT[0-9a-fA-F]*: VF: Unexpected DBs reassignment: [0-9] != [0-9]");
+ strcat(regex, "|GT[0-9a-fA-F]*: VF: Unexpected LMEM reassignment: [0-9] != [0-9]");
+ }
+
igt_emit_ignore_dmesg_regex(regex);
}
@@ -278,6 +309,65 @@ static void probe_fail_guc(int fd, char pci_slot[], const char function_name[],
}
}
+static void vf_provision_inject_fault(int fd, const char func_name[],
+ struct fault_injection_params *fault_params)
+{
+ int auto_probe_en = igt_sriov_is_driver_autoprobe_enabled(fd);
+ unsigned int totalvfs = igt_sriov_get_total_vfs(fd);
+ int i;
+
+ for (i = 0; i < INJECT_VF_PROVISION_ERR_MAX; i++) {
+ if (igt_sriov_get_enabled_vfs(fd))
+ igt_sriov_disable_vfs(fd);
+
+ setup_injection_fault(fault_params);
+
+ injection_list_add(func_name);
+ set_retval(func_name, vf_provision_err_inject_list[i]);
+
+ igt_sriov_enable_driver_autoprobe(fd);
+ igt_sriov_enable_vfs(fd, totalvfs);
+ igt_sriov_disable_vfs(fd);
+ if (!auto_probe_en)
+ igt_sriov_disable_driver_autoprobe(fd);
+ injection_list_remove(func_name);
+ }
+}
+/**
+ * SUBTEST: probe-fail-vf-provision-%s
+ * Description: inject an error in the injectable function %arg[1] then reprobe driver
+ * Functionality: fault
+ *
+ * arg[1]:
+ * @xe_should_fail_vf_provisioning: Inject an error when provisioning VF.
+ */
+static void probe_fail_vf_provision(int fd, char pci_slot[], const char function_name[],
+ struct fault_injection_params *fault_params)
+{
+ int space, times, interval;
+ /* We donot have LMEM for IGPU. */
+ int end = xe_has_vram(fd) ?
+ (VF_PROVISION_MAX_PARAMS):(VF_PROVISION_MAX_PARAMS - 1);
+
+ igt_skip_on(!igt_sriov_is_pf(fd));
+ igt_assert(fault_params);
+
+ ignore_faults_in_dmesg(function_name);
+
+ for (space = 1; space < end; space++) {
+ for (times = 1; times < end; times++) {
+ for (interval = 1; interval < end; interval++) {
+ fault_params->interval = interval;
+ fault_params->times = times;
+ fault_params->space = space;
+
+ vf_provision_inject_fault(fd, function_name,
+ fault_params);
+
+ }
+ }
+ }
+}
/**
* SUBTEST: exec-queue-create-fail-%s
* Description: inject an error in function %arg[1] used in exec queue create IOCTL to make it fail
@@ -551,6 +641,11 @@ igt_main_args("I:", NULL, help_str, opt_handler, NULL)
{ }
};
+ const struct section vf_proviosin_fail_functions[] = {
+ { "xe_should_fail_vf_provisioning" },
+ {}
+ };
+
igt_fixture {
igt_require(fail_function_injection_enabled());
fd = drm_open_driver(DRIVER_XE);
@@ -586,6 +681,13 @@ igt_main_args("I:", NULL, help_str, opt_handler, NULL)
igt_subtest_f("oa-add-config-fail-%s", s->name)
oa_add_config_fail(fd, sysfs, devid, s->name);
+ for (const struct section *s = vf_proviosin_fail_functions; s->name; s++)
+ igt_subtest_f("probe-fail-vf-provision-%s", s->name) {
+ memcpy(&fault_params, &default_fault_params,
+ sizeof(struct fault_injection_params));
+ probe_fail_vf_provision(fd, pci_slot, s->name, &fault_params);
+ }
+
igt_fixture {
igt_kmod_unbind("xe", pci_slot);
}
--
2.43.0
More information about the igt-dev
mailing list