Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] lib/igt_sriov_device: Adjust the igt_sriov_is_pf function
@ 2024-05-09 14:15 Marcin Bernatowicz
  2024-05-09 14:44 ` ✓ CI.xeBAT: success for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Marcin Bernatowicz @ 2024-05-09 14:15 UTC (permalink / raw)
  To: igt-dev; +Cc: kamil.konieczny, lukasz.laguna, michal.wajdeczko

A device is considered a PF if it supports the creation of one or more
VFs. This capability is indicated by the presence of the sriov_totalvfs
attribute in the device's sysfs entry, with a value greater than zero.
The igt_sriov_is_pf function checks for this attribute and its value to
confirm the device's PF status.
This adjustment streamlines the process for tests that manipulate Virtual
Functions (VFs) by consolidating prerequisite checks into a single
`igt_require(igt_sriov_is_pf)`.

Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
---
 lib/igt_sriov_device.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c
index a0ef05d5c..8d59bfdca 100644
--- a/lib/igt_sriov_device.c
+++ b/lib/igt_sriov_device.c
@@ -19,23 +19,25 @@
  * igt_sriov_is_pf - Check if device is PF
  * @device: device file descriptor
  *
- * Determine if device is PF by checking existence of sriov_totalvfs file.
+ * Determines if a device is a Physical Function (PF) by verifying
+ * the presence of the sriov_totalvfs attribute and ensuring its
+ * read value is greater than zero.
  *
  * Return:
  * True if device is PF, false otherwise.
  */
 bool igt_sriov_is_pf(int device)
 {
+	uint32_t value = 0;
 	int sysfs;
-	bool ret;
 
 	sysfs = igt_sysfs_open(device);
 	igt_assert_fd(sysfs);
 
-	ret = igt_sysfs_has_attr(sysfs, "device/sriov_totalvfs");
+	__igt_sysfs_get_u32(sysfs, "device/sriov_totalvfs", &value);
 	close(sysfs);
 
-	return ret;
+	return value > 0;
 }
 
 static bool __pf_attr_get_u32(int pf, const char *attr, uint32_t *value)
-- 
2.31.1


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

end of thread, other threads:[~2024-09-04  9:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 14:15 [PATCH i-g-t] lib/igt_sriov_device: Adjust the igt_sriov_is_pf function Marcin Bernatowicz
2024-05-09 14:44 ` ✓ CI.xeBAT: success for " Patchwork
2024-05-09 15:00 ` ✓ Fi.CI.BAT: " Patchwork
2024-05-09 19:37 ` ✗ CI.xeFULL: failure " Patchwork
2024-05-10  8:33   ` Bernatowicz, Marcin
2024-05-10  1:51 ` ✗ Fi.CI.IGT: " Patchwork
2024-05-10  8:35   ` Bernatowicz, Marcin
2024-09-04  9:25 ` [PATCH i-g-t] " Adam Miszczak

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