Re: [PATCH v3 0/1] vfio/pci: Give drivers control of PCI driver_data

From: Alex Williamson

Date: Sat Oct 10 2026 - 15:49:04 EST


On Mon, 5 Oct 2026 11:42:35 -0700
Simon Song <xinmengs@xxxxxxxxxx> wrote:

> Hi all,
>
> This patch lets VFIO PCI variant drivers store their private structures
> in PCI driver_data, removing the requirement that it point directly to
> struct vfio_pci_core_device. This also accommodates the typed driver data
> used by the Rust PCI infrastructure, as discussed for the proposed Rust
> NVIDIA vGPU VFIO driver [1].
>
> Runtime PM and AER helpers receive an explicit vfio_pci_core_device
> pointer. VFIO_PCI_CORE_DEFINE_CALLBACKS() generates per-driver wrappers
> that retrieve the driver's private data and pass its embedded core device
> to these helpers. Each driver installs its own PM ops table.
>
> VGA initialization selects the decode callback in vfio_pci_vga_init()
> based on vfio_vga_disabled(vdev). Both callbacks use pci_dev directly and
> do not depend on driver_data.
>
> Changes since v2 [2]:
> - Drop the unused pci_channel_state_t argument from the core AER helper
> and its callers, preserving the PCI callback signature (Danilo).
> - Wrap each driver's PM ops pointer with pm_ptr() so unused tables can
> be removed when CONFIG_PM=n (Sashiko).
>
> Changes since v1:
> - Extend VFIO_PCI_CORE_DEFINE_CALLBACKS() to accept the driver's private
> structure type and the member containing vfio_pci_core_device.
> - Store each variant driver's private structure in PCI driver_data.
> - Select the VGA decode callback in the core and retain the one-argument
> vfio_pci_core_register_device() interface.
>
> [1] https://lore.kernel.org/all/DLFD2ZDSK9YQ.3A4R66G8UJMD8@xxxxxxxxxx/
> [2] https://lore.kernel.org/r/20260930143641.4160785-1-xinmengs@xxxxxxxxxx/
>
> Thanks,
> Simon
>
> Simon Song (1):
> vfio/pci: Remove the core dependency on driver data
>
> .../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(-)
>

I pulled in Dave's topic/pci-vgaarb-rework-2026-10-01, which gives us
93d41424caf7. The vfio_pci_core_device is now registered with the vga
client so we no longer need to derive anything from the pci_dev. This
makes all the VGA changes here unnecessary.

Applied to vfio next branch for v7.4 with the VGA chunks (shown in
the discussion thread) and commit log paragraph describing them dropped.
Thanks,

Alex