Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Riana Tauro <riana.tauro@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: badal.nilawar@intel.com
Subject: [igt-dev] [PATCH i-g-t v2 1/4] lib/igt_device: Add a function to get the pci slot name
Date: Fri,  4 Aug 2023 16:01:08 +0530	[thread overview]
Message-ID: <20230804103111.21214-2-riana.tauro@intel.com> (raw)
In-Reply-To: <20230804103111.21214-1-riana.tauro@intel.com>

The existing d3cold_allowed get/set functions in igt_pm uses
igt_device_card as a function argument. Xe tests cannot use
this function as they use pci_device.
To have a common library function for both i915 and xe, use a
common parameter between both igt_device_card and
pci_device ie.pci_slot_name.

Add a helper function to get this pci slot name.

v2: Add justification for change in commit message (Anshuman)

Signed-off-by: Riana Tauro <riana.tauro@intel.com>
---
 lib/igt_device.c | 20 ++++++++++++++++++++
 lib/igt_device.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/lib/igt_device.c b/lib/igt_device.c
index 49b771221..ffb3f56ce 100644
--- a/lib/igt_device.c
+++ b/lib/igt_device.c
@@ -23,6 +23,7 @@
  */
 #include <sys/types.h>
 #include <fcntl.h>
+#include <limits.h>
 
 #include <sys/stat.h>
 #ifdef __linux__
@@ -287,3 +288,22 @@ igt_device_get_pci_root_port(int fd)
 
 	return prev;
 }
+
+/**
+ * igt_device_get_pci_slot_name:
+ * @fd: the device.
+ * @pci_slot_name: pci slot name
+ *
+ * Looks up the graphics pci device using libpciaccess
+ * and gets the slot name
+ */
+void igt_device_get_pci_slot_name(int fd, char *pci_slot_name)
+{
+	struct pci_device *pci_dev;
+
+	pci_dev = __igt_device_get_pci_device(fd, 0);
+	igt_require(pci_dev);
+
+	snprintf(pci_slot_name, NAME_MAX, "%04x:%02x:%02x.%01x",
+		 pci_dev->domain, pci_dev->bus, pci_dev->dev, pci_dev->func);
+}
diff --git a/lib/igt_device.h b/lib/igt_device.h
index 800a0fcc3..dad7bb047 100644
--- a/lib/igt_device.h
+++ b/lib/igt_device.h
@@ -36,4 +36,5 @@ struct pci_device *igt_device_get_pci_device(int fd);
 struct pci_device *__igt_device_get_pci_device(int fd, unsigned int vf_id);
 struct pci_device *igt_device_get_pci_root_port(int fd);
 
+void igt_device_get_pci_slot_name(int fd, char *pci_slot_name);
 #endif /* __IGT_DEVICE_H__ */
-- 
2.40.0

  reply	other threads:[~2023-08-04 10:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04 10:31 [igt-dev] [PATCH i-g-t v2 0/4] Modify igt_pm functions and add GT C6 freeze test Riana Tauro
2023-08-04 10:31 ` Riana Tauro [this message]
2023-08-08  7:54   ` [igt-dev] [PATCH i-g-t v2 1/4] lib/igt_device: Add a function to get the pci slot name Gupta, Anshuman
2023-08-04 10:31 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/igt_pm: change d3cold_allowed function parameters Riana Tauro
2023-08-08  8:02   ` Gupta, Anshuman
2023-08-04 10:31 ` [igt-dev] [PATCH i-g-t v2 3/4] tests/xe: use igt_pm library functions Riana Tauro
2023-08-08  8:25   ` Gupta, Anshuman
2023-08-04 10:31 ` [igt-dev] [PATCH i-g-t v2 4/4] tests/xe: Add a test that validates residency during s2idle Riana Tauro
2023-08-08  8:35   ` Gupta, Anshuman
2023-08-09  5:16     ` Riana Tauro
2023-08-04 11:13 ` [igt-dev] ○ CI.xeBAT: info for Modify igt_pm functions and add GT C6 freeze test Patchwork
2023-08-04 11:23 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-08-04 16:22 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=20230804103111.21214-2-riana.tauro@intel.com \
    --to=riana.tauro@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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