Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2] tests/intel/xe_sriov_auto_provisioning: Add restore_auto_provisioning tests
@ 2025-11-28 11:43 Marcin Bernatowicz
  2025-11-28 13:29 ` ✓ Xe.CI.BAT: success for tests/intel/xe_sriov_auto_provisioning: Add restore_auto_provisioning tests (rev2) Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Marcin Bernatowicz @ 2025-11-28 11:43 UTC (permalink / raw)
  To: igt-dev
  Cc: Marcin Bernatowicz, Adam Miszczak, Jakub Kolakowski,
	Lukasz Laguna, Michał Wajdeczko

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)

Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
---
v2: address Lukasz's review comments:
 - Fix comment style
 - Add blank line between prerequisites and subtest body
 - Correct subtest name
 - Add assertion that dummy_value is applied
---
 tests/intel/xe_sriov_auto_provisioning.c | 142 ++++++++++++++++++++++-
 1 file changed, 141 insertions(+), 1 deletion(-)

diff --git a/tests/intel/xe_sriov_auto_provisioning.c b/tests/intel/xe_sriov_auto_provisioning.c
index 451c3c5ca..e6350bc68 100644
--- a/tests/intel/xe_sriov_auto_provisioning.c
+++ b/tests/intel/xe_sriov_auto_provisioning.c
@@ -290,6 +290,104 @@ 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_assert_lte(dummy_value, expected[vf]);
+			}
+
+			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 +530,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),
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-30 16:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28 11:43 [PATCH i-g-t v2] tests/intel/xe_sriov_auto_provisioning: Add restore_auto_provisioning tests Marcin Bernatowicz
2025-11-28 13:29 ` ✓ Xe.CI.BAT: success for tests/intel/xe_sriov_auto_provisioning: Add restore_auto_provisioning tests (rev2) Patchwork
2025-11-28 13:38 ` ✗ i915.CI.BAT: failure " Patchwork
2025-11-28 14:56 ` ✗ Xe.CI.Full: " Patchwork
2025-11-30 16:12 ` [PATCH i-g-t v2] tests/intel/xe_sriov_auto_provisioning: Add restore_auto_provisioning tests Laguna, Lukasz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox