]> Gentwo Git Trees - linux/.git/commitdiff
drm/xe/pci: Introduce a helper to allow VF access to PF xe_device
authorMichał Winiarski <michal.winiarski@intel.com>
Thu, 27 Nov 2025 09:39:32 +0000 (10:39 +0100)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Mon, 1 Dec 2025 08:42:37 +0000 (09:42 +0100)
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>
drivers/gpu/drm/xe/xe_pci.c
drivers/gpu/drm/xe/xe_pci.h

index bbe6f8e65844c3a88055ba2a053dbefe817da529..0e39a0255b992e83ade581772144330077a27180 100644 (file)
@@ -1223,6 +1223,23 @@ static struct pci_driver xe_pci_driver = {
 #endif
 };
 
+/**
+ * xe_pci_to_pf_device() - Get PF &xe_device.
+ * @pdev: the VF &pci_dev device
+ *
+ * Return: pointer to PF &xe_device, NULL otherwise.
+ */
+struct xe_device *xe_pci_to_pf_device(struct pci_dev *pdev)
+{
+       struct drm_device *drm;
+
+       drm = pci_iov_get_pf_drvdata(pdev, &xe_pci_driver);
+       if (IS_ERR(drm))
+               return NULL;
+
+       return to_xe_device(drm);
+}
+
 int xe_register_pci_driver(void)
 {
        return pci_register_driver(&xe_pci_driver);
index 611c1209b14cc5a187764f23b20aa1cff03399fe..11bcc5fe2c5b9a4e20353fc8884357aa9da388db 100644 (file)
@@ -6,7 +6,10 @@
 #ifndef _XE_PCI_H_
 #define _XE_PCI_H_
 
+struct pci_dev;
+
 int xe_register_pci_driver(void);
 void xe_unregister_pci_driver(void);
+struct xe_device *xe_pci_to_pf_device(struct pci_dev *pdev);
 
 #endif