]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/pf: Promote xe_pci_sriov_get_vf_pdev
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 30 Oct 2025 22:23:45 +0000 (23:23 +0100)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 31 Oct 2025 19:01:48 +0000 (20:01 +0100)
In the upcoming patch we would like to use this private helper
during preparation of the sysfs links. Promote it.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Link: https://patch.msgid.link/20251030222348.186658-15-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_pci_sriov.c
drivers/gpu/drm/xe/xe_pci_sriov.h

index 735f51effc7a3fc0df547782a68d7bcb37d27105..4d5da6686e9231d7bb63aaa22c5f2473769b5eae 100644 (file)
@@ -30,18 +30,6 @@ static void pf_reset_vfs(struct xe_device *xe, unsigned int num_vfs)
                xe_sriov_pf_control_reset_vf(xe, n);
 }
 
-static struct pci_dev *xe_pci_pf_get_vf_dev(struct xe_device *xe, unsigned int vf_id)
-{
-       struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
-
-       xe_assert(xe, IS_SRIOV_PF(xe));
-
-       /* caller must use pci_dev_put() */
-       return pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
-                       pdev->bus->number,
-                       pci_iov_virtfn_devfn(pdev, vf_id));
-}
-
 static void pf_link_vfs(struct xe_device *xe, int num_vfs)
 {
        struct pci_dev *pdev_pf = to_pci_dev(xe->drm.dev);
@@ -60,7 +48,7 @@ static void pf_link_vfs(struct xe_device *xe, int num_vfs)
         * enforce correct resume order.
         */
        for (n = 1; n <= num_vfs; n++) {
-               pdev_vf = xe_pci_pf_get_vf_dev(xe, n - 1);
+               pdev_vf = xe_pci_sriov_get_vf_pdev(pdev_pf, n);
 
                /* unlikely, something weird is happening, abort */
                if (!pdev_vf) {
@@ -228,3 +216,25 @@ int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
 
        return ret;
 }
+
+/**
+ * xe_pci_sriov_get_vf_pdev() - Lookup the VF's PCI device using the VF identifier.
+ * @pdev: the PF's &pci_dev
+ * @vfid: VF identifier (1-based)
+ *
+ * The caller must decrement the reference count by calling pci_dev_put().
+ *
+ * Return: the VF's &pci_dev or NULL if the VF device was not found.
+ */
+struct pci_dev *xe_pci_sriov_get_vf_pdev(struct pci_dev *pdev, unsigned int vfid)
+{
+       struct xe_device *xe = pdev_to_xe_device(pdev);
+
+       xe_assert(xe, dev_is_pf(&pdev->dev));
+       xe_assert(xe, vfid);
+       xe_assert(xe, vfid <= pci_sriov_get_totalvfs(pdev));
+
+       return pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
+                                          pdev->bus->number,
+                                          pci_iov_virtfn_devfn(pdev, vfid - 1));
+}
index c76dd0d90495e79234f1f8f7ace129998a79a5d7..b9105d71dbb1eef835e435b914b0964a6d6d9894 100644 (file)
@@ -10,6 +10,7 @@ struct pci_dev;
 
 #ifdef CONFIG_PCI_IOV
 int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs);
+struct pci_dev *xe_pci_sriov_get_vf_pdev(struct pci_dev *pdev, unsigned int vfid);
 #else
 static inline int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
 {