All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anshuman Gupta <anshuman.gupta@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: petri.latvala@intel.com, badal.nilawar@intel.com, rodrigo.vivi@intel.com
Subject: [igt-dev] [PATCH i-g-t 2/6] lib/igt_device: Get gfx PCI card root port
Date: Tue, 17 May 2022 19:01:08 +0530	[thread overview]
Message-ID: <20220517133112.25507-3-anshuman.gupta@intel.com> (raw)
In-Reply-To: <20220517133112.25507-1-anshuman.gupta@intel.com>

Utility library function to get the Gfx Card PCI topology
root port pci device using libpaciaccess.
root port will be used to get the real ACPI D state.

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 lib/igt_device.c | 28 ++++++++++++++++++++++++++++
 lib/igt_device.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/lib/igt_device.c b/lib/igt_device.c
index 9794a9928f..fddfba72cd 100644
--- a/lib/igt_device.c
+++ b/lib/igt_device.c
@@ -257,3 +257,31 @@ struct pci_device *igt_device_get_pci_device(int fd)
 
 	return pci_dev;
 }
+
+/**
+ * igt_device_get_pci_root_port:
+ * @fd: the device.
+ *
+ * Looks up the graphics pci device root port using libpciaccess.
+ *
+ * Returns:
+ * The root port pci_device.
+ */
+struct pci_device *
+igt_device_get_pci_root_port(int fd)
+{
+	struct pci_device *pci_dev, *prev;
+
+	pci_dev = __igt_device_get_pci_device(fd, 0);
+	igt_require(pci_dev);
+
+	while (pci_dev) {
+		prev = pci_dev;
+		pci_dev = pci_device_get_parent_bridge(pci_dev);
+	}
+
+	igt_debug("Root Port PCI device %04x:%02x:%02x.%01x\n",
+		  prev->domain, prev->bus, prev->dev, prev->func);
+
+	return prev;
+}
diff --git a/lib/igt_device.h b/lib/igt_device.h
index 1aaa840e25..800a0fcc3c 100644
--- a/lib/igt_device.h
+++ b/lib/igt_device.h
@@ -34,5 +34,6 @@ void igt_device_drop_master(int fd);
 int igt_device_get_card_index(int fd);
 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);
 
 #endif /* __IGT_DEVICE_H__ */
-- 
2.26.2

  parent reply	other threads:[~2022-05-17 13:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17 13:31 [igt-dev] [PATCH i-g-t 0/6] D3Cold Tool Anshuman Gupta
2022-05-17 13:31 ` [igt-dev] [PATCH i-g-t 1/6] test/i915_pm_rpm: Add placement to gem-{mmap-type, execbuf} Anshuman Gupta
2022-05-17 13:31 ` Anshuman Gupta [this message]
2022-05-17 13:31 ` [igt-dev] [PATCH i-g-t 3/6] lib/igt_pm: D3Cold runtime pm infrastructure Anshuman Gupta
2022-05-17 13:31 ` [igt-dev] [PATCH i-g-t 4/6] lib: Optional autosuspend_delay_ms configuration Anshuman Gupta
2022-05-17 13:31 ` [igt-dev] [PATCH i-g-t 5/6] tools: Add intel_pm_rpm tool Anshuman Gupta
2022-05-17 13:31 ` [igt-dev] [PATCH i-g-t 6/6] tools/intel_pm_rpm: Add an option to setup d3cold Anshuman Gupta
2022-05-17 14:34 ` [igt-dev] ✓ Fi.CI.BAT: success for D3Cold Tool Patchwork
2022-05-17 15:35 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-05-18 16:23   ` Gupta, Anshuman
2022-05-18 17:56 ` [igt-dev] ✓ Fi.CI.IGT: success " 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=20220517133112.25507-3-anshuman.gupta@intel.com \
    --to=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    --cc=rodrigo.vivi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.