Skip to contentSkip to conversation

tests/intel/xe_sriov_auto_provisioning: Add restore_auto_provisioning tests

PATCH New Marcin Bernatowicz 1 participant 1 message Oct 23, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/intel/xe_sriov_auto_provisioning: Add restore_auto_provisioning tests

Add subtests that verify restore_auto_provisioning with:
- disabled VFs (succeeds; idempotent)
- enabled VFs in auto mode (no-op)
- enabled VFs in custom mode (-EBUSY; succeeds after disable)

Cc Adam Miszczak <[email protected]>
Cc Jakub Kolakowski <[email protected]>
Cc Lukasz Laguna <[email protected]>
Cc Michał Wajdeczko <[email protected]>
---
 tests/intel/xe_sriov_auto_provisioning.c | 136 ++++++++++++++++++++++-
 1 file changed, 135 insertions(+), 1 deletion(-)
tests/intel/xe_sriov_auto_provisioning.c +135 -1
index 451c3c5ca..74cea5422 100644
@@ -290,6 +290,98 @@ static void check_selfconfig(int pf_fd, unsigned int vf_num, unsigned int flags)
 	igt_fail_on_f(fails, "selfconfig check failed\n");
 }
 
+static bool empty_shared_res_attributes(int pf_fd)
+{
+	struct xe_sriov_provisioned_range *ranges = NULL;
+	enum xe_sriov_shared_res res;
+	unsigned int gt;
+	int fails = 0;
+
+	xe_for_each_gt(pf_fd, gt)
+		xe_sriov_for_each_provisionable_shared_res(res, pf_fd, gt)
+			if (xe_sriov_pf_debugfs_read_check_ranges(pf_fd, res, gt, &ranges, 0))
+				fails++;
+
+	return fails == 0;
+}
+
+/**
+ * SUBTEST: restore-auto-provisioning-disabled-vfs
+ * Description: Verify restore auto provisioning when VFs are disabled
+ */
+static void restore_auto_provisioning_disabled_vfs(int pf_fd)
+{
+	igt_require(xe_sriov_pf_debugfs_supports_restore_auto_provisioning(pf_fd));
+	igt_skip_on(igt_sriov_get_enabled_vfs(pf_fd));
+	igt_assert_eq(0, xe_sriov_pf_debugfs_restore_auto_provisioning(pf_fd));
+	igt_assert(empty_shared_res_attributes(pf_fd));
+	// check second call is noop
+	igt_assert_eq(0, xe_sriov_pf_debugfs_restore_auto_provisioning(pf_fd));
+	igt_assert(empty_shared_res_attributes(pf_fd));
+}
+
+/**
+ * SUBTEST: restore-auto-provisioning-enabled-vfs-auto_mode
+ * Description: Verify that restore auto provisioning with VFs enabled in auto mode is noop
+ */
+static void restore_auto_provisioning_enabled_vfs_auto_mode(int pf_fd, unsigned int num_vfs)
+{
+	igt_require(xe_sriov_pf_debugfs_supports_restore_auto_provisioning(pf_fd));
+	igt_skip_on(igt_sriov_get_enabled_vfs(pf_fd));
+	igt_require(empty_shared_res_attributes(pf_fd));
+	// ensure auto provisioning on
+	igt_assert_eq(0, xe_sriov_pf_debugfs_restore_auto_provisioning(pf_fd));
+	igt_assert(empty_shared_res_attributes(pf_fd));
+	igt_sriov_disable_driver_autoprobe(pf_fd);
+	igt_sriov_enable_vfs(pf_fd, num_vfs);
+	// ensure noop
+	igt_assert_eq(0, xe_sriov_pf_debugfs_restore_auto_provisioning(pf_fd));
+	igt_assert(!empty_shared_res_attributes(pf_fd));
+	igt_sriov_disable_vfs(pf_fd);
+	igt_assert(empty_shared_res_attributes(pf_fd));
+}
+
+/**
+ * SUBTEST: restore-auto-provisioning-enabled-vfs-custom-mode
+ * Description: Verify that restore auto provisioning with VFs enabled in custom mode is rejected
+ *		and auto provisioning restored after VFs disabled
+ */
+static void restore_auto_provisioning_enabled_vfs_custom_mode(int pf_fd, unsigned int num_vfs)
+{
+	enum xe_sriov_shared_res res;
+	unsigned int gt;
+	uint64_t dummy_value = 10;
+	uint64_t expected[num_vfs + 1];
+
+	igt_require(xe_sriov_pf_debugfs_supports_restore_auto_provisioning(pf_fd));
+	igt_skip_on(igt_sriov_get_enabled_vfs(pf_fd));
+	igt_require(empty_shared_res_attributes(pf_fd));
+	// ensure auto provisioning on
+	igt_assert_eq(0, xe_sriov_pf_debugfs_restore_auto_provisioning(pf_fd));
+	igt_sriov_disable_driver_autoprobe(pf_fd);
+
+	xe_for_each_gt(pf_fd, gt) {
+		xe_sriov_for_each_provisionable_shared_res(res, pf_fd, gt) {
+			for (unsigned int vf = 1; vf <= num_vfs; vf++) {
+				xe_sriov_pf_set_shared_res_attr(pf_fd, res, vf, gt, dummy_value);
+				expected[vf] = xe_sriov_pf_get_shared_res_attr(pf_fd, res, vf, gt);
+			}
+
+			igt_sriov_enable_vfs(pf_fd, num_vfs);
+			igt_assert_eq(xe_sriov_pf_debugfs_restore_auto_provisioning(pf_fd),
+				      -EBUSY);
+
+			for (unsigned int vf = 1; vf <= num_vfs; vf++)
+				igt_assert_eq(expected[vf],
+					      xe_sriov_pf_get_shared_res_attr(pf_fd, res, vf, gt));
+
+			igt_sriov_disable_vfs(pf_fd);
+			igt_assert_eq(0, xe_sriov_pf_debugfs_restore_auto_provisioning(pf_fd));
+			igt_assert(empty_shared_res_attributes(pf_fd));
+		}
+	}
+}
+
 static bool extended_scope;
 
 static int opts_handler(int opt, int opt_index, void *data)
