Skip to content

Commit 5be29eb

Browse files
mwiniarsThomas Hellström
authored andcommitted
drm/xe/pci: Introduce a helper to allow VF access to PF xe_device
In certain scenarios (such as VF migration), VF driver needs to interact with PF driver. Add a helper to allow VF driver access to PF xe_device. Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Link: https://patch.msgid.link/20251127093934.1462188-3-michal.winiarski@intel.com Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> (cherry picked from commit 8b3cce3) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent 73834d0 commit 5be29eb

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

drivers/gpu/drm/xe/xe_pci.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,23 @@ static struct pci_driver xe_pci_driver = {
12231223
#endif
12241224
};
12251225

1226+
/**
1227+
* xe_pci_to_pf_device() - Get PF &xe_device.
1228+
* @pdev: the VF &pci_dev device
1229+
*
1230+
* Return: pointer to PF &xe_device, NULL otherwise.
1231+
*/
1232+
struct xe_device *xe_pci_to_pf_device(struct pci_dev *pdev)
1233+
{
1234+
struct drm_device *drm;
1235+
1236+
drm = pci_iov_get_pf_drvdata(pdev, &xe_pci_driver);
1237+
if (IS_ERR(drm))
1238+
return NULL;
1239+
1240+
return to_xe_device(drm);
1241+
}
1242+
12261243
int xe_register_pci_driver(void)
12271244
{
12281245
return pci_register_driver(&xe_pci_driver);

drivers/gpu/drm/xe/xe_pci.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
#ifndef _XE_PCI_H_
77
#define _XE_PCI_H_
88

9+
struct pci_dev;
10+
911
int xe_register_pci_driver(void);
1012
void xe_unregister_pci_driver(void);
13+
struct xe_device *xe_pci_to_pf_device(struct pci_dev *pdev);
1114

1215
#endif

0 commit comments

Comments
 (0)