From patchwork Wed Oct 2 10:49:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Gordeev X-Patchwork-Id: 279814 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id E17FC2C0392 for ; Thu, 3 Oct 2013 02:38:15 +1000 (EST) Received: from dhcp-26-207.brq.redhat.com (unknown [89.24.186.221]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D1A3A2C00C1 for ; Thu, 3 Oct 2013 02:37:49 +1000 (EST) Received: from dhcp-26-207.brq.redhat.com (localhost [127.0.0.1]) by dhcp-26-207.brq.redhat.com (8.14.5/8.14.5) with ESMTP id r92B062B002767; Wed, 2 Oct 2013 13:00:06 +0200 Received: (from agordeev@localhost) by dhcp-26-207.brq.redhat.com (8.14.5/8.14.5/Submit) id r92B046C002766; Wed, 2 Oct 2013 13:00:04 +0200 From: Alexander Gordeev To: linux-kernel@vger.kernel.org Subject: [PATCH RFC 70/77] vmci: Update MSI/MSI-X interrupts enablement code Date: Wed, 2 Oct 2013 12:49:26 +0200 Message-Id: <654a7884b9ad6fbe777d00bb0a226010e421b3b9.1380703263.git.agordeev@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: References: Cc: linux-mips@linux-mips.org, "VMware, Inc." , linux-nvme@lists.infradead.org, linux-ide@vger.kernel.org, linux-s390@vger.kernel.org, Andy King , linux-scsi@vger.kernel.org, linux-rdma@vger.kernel.org, x86@kernel.org, Alexander Gordeev , linux-pci@vger.kernel.org, iss_storagedev@hp.com, linux-driver@qlogic.com, Tejun Heo , Bjorn Helgaas , Dan Williams , Jon Mason , Ingo Molnar , Solarflare linux maintainers , netdev@vger.kernel.org, Ralf Baechle , e1000-devel@lists.sourceforge.net, Martin Schwidefsky , linux390@de.ibm.com, linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16rc2 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" As result of recent re-design of the MSI/MSI-X interrupts enabling pattern this driver has to be updated to use the new technique to obtain a optimal number of MSI/MSI-X interrupts required. Signed-off-by: Alexander Gordeev --- drivers/misc/vmw_vmci/vmci_guest.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmci_guest.c index b3a2b76..af5caf8 100644 --- a/drivers/misc/vmw_vmci/vmci_guest.c +++ b/drivers/misc/vmw_vmci/vmci_guest.c @@ -377,19 +377,27 @@ static int vmci_enable_msix(struct pci_dev *pdev, { int i; int result; + int nvec; - for (i = 0; i < VMCI_MAX_INTRS; ++i) { + result = pci_msix_table_size(pdev); + if (result < 0) + return result; + + nvec = min(result, VMCI_MAX_INTRS); + if (nvec < VMCI_MAX_INTRS) + nvec = 1; + + for (i = 0; i < nvec; ++i) { vmci_dev->msix_entries[i].entry = i; vmci_dev->msix_entries[i].vector = i; } - result = pci_enable_msix(pdev, vmci_dev->msix_entries, VMCI_MAX_INTRS); - if (result == 0) - vmci_dev->exclusive_vectors = true; - else if (result > 0) - result = pci_enable_msix(pdev, vmci_dev->msix_entries, 1); + result = pci_enable_msix(pdev, vmci_dev->msix_entries, nvec); + if (result) + return result; - return result; + vmci_dev->exclusive_vectors = true; + return 0; } /*