Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: kamil.konieczny@linux.intel.com, lukasz.laguna@intel.com,
	michal.wajdeczko@intel.com
Subject: [PATCH i-g-t] lib/igt_sriov_device: Adjust the igt_sriov_is_pf function
Date: Thu,  9 May 2024 14:15:56 +0000	[thread overview]
Message-ID: <20240509141556.4128166-1-marcin.bernatowicz@linux.intel.com> (raw)

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


             reply	other threads:[~2024-05-09 14:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 14:15 Marcin Bernatowicz [this message]
2024-05-09 14:44 ` ✓ CI.xeBAT: success for lib/igt_sriov_device: Adjust the igt_sriov_is_pf function 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509141556.4128166-1-marcin.bernatowicz@linux.intel.com \
    --to=marcin.bernatowicz@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=lukasz.laguna@intel.com \
    --cc=michal.wajdeczko@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox