According PCI local bus specification, the register of Message Control for MSI (offset: 2, length: 2) has bit#0 to enable or disable MSI logic and it shouldn't be part contributing to the calculation of MSI interrupt count. The patch fixes above issue. Also, the patch renames local variable "flags" to "ctl" for both MSI and MSIx case. Signed-off-by: Gavin Shan <shangw@xxxxxxxxxxxxxxxxxx> --- drivers/vfio/pci/vfio_pci.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 7ba0424..5760ea6 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -190,25 +190,23 @@ static int vfio_pci_get_irq_count(struct vfio_pci_device *vdev, int irq_type) } else if (irq_type == VFIO_PCI_MSI_IRQ_INDEX) { u8 pos; - u16 flags; + u16 ctl; pos = vdev->pdev->msi_cap; if (pos) { pci_read_config_word(vdev->pdev, - pos + PCI_MSI_FLAGS, &flags); - - return 1 << (flags & PCI_MSI_FLAGS_QMASK); + pos + PCI_MSI_FLAGS, &ctl); + return 1 << ((ctl & PCI_MSI_FLAGS_QMASK) >> 1); } } else if (irq_type == VFIO_PCI_MSIX_IRQ_INDEX) { u8 pos; - u16 flags; + u16 ctl; pos = vdev->pdev->msix_cap; if (pos) { pci_read_config_word(vdev->pdev, - pos + PCI_MSIX_FLAGS, &flags); - - return (flags & PCI_MSIX_FLAGS_QSIZE) + 1; + pos + PCI_MSIX_FLAGS, &ctl); + return (ctl & PCI_MSIX_FLAGS_QSIZE) + 1; } } else if (irq_type == VFIO_PCI_ERR_IRQ_INDEX) if (pci_is_pcie(vdev->pdev)) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html