Skip to content

Commit ae16f18

Browse files
committed
drm/xe/pf: Promote xe_pci_sriov_get_vf_pdev
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
1 parent b5b297b commit ae16f18

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

drivers/gpu/drm/xe/xe_pci_sriov.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ static void pf_reset_vfs(struct xe_device *xe, unsigned int num_vfs)
3030
xe_sriov_pf_control_reset_vf(xe, n);
3131
}
3232

33-
static struct pci_dev *xe_pci_pf_get_vf_dev(struct xe_device *xe, unsigned int vf_id)
34-
{
35-
struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
36-
37-
xe_assert(xe, IS_SRIOV_PF(xe));
38-
39-
/* caller must use pci_dev_put() */
40-
return pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
41-
pdev->bus->number,
42-
pci_iov_virtfn_devfn(pdev, vf_id));
43-
}
44-
4533
static void pf_link_vfs(struct xe_device *xe, int num_vfs)
4634
{
4735
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)
6048
* enforce correct resume order.
6149
*/
6250
for (n = 1; n <= num_vfs; n++) {
63-
pdev_vf = xe_pci_pf_get_vf_dev(xe, n - 1);
51+
pdev_vf = xe_pci_sriov_get_vf_pdev(pdev_pf, n);
6452

6553
/* unlikely, something weird is happening, abort */
6654
if (!pdev_vf) {
@@ -228,3 +216,25 @@ int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
228216

229217
return ret;
230218
}
219+
220+
/**
221+
* xe_pci_sriov_get_vf_pdev() - Lookup the VF's PCI device using the VF identifier.
222+
* @pdev: the PF's &pci_dev
223+
* @vfid: VF identifier (1-based)
224+
*
225+
* The caller must decrement the reference count by calling pci_dev_put().
226+
*
227+
* Return: the VF's &pci_dev or NULL if the VF device was not found.
228+
*/
229+
struct pci_dev *xe_pci_sriov_get_vf_pdev(struct pci_dev *pdev, unsigned int vfid)
230+
{
231+
struct xe_device *xe = pdev_to_xe_device(pdev);
232+
233+
xe_assert(xe, dev_is_pf(&pdev->dev));
234+
xe_assert(xe, vfid);
235+
xe_assert(xe, vfid <= pci_sriov_get_totalvfs(pdev));
236+
237+
return pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus),
238+
pdev->bus->number,
239+
pci_iov_virtfn_devfn(pdev, vfid - 1));
240+
}

drivers/gpu/drm/xe/xe_pci_sriov.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct pci_dev;
1010

1111
#ifdef CONFIG_PCI_IOV
1212
int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs);
13+
struct pci_dev *xe_pci_sriov_get_vf_pdev(struct pci_dev *pdev, unsigned int vfid);
1314
#else
1415
static inline int xe_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
1516
{

0 commit comments

Comments
 (0)