git: virtio: Fix and activate PCI MSI-X support.

Sepherosa Ziehau sepherosa at gmail.com
Sun Feb 12 02:41:15 PST 2017


I don't like the design of the virtio bus, i.e. assigning the MSI-X
target CPU behind the driver's back; driver should have control over
the MSI-X target CPU (it does not matter that much for legacy
interrupt and MSI though).

On Sat, Feb 11, 2017 at 8:00 PM, Imre Vadasz
<ivadasz at crater.dragonflybsd.org> wrote:
>
> commit c8247d066210114260c306e56365cd1346df7855
> Author: Imre Vadász <imre at vdsz.com>
> Date:   Wed Feb 8 22:05:35 2017 +0100
>
>     virtio: Fix and activate PCI MSI-X support.
>
>     * Change pci_msi_blacklisted() test to always assume working MSI and MSI-X
>       interrupts on virtual-machines. We should assume that a hypervisor
>       without MSI or MSI-X support shouldn't even indicate supported MSI(-X)
>       via the PCI config space.
>
>     * Move vtblk_alloc_disk() to the end of virtio_blk's attach method.
>       This avoids a race between irq enabling in virtio, and the disk probing.
>
>     * Fix allocation and teardown of MSI-X interrupts.
>
>     * Get rid of rather confusing VIRTIO_PCI_FLAG_NO_MSI and
>       VIRTIO_PCI_FLAG_NO_MSIX flags. The VIRTIO_PCI_FLAG_NO_MSI is unneeded
>       when using pci_alloc_1intr() for MSI allocation, and
>       instead of VIRTIO_PCI_FLAG_NO_MSIX we can just check sc->vtpci_msix_res.
>
>     * For now, MSI-X vectors are simply assigned to subsequent cores (plus
>       adding the device_get_unit() value to shuffle things a bit), i.e.:
>       (device_get_unit(dev) + cnt) % ncpus
>
>     * For the if_vtnet network driver this means that the rx and tx queues run
>       on different cores, but both queues still use the same serializer for
>       now.
>
>     * One major advantages in using MSI-X interrupts instead of the legacy
>       IRQ is, that this avoids interrupt sharing in many virtual-machine
>       configurations.
>
>     * Tested on qemu with TCG (unaccelerated emulation) and 1 core, and with
>       KVM acceleration and 2 cores, with both virtio network and disk devices.
>
> Summary of changes:
>  share/man/man4/virtio.4                   |  10 ++
>  sys/bus/pci/pci.c                         |   8 ++
>  sys/dev/virtual/virtio/block/virtio_blk.c |   4 +-
>  sys/dev/virtual/virtio/pci/virtio_pci.c   | 206 ++++++++++++------------------
>  4 files changed, 105 insertions(+), 123 deletions(-)
>
> http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/c8247d066210114260c306e56365cd1346df7855
>
>
> --
> DragonFly BSD source repository



-- 
Tomorrow Will Never Die


More information about the Commits mailing list