@@ -432,10 +524,52 @@ igt_main_args("", long_opts, help_str, opts_handler, NULL)
 		}
 	}
 
+	igt_describe("Verify restore-auto-provisioning when VFs are disabled");
+	igt_subtest("restore-auto-provisioning-disabled-vfs") {
+		restore_auto_provisioning_disabled_vfs(pf_fd);
+	}
+
+	igt_describe("Verify that restore auto provisioning with VFs enabled in auto mode is noop");
+	igt_subtest_with_dynamic("restore-auto-provisioning-enabled-vfs-auto_mode") {
+		if (extended_scope)
+			for_each_sriov_num_vfs(pf_fd, num_vfs)
+				igt_dynamic_f("numvfs-%d", num_vfs)
+					restore_auto_provisioning_enabled_vfs_auto_mode(pf_fd,
+											num_vfs);
+
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				igt_debug("numvfs=%u\n", num_vfs);
+				restore_auto_provisioning_enabled_vfs_auto_mode(pf_fd,
+										num_vfs);
+			}
+		}
+	}
+
+	igt_describe("Verify restore-auto-provisioning with VFs enabled in custom mode");
+	igt_subtest_with_dynamic("restore-auto-provisioning-enabled-vfs-custom-mode") {
+		if (extended_scope)
+			for_each_sriov_num_vfs(pf_fd, num_vfs)
+				igt_dynamic_f("numvfs-%d", num_vfs)
+					restore_auto_provisioning_enabled_vfs_custom_mode(pf_fd,
+											  num_vfs);
+
+		for_random_sriov_num_vfs(pf_fd, num_vfs) {
+			igt_dynamic_f("numvfs-random") {
+				igt_debug("numvfs=%u\n", num_vfs);
+				restore_auto_provisioning_enabled_vfs_custom_mode(pf_fd,
+										  num_vfs);
+			}
+		}
+	}
+
 	igt_fixture {
 		igt_sriov_disable_vfs(pf_fd);
 		/* abort to avoid execution of next tests with enabled VFs */
-		igt_abort_on_f(igt_sriov_get_enabled_vfs(pf_fd) > 0, "Failed to disable VF(s)");
+		igt_abort_on_f(igt_sriov_get_enabled_vfs(pf_fd) > 0, "Failed to disable VF(s)\n");
+		if (xe_sriov_pf_debugfs_supports_restore_auto_provisioning(pf_fd))
+			igt_abort_on_f(xe_sriov_pf_debugfs_restore_auto_provisioning(pf_fd),
+				       "Failed to restore auto provisioning\n");
 		autoprobe ? igt_sriov_enable_driver_autoprobe(pf_fd) :
 			    igt_sriov_disable_driver_autoprobe(pf_fd);
 		igt_abort_on_f(autoprobe != igt_sriov_is_driver_autoprobe_enabled(pf_fd),
Signature · 1 line
2.43.0