* [PATCH] kvm tools: Fix MSI-X table size set up
@ 2011-10-27 13:14 Asias He
2011-10-27 16:36 ` Ingo Molnar
0 siblings, 1 reply; 3+ messages in thread
From: Asias He @ 2011-10-27 13:14 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Cyrill Gorcunov, Ingo Molnar, Sasha Levin, kvm, Asias He
We at most have VIRTIO_PCI_MAX_VQ entries for virt queue,
VIRTIO_PCI_MAX_CONFIG entries for config.
To quoto 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
Signed-off-by: Asias He <asias.hejun@gmail.com>
---
tools/kvm/include/kvm/virtio-pci.h | 5 +++--
tools/kvm/virtio/pci.c | 13 ++++++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tools/kvm/include/kvm/virtio-pci.h b/tools/kvm/include/kvm/virtio-pci.h
index d6d98df..81196e5 100644
--- a/tools/kvm/include/kvm/virtio-pci.h
+++ b/tools/kvm/include/kvm/virtio-pci.h
@@ -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;
diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c
index fe3f746..17e570c 100644
--- a/tools/kvm/virtio/pci.c
+++ b/tools/kvm/virtio/pci.c
@@ -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 quoto 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
--
1.7.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kvm tools: Fix MSI-X table size set up
2011-10-27 13:14 [PATCH] kvm tools: Fix MSI-X table size set up Asias He
@ 2011-10-27 16:36 ` Ingo Molnar
2011-10-28 1:11 ` Asias He
0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2011-10-27 16:36 UTC (permalink / raw)
To: Asias He; +Cc: Pekka Enberg, Cyrill Gorcunov, Sasha Levin, kvm
* Asias He <asias.hejun@gmail.com> wrote:
> We at most have VIRTIO_PCI_MAX_VQ entries for virt queue,
> VIRTIO_PCI_MAX_CONFIG entries for config.
>
> To quoto the PCI spec:
s/quoto/quote
Thanks,
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kvm tools: Fix MSI-X table size set up
2011-10-27 16:36 ` Ingo Molnar
@ 2011-10-28 1:11 ` Asias He
0 siblings, 0 replies; 3+ messages in thread
From: Asias He @ 2011-10-28 1:11 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Pekka Enberg, Cyrill Gorcunov, Sasha Levin, kvm
On 10/28/2011 12:36 AM, Ingo Molnar wrote:
>
> * Asias He <asias.hejun@gmail.com> wrote:
>
>> We at most have VIRTIO_PCI_MAX_VQ entries for virt queue,
>> VIRTIO_PCI_MAX_CONFIG entries for config.
>>
>> To quoto the PCI spec:
>
> s/quoto/quote
Pekka has fixed this. Thanks.
--
Asias He
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-28 1:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-27 13:14 [PATCH] kvm tools: Fix MSI-X table size set up Asias He
2011-10-27 16:36 ` Ingo Molnar
2011-10-28 1:11 ` Asias He
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).