From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gavin Shan Subject: [PATCH 2/3] drivers/vfio/pci: Fix wrong MSI interrupt count Date: Mon, 10 Mar 2014 13:46:54 +0800 Message-ID: <1394430415-15574-3-git-send-email-shangw@linux.vnet.ibm.com> References: <1394430415-15574-1-git-send-email-shangw@linux.vnet.ibm.com> Cc: kvm@vger.kernel.org, benh@kernel.crashing.org, aik@ozlabs.ru, Gavin Shan To: alex.williamson@redhat.com Return-path: Received: from e39.co.us.ibm.com ([32.97.110.160]:33061 "EHLO e39.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753187AbaCJFrQ (ORCPT ); Mon, 10 Mar 2014 01:47:16 -0400 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 9 Mar 2014 23:47:15 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 6100E3E4003F for ; Sun, 9 Mar 2014 23:47:13 -0600 (MDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by b03cxnp07029.gho.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2A3iRa07930162 for ; Mon, 10 Mar 2014 04:44:27 +0100 Received: from d03av02.boulder.ibm.com (localhost [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s2A5lCiX026532 for ; Sun, 9 Mar 2014 23:47:12 -0600 In-Reply-To: <1394430415-15574-1-git-send-email-shangw@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 the issue. Signed-off-by: Gavin Shan --- drivers/vfio/pci/vfio_pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 7ba0424..6b8cd07 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -196,8 +196,7 @@ static int vfio_pci_get_irq_count(struct vfio_pci_device *vdev, int irq_type) if (pos) { pci_read_config_word(vdev->pdev, pos + PCI_MSI_FLAGS, &flags); - - return 1 << (flags & PCI_MSI_FLAGS_QMASK); + return 1 << ((flags & PCI_MSI_FLAGS_QMASK) >> 1); } } else if (irq_type == VFIO_PCI_MSIX_IRQ_INDEX) { u8 pos; -- 1.7.10.4