Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 8b3cce3ad9c78ce3dae1c178f99352d50e12a3c0)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

authored by

Michał Winiarski and committed by
Thomas Hellström
5be29ebe 73834d03

+20
+17
drivers/gpu/drm/xe/xe_pci.c
··· 1223 1223 #endif 1224 1224 }; 1225 1225 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 + 1226 1243 int xe_register_pci_driver(void) 1227 1244 { 1228 1245 return pci_register_driver(&xe_pci_driver);
+3
drivers/gpu/drm/xe/xe_pci.h
··· 6 6 #ifndef _XE_PCI_H_ 7 7 #define _XE_PCI_H_ 8 8 9 + struct pci_dev; 10 + 9 11 int xe_register_pci_driver(void); 10 12 void xe_unregister_pci_driver(void); 13 + struct xe_device *xe_pci_to_pf_device(struct pci_dev *pdev); 11 14 12 15 #endif