Skip to content

vfio/pci: Latch module params, fix bitfield use and VGA unwind

Alex Williamson kvm lkml stable 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 2 repliesIn review
  2. v25 patches 6 repliesSuperseded
  3. v12 patches 1 replySuperseded

Changes in v3 from the cover letter

- patch 1: Remove the conditional runtime PM get/put in vfio_pci_dev_set_pm_runtime_get(), which failed to account for devices that might already be in low power due to the low power device feature ioctl. Now that disable_idle_d3 is no longer global, use the same unconditional runtime PM get/put around try_reset from the disable path. This is harmless regardless of the disable_idle_d3 flag and consistent with other unconditional use cases, such as read/write accesses.

- patch 6: New. Since we need a respin, implement the suggested debugfs exposure of the per-device flag state.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6vfio/pci: Latch disable_idle_d3 per devicedrivers/vfio/pci/vfio_pci_core.c include/linux/vfio_pci_core.h+11 -90 replies
2/6vfio/pci: Release the VGA arbiter client on register_device() failuredrivers/vfio/pci/vfio_pci_core.c+1 -00 replies
3/6vfio/pci: Fix racy bitfields and tighten struct layoutinclude/linux/vfio_pci_core.h+8 -50 replies
4/6vfio/mlx5: Fix racy bitfields and tighten struct layoutdrivers/vfio/pci/mlx5/cmd.h+9 -60 replies
5/6vfio/pci: Latch all module parameters per devicedrivers/vfio/pci/vfio_pci.c drivers/vfio/pci/vfio_pci_core.c include/linux/vfio_pci_core.h+30 -300 replies
6/6vfio/pci: Expose latched module parameter policy in debugfsDocumentation/ABI/testing/debugfs-vfio drivers/vfio/pci/vfio_pci_core.c+85 -00 replies

Reviews trailers per patch

1 of 6 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchChengwen FengKevin Tian
SeriesR-b
1/6
2/6
3/6
4/6
5/6A-b
6/6

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/6] vfio/pci: Latch module params, fix bitfield use and VGA unwind

The vfio-pci module pushes module parameters into vfio-pci-core at initialization that change global policies for all devices, whether bound to vfio-pci itself or other variant drivers. Not only is this generally bad practice, but in the case of runtime PM, policy changes can affect initialized devices, even while they're in use, resulting in unbalanced operations.

This series first addresses the runtime PM case as a separate fix for stable, latching the runtime PM support into the device.

Then, in preparing for moving disable_vga to per device, it's discovered that we lack proper unwind support for a registration failure, leaving the VGA arbiter client registered. This is resolved before it turns into an issue, also marked for stable.

Next, we're again reminded of the risky bitfield use in both the vfio-pci-core and mlx5 variant driver, therefore before expanding use for more per-device flags, perform the binary split to categorize flags as either setup/release or runtime to avoid RMW hazards of the bitfields. Also for stable.

Finally, close the series by pulling vfio-pci module parameter policy out of the core, latching each into the device structure.

This latter change also has the effect of restoring the mutability of two of the module parameters, where that functionality was lost with the vfio-pci-core split. With this series, the current parameter values are latched into the device at probe time.

Please review. Thanks,
Alex

v3:
- patch 1: Remove the conditional runtime PM get/put in vfio_pci_dev_set_pm_runtime_get(), which failed to account for devices that might already be in low power due to the low power device feature ioctl. Now that disable_idle_d3 is no longer global, use the same unconditional runtime PM get/put around try_reset from the disable path. This is harmless regardless of the disable_idle_d3 flag and consistent with other unconditional use cases, such as read/write accesses.

- patch 6: New. Since we need a respin, implement the suggested debugfs exposure of the per-device flag state.

v2:
- Sashiko fixes, including pulling in the bitfield split series.

Alex Williamson (6):
vfio/pci: Latch disable_idle_d3 per device
vfio/pci: Release the VGA arbiter client on register_device() failure vfio/pci: Fix racy bitfields and tighten struct layout vfio/mlx5: Fix racy bitfields and tighten struct layout vfio/pci: Latch all module parameters per device
vfio/pci: Expose latched module parameter policy in debugfs

 Documentation/ABI/testing/debugfs-vfio |  26 +++++++
 drivers/vfio/pci/mlx5/cmd.h            |  15 ++--
 drivers/vfio/pci/vfio_pci.c            |  30 ++++++--
 drivers/vfio/pci/vfio_pci_core.c       | 101 ++++++++++++++++++-------
 include/linux/vfio_pci_core.h          |  18 +++--
 5 files changed, 142 insertions(+), 48 deletions(-)
Signature · 1 line
2.53.0