Skip to content

vfio/pci: Give drivers control of PCI driver_data

Simon Song kvm lkml 2 versions – Applied

Status from this message: Applied to vfio next branch for v7.4 with the VGA chunks (shown in

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest1 patch 6 repliesApplied
  2. v21 patch 3 repliesSuperseded

Changes since v1 from the cover letter

- 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/[email protected]/
[2] https://lore.kernel.org/r/[email protected]/

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/1vfio/pci: Remove the core dependency on driver datadrivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c drivers/vfio/pci/ism/main.c drivers/vfio/pci/mlx5/main.c +9 more+159 -954 replies

Reviews trailers per patch

The patch has a Reviewed-by or Acked-by.

PatchDanilo KrummrichJason Gunthorpe
1/1R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

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

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/[email protected]/
[2] https://lore.kernel.org/r/[email protected]/

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(-)
Signature · 1 line
2.43.7