Re: [PATCH v3 1/1] vfio/pci: Remove the core dependency on driver data

From: Jason Gunthorpe

Date: Fri Oct 09 2026 - 15:38:36 EST


On Mon, Oct 05, 2026 at 11:42:36AM -0700, Simon Song wrote:
> vfio-pci-core currently has runtime functions that interpret pci
> driver_data as a pointer to vfio_pci_core_device, and enforce vfio
> variant drivers must set vfio_pci_core_device to their pci driver_data.
> This constrains variant drivers' private-data layout, including the
> typed driver data used by the Rust PCI infrastructure.
>
> Add VFIO_PCI_CORE_DEFINE_CALLBACKS marcos to generate wrapper code for
> each vfio variant driver, update vfio variant drivers to store their
> private strctures in driver_data and use generated wrapper to pass the
> vfio core device to helpers.
>
> Select the vga decode callback during vfio_pci_vga_init based on if
> vfio_vga_disabled, the callback only use pci_dev and does not require
> driver_data
>
> Assisted-by: LLM
> Suggested-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Suggested-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
> Suggested-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> Link: https://lore.kernel.org/all/DLFD2ZDSK9YQ.3A4R66G8UJMD8@xxxxxxxxxx/
> Signed-off-by: Simon Song <xinmengs@xxxxxxxxxx>
> ---
> .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 27 ++++----
> drivers/vfio/pci/ism/main.c | 19 +++---
> drivers/vfio/pci/mlx5/main.c | 13 ++--
> drivers/vfio/pci/nvgrace-gpu/main.c | 19 +++---
> drivers/vfio/pci/pds/pci_drv.c | 8 ++-
> drivers/vfio/pci/pds/vfio_dev.c | 5 +-
> drivers/vfio/pci/qat/main.c | 12 ++--
> drivers/vfio/pci/vfio_pci.c | 33 +++++++++-
> drivers/vfio/pci/vfio_pci_core.c | 61 +++++++------------
> drivers/vfio/pci/virtio/main.c | 8 ++-
> drivers/vfio/pci/xe/main.c | 8 ++-
> include/linux/vfio_pci_core.h | 41 ++++++++++++-
> 12 files changed, 159 insertions(+), 95 deletions(-)

This looks OK to me, but it probably should have been 3 patches,
mixing the VGA stuff into all of this (and you have a smart approach)
is not how upstream likes to see things arranged.

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason