Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2] lib/igt_sriov_device: Update igt_sriov_enable_vfs helper
@ 2026-05-06 17:38 Jakub Kolakowski
  2026-05-06 18:39 ` ✓ Xe.CI.BAT: success for lib/igt_sriov_device: Update igt_sriov_enable_vfs helper (rev2) Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jakub Kolakowski @ 2026-05-06 17:38 UTC (permalink / raw)
  To: igt-dev
  Cc: Jakub Kolakowski, Jani Nikula, Adam Miszczak, Lukasz Laguna,
	Marcin Bernatowicz, Katarzyna Piecielska

Some platforms may expose sriov capability and sriov_totalvfs will be
greater than 0 while the driver actually doesn't support the platform.
In such case igt_sriov_is_pf() helper that checks for sriov_totalvfs
will pass.
Add additional check within igt_sriov_enable_vfs() function to check if
writing to sriov_numvfs was successfull and what errno was returned
during this operation. ENOENT will mean that SR-IOV isn't supported for
given configuration. In such case test will skip instead of failing.

V2:
 - replace __pf_attr_set_u32() with igt_sysfs_printf to reduce layers of
   helper functions and increase reliability of checking for errno

Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Cc: Katarzyna Piecielska <katarzyna.piecielska@intel.com>
Signed-off-by: Jakub Kolakowski <jakub1.kolakowski@intel.com>
---
 lib/igt_sriov_device.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c
index 1f4c3ac04..4be57deea 100644
--- a/lib/igt_sriov_device.c
+++ b/lib/igt_sriov_device.c
@@ -174,10 +174,22 @@ unsigned int igt_sriov_get_enabled_vfs(int pf)
  */
 void igt_sriov_enable_vfs(int pf, unsigned int num_vfs)
 {
+	int sysfs;
+	int ret;
+
+	igt_assert(igt_sriov_is_pf(pf));
 	igt_assert(num_vfs > 0);
 
+	sysfs = igt_sysfs_open(pf);
+	igt_assert_fd(sysfs);
+
 	igt_debug("Enabling %u VFs\n", num_vfs);
-	pf_attr_set_u32(pf, "device/sriov_numvfs", num_vfs);
+	ret = igt_sysfs_printf(sysfs, "device/sriov_numvfs", "%u", num_vfs);
+	close(sysfs);
+
+	igt_require_f(ret != -ENOENT, "SR-IOV not supported\n");
+	igt_assert_f(ret > 0, "Failed to write %u to device/sriov_numvfs (%s)\n",
+		     num_vfs, strerror(abs(ret)));
 }
 
 /**
-- 
2.43.0


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

end of thread, other threads:[~2026-05-11  7:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06 17:38 [PATCH i-g-t v2] lib/igt_sriov_device: Update igt_sriov_enable_vfs helper Jakub Kolakowski
2026-05-06 18:39 ` ✓ Xe.CI.BAT: success for lib/igt_sriov_device: Update igt_sriov_enable_vfs helper (rev2) Patchwork
2026-05-06 18:44 ` ✓ i915.CI.BAT: " Patchwork
2026-05-06 20:35 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-05-07  1:08 ` ✗ i915.CI.Full: " Patchwork
2026-05-11  7:47 ` [PATCH i-g-t v2] lib/igt_sriov_device: Update igt_sriov_enable_vfs helper Bernatowicz, Marcin

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