[RFC] [PATCH i-g-t v3] tests/intel/xe_fault_injection: Inject errors for VF provision
Satyanarayana K V P
satyanarayana.k.v.p at intel.com
Fri Jun 20 13:35:16 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
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
V2 -> V3:
- Rebased with latest igt repo.
- Added some debug prints.
- Updated test name to igt at xe_fault_injection@probe-fail-vf-provision
(Michal Wajdeczko).
V1 -> V2:
- Fixed review comments.
---
tests/intel/xe_fault_injection.c | 84 ++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index 8245c558c..57d0fe6a1 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -29,6 +29,18 @@
#define BO_SIZE (1024*1024)
#define INJECT_ITERATIONS 100
+#define INJECT_VF_PROVISION_ERR_COUNT 6
+#define VF_PROVISION_MAX_PARAMS 4
+
+int vf_provision_err_inject_list[INJECT_VF_PROVISION_ERR_COUNT] = {
+ -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. */
@@ -298,6 +310,64 @@ static void probe_fail_guc(int fd, const char pci_slot[], const char function_na
}
}
+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_COUNT; i++) {
+ if (igt_sriov_get_enabled_vfs(fd))
+ igt_sriov_disable_vfs(fd);
+
+ setup_injection_fault(fault_params);
+
+ injection_list_add(func_name);
+ igt_debug("Injecting error %d\n", vf_provision_err_inject_list[i]);
+ 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
+ * Description: inject an error in the injectable function %arg[1] then reprobe driver
+ * Functionality: fault
+ */
+static void probe_fail_vf_provision(int fd, const char pci_slot[],
+ const char function_name[],
+ struct fault_injection_params *fault_params)
+{
+ int space, times, interval;
+ /* We do not 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_dmesg_errors_from_dut(pci_slot);
+
+ 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
@@ -574,6 +644,11 @@ igt_main_args("I:", NULL, help_str, opt_handler, NULL)
{ }
};
+ const struct section vf_proviosin_fail_functions[] = {
+ { "probe-fail-vf-provision" },
+ {}
+ };
+
igt_fixture {
igt_require(fail_function_injection_enabled());
fd = drm_open_driver(DRIVER_XE);
@@ -611,6 +686,15 @@ 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, pci_slot, s->name);
+ for (const struct section *s = vf_proviosin_fail_functions; s->name; s++)
+ igt_subtest_f("probe-fail-vf-provision") {
+ memcpy(&fault_params, &default_fault_params,
+ sizeof(struct fault_injection_params));
+ probe_fail_vf_provision(fd, pci_slot,
+ "xe_should_fail_vf_provisioning",
+ &fault_params);
+ }
+
igt_fixture {
igt_kmod_unbind("xe", pci_slot);
}
--
2.43.0
More information about the igt-dev
mailing list