[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a2e355aa-87d7-4459-b34e-1e04be02fb93@intel.com>
Date: Fri, 31 Oct 2025 18:39:11 +0100
From: Michal Wajdeczko <michal.wajdeczko@...el.com>
To: Michał Winiarski <michal.winiarski@...el.com>, "Alex
Williamson" <alex@...zbot.org>, Lucas De Marchi <lucas.demarchi@...el.com>,
Thomas Hellström <thomas.hellstrom@...ux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@...el.com>, Jason Gunthorpe <jgg@...pe.ca>,
Yishai Hadas <yishaih@...dia.com>, Kevin Tian <kevin.tian@...el.com>, Shameer
Kolothum <skolothumtho@...dia.com>, <intel-xe@...ts.freedesktop.org>,
<linux-kernel@...r.kernel.org>, <kvm@...r.kernel.org>, Matthew Brost
<matthew.brost@...el.com>, Matt Roper <matthew.d.roper@...el.com>
CC: <dri-devel@...ts.freedesktop.org>, Jani Nikula
<jani.nikula@...ux.intel.com>, Joonas Lahtinen
<joonas.lahtinen@...ux.intel.com>, Tvrtko Ursulin <tursulin@...ulin.net>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, "Lukasz
Laguna" <lukasz.laguna@...el.com>, Christoph Hellwig <hch@...radead.org>
Subject: Re: [PATCH v3 25/28] drm/xe/pci: Introduce a helper to allow VF
access to PF xe_device
On 10/30/2025 9:31 PM, Michał Winiarski wrote:
> 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.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@...el.com>
> ---
> drivers/gpu/drm/xe/xe_pci.c | 17 +++++++++++++++++
> drivers/gpu/drm/xe/xe_pci.h | 3 +++
> 2 files changed, 20 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
> index aeae675c912b7..3e7b03c847a42 100644
> --- a/drivers/gpu/drm/xe/xe_pci.c
> +++ b/drivers/gpu/drm/xe/xe_pci.c
> @@ -1224,6 +1224,23 @@ static struct pci_driver xe_pci_driver = {
> #endif
> };
>
> +/**
> + * xe_pci_get_pf_xe_device() - Get PF &xe_device.
> + * @pdev: the VF &pci_dev device
> + *
> + * Return: pointer to PF &xe_device, NULL otherwise.
> + */
> +struct xe_device *xe_pci_get_pf_xe_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);
> +}
I would rather expose xe_pci_driver from xe_pci.c (*) and then
make this a static helper as part of the vfio export file
static struct xe_device *to_xe_pf(struct pci_dev *pdev)
but maybe Lucas or Matt has a different opinion
(*) this will also help us to move our live-kunit generator to a better place
> +
> int xe_register_pci_driver(void)
> {
> return pci_register_driver(&xe_pci_driver);
> diff --git a/drivers/gpu/drm/xe/xe_pci.h b/drivers/gpu/drm/xe/xe_pci.h
> index 611c1209b14cc..2bb2e486756db 100644
> --- a/drivers/gpu/drm/xe/xe_pci.h
> +++ b/drivers/gpu/drm/xe/xe_pci.h
> @@ -6,6 +6,9 @@
> #ifndef _XE_PCI_H_
> #define _XE_PCI_H_
>
> +struct pci_dev;
> +
> +struct xe_device *xe_pci_get_pf_xe_device(struct pci_dev *pdev);
> int xe_register_pci_driver(void);
> void xe_unregister_pci_driver(void);
>
Powered by blists - more mailing lists