[PATCH RFC v1 0/3] Support dynamic MSI-X allocation

Jing Liu posted 3 patches 9 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230727072410.135743-1-jing2.liu@intel.com
Maintainers: Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>
There is a newer version of this series
hw/vfio/pci.c        | 84 +++++++++++++++++++++++++++++++++++++-------
hw/vfio/pci.h        |  1 +
hw/vfio/trace-events |  2 ++
3 files changed, 74 insertions(+), 13 deletions(-)
[PATCH RFC v1 0/3] Support dynamic MSI-X allocation
Posted by Jing Liu 9 months, 1 week ago
Before kernel v6.5, dynamic allocation of MSI-X interrupts was not
supported. Qemu therefore when allocating a new interrupt, should first
release all previously allocated interrupts (including disable of MSI-X)
and re-allocate all interrupts that includes the new one.

The kernel series [1] adds the support of dynamic MSI-X allocation to
vfio-pci and uses the existing flag VFIO_IRQ_INFO_NORESIZE to guide user
space, that when dynamic MSI-X is supported the flag is cleared.

This series makes the behavior for VFIO PCI devices when dynamic MSI-X
allocation is supported. When guest unmasks an interrupt, Qemu can
directly allocate an interrupt on host for this and has nothing to do
with the previously allocated ones. Therefore, host only allocates
interrupts for those unmasked (enabled) interrupts inside guest when
dynamic MSI-X allocation is supported by device.

During migration restore, Qemu calls vfio_enable_vectors() to enable
MSI-X and interrupts. Since the API causes that a number of irqs set to
host kernel are all allocated when enabling MSI-X, to avoid this, one
possible way is that Qemu first sets vector 0 to host kernel to enable
MSI-X with an invalid fd. After MSI-X enabling, the API can decide which
should be allocated via the event fd value. In this way, the interrupts
allocation on target would be the same as migration source.

Jing Liu (2):
  vfio/pci: enable vector on dynamic MSI-X allocation
  vfio/pci: dynamic MSI-X allocation in interrupt restoring

Reinette Chatre (1):
  vfio/pci: detect the support of dynamic MSI-X allocation

 hw/vfio/pci.c        | 84 +++++++++++++++++++++++++++++++++++++-------
 hw/vfio/pci.h        |  1 +
 hw/vfio/trace-events |  2 ++
 3 files changed, 74 insertions(+), 13 deletions(-)

-- 
2.27.0