Skip to content

vfio/pci: Remove duplicate code and logic from VFIO PCI interrupt management

Reinette Chatre kvm linux-patches lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest17 patches 20 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17vfio/pci: Use unsigned int instead of unsigneddrivers/vfio/pci/vfio_pci_intrs.c+24 -180 replies
2/17vfio/pci: Remove duplicate check from vfio_pci_set_ctx_trigger_single() wrappersdrivers/vfio/pci/vfio_pci_intrs.c+8 -40 replies
3/17vfio/pci: Consistently acquire mutex for interrupt managementdrivers/vfio/pci/vfio_pci_core.c drivers/vfio/pci/vfio_pci_intrs.c+8 -52 replies
4/17vfio/pci: Remove duplicate interrupt management from core VFIO PCIdrivers/vfio/pci/vfio_pci_core.c+6 -100 replies
5/17vfio/pci: Limit eventfd signaling to interrupt management codedrivers/vfio/pci/vfio_pci_core.c+13 -170 replies
6/17vfio/pci: Remove interrupt index interpretation from wrappersdrivers/vfio/pci/vfio_pci_intrs.c+21 -172 replies
7/17vfio/pci: Preserve per-interrupt contextsdrivers/vfio/pci/vfio_pci_intrs.c+14 -124 replies
8/17vfio/pci: Extract MSI/MSI-X specific code from common flowdrivers/vfio/pci/vfio_pci_intrs.c+89 -450 replies
9/17vfio/pci: Converge similar code flowsdrivers/vfio/pci/vfio_pci_intrs.c+6 -40 replies
10/17vfio/pci: Extract INTx specific code from vfio_intx_set_signal()drivers/vfio/pci/vfio_pci_intrs.c+49 -200 replies
11/17vfio/pci: Perform MSI/MSI-X interrupt management via callbacksdrivers/vfio/pci/vfio_pci_intrs.c+39 -50 replies
12/17vfio/pci: Remove msi term from generic codedrivers/vfio/pci/vfio_pci_intrs.c+7 -72 replies
13/17vfio/pci: Remove vfio_intx_set_signal()drivers/vfio/pci/vfio_pci_intrs.c+13 -490 replies
14/17vfio/pci: Add utility to trigger INTx eventfd knowing interrupt contextdrivers/vfio/pci/vfio_pci_intrs.c+25 -70 replies
15/17vfio/pci: Let enable and disable of interrupt types use same signaturedrivers/vfio/pci/vfio_pci_intrs.c+18 -98 replies
16/17vfio/pci: Move vfio_msi_disable() to be with other MSI/MSI-X management codedrivers/vfio/pci/vfio_pci_intrs.c+29 -290 replies
17/17vfio/pci: Remove duplicate interrupt management flowdrivers/vfio/pci/vfio_pci_intrs.c+35 -692 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/17] vfio/pci: Remove duplicate code and logic from VFIO PCI interrupt management

Hi Everybody,

Duplicate VFIO PCI interrupt management code and logic can be found in two areas:
1) the VFIO PCI core (vfio_pci_core.c) directly accesses the VFIO PCI interrupt lock and data to duplicate actions available via the VFIO PCI interrupt management code (vfio_pci_intrs.c), and
2) the INTx and MSI/MSI-X interrupt management code within vfio_pci_intrs.c have duplicate logic.

This series addresses (1) and (2) by first containing VFIO PCI interrupt management within the VFIO PCI interrupt management code found in vfio_pci_intrs.c and then refactoring the VFIO PCI interrupt management code (vfio_pci_intrs.c) to share common logic between INTx, MSI, and MSI-X interrupt management.

Bulk of the changes result in the same actions as before this series. Two functional changes to highlight:
a) "vfio/pci: Consistently acquire mutex for interrupt management" changes vfio_pci_core_disable()->vfio_pci_set_irqs_ioctl() to be called with the igate mutex held.
b) "vfio/pci: Preserve per-interrupt contexts" changes MSI/MSI-x interrupt management to preserve per-interrupt contexts across interrupt allocate/free.

This work was inspired by (and inherits a few patches from) the IMS [1] enabling work but this work is submitted (and expected to be considered) independent from IMS.

Any feedback will be appreciated.

Reinette

[1] https://lore.kernel.org/lkml/[email protected]/

Reinette Chatre (17):
vfio/pci: Use unsigned int instead of unsigned
vfio/pci: Remove duplicate check from
vfio_pci_set_ctx_trigger_single() wrappers
vfio/pci: Consistently acquire mutex for interrupt management vfio/pci: Remove duplicate interrupt management from core VFIO PCI vfio/pci: Limit eventfd signaling to interrupt management code vfio/pci: Remove interrupt index interpretation from wrappers vfio/pci: Preserve per-interrupt contexts
vfio/pci: Extract MSI/MSI-X specific code from common flow vfio/pci: Converge similar code flows
vfio/pci: Extract INTx specific code from vfio_intx_set_signal() vfio/pci: Perform MSI/MSI-X interrupt management via callbacks vfio/pci: Remove msi term from generic code
vfio/pci: Remove vfio_intx_set_signal()
vfio/pci: Add utility to trigger INTx eventfd knowing interrupt
context
vfio/pci: Let enable and disable of interrupt types use same signature vfio/pci: Move vfio_msi_disable() to be with other MSI/MSI-X
management code
vfio/pci: Remove duplicate interrupt management flow

 drivers/vfio/pci/vfio_pci_core.c  |  49 ++-
 drivers/vfio/pci/vfio_pci_intrs.c | 510 ++++++++++++++++++------------
 2 files changed, 318 insertions(+), 241 deletions(-)

base-commit: 41bccc98fb7931d63d03f326a746ac4d429c1dd3

Signature · 1 line
2.34.1