]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Fix MSI-X table size set up
authorAsias He <asias.hejun@gmail.com>
Thu, 27 Oct 2011 13:14:33 +0000 (21:14 +0800)
committerPekka Enberg <penberg@kernel.org>
Thu, 27 Oct 2011 13:59:50 +0000 (16:59 +0300)
We at most have VIRTIO_PCI_MAX_VQ entries for virt queue,
VIRTIO_PCI_MAX_CONFIG entries for config.

To quote the PCI spec:

    System software reads this field to determine the
    MSI-X Table Size N, which is encoded as N-1.
    For example, a returned value of "00000000011"
    indicates a table size of 4.

So, we should set table size to

    VIRTIO_PCI_MAX_VQ + VIRTIO_PCI_MAX_CONFIG - 1

not

    VIRTIO_PCI_MAX_VQ + VIRTIO_PCI_MAX_CONFIG

Acked-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/include/kvm/virtio-pci.h
tools/kvm/virtio/pci.c

index d6d98df01ad463ce55eb01fb45339b7ef320eefb..81196e53b89d756302902b3eeba07ec5d4cd6431 100644 (file)
@@ -5,7 +5,8 @@
 
 #include <linux/types.h>
 
-#define VIRTIO_PCI_MAX_VQ 3
+#define VIRTIO_PCI_MAX_VQ      3
+#define VIRTIO_PCI_MAX_CONFIG  1
 
 struct kvm;
 
@@ -44,7 +45,7 @@ struct virtio_pci {
        u32                     msix_io_block;
        u32                     msix_pba_block;
        u64                     msix_pba;
-       struct msix_table       msix_table[VIRTIO_PCI_MAX_VQ + 1];
+       struct msix_table       msix_table[VIRTIO_PCI_MAX_VQ + VIRTIO_PCI_MAX_CONFIG];
 
        /* virtio queue */
        u16                     queue_selector;
index fe3f746982732ab407280b3df6c7dda3a37e3bb8..b8d1ec1b33cdbd6cc8af84ee24248f1faf2f4ced 100644 (file)
@@ -287,7 +287,18 @@ int virtio_pci__init(struct kvm *kvm, struct virtio_pci *vpci, void *dev,
 
        vpci->pci_hdr.msix.cap = PCI_CAP_ID_MSIX;
        vpci->pci_hdr.msix.next = 0;
-       vpci->pci_hdr.msix.ctrl = (VIRTIO_PCI_MAX_VQ + 1);
+       /*
+        * We at most have VIRTIO_PCI_MAX_VQ entries for virt queue,
+        * VIRTIO_PCI_MAX_CONFIG entries for config.
+        *
+        * To quote the PCI spec:
+        *
+        * System software reads this field to determine the
+        * MSI-X Table Size N, which is encoded as N-1.
+        * For example, a returned value of "00000000011"
+        * indicates a table size of 4.
+        */
+       vpci->pci_hdr.msix.ctrl = (VIRTIO_PCI_MAX_VQ + VIRTIO_PCI_MAX_CONFIG - 1);
 
        /*
         * Both table and PBA could be mapped on the same BAR, but for now