From patchwork Fri Oct 18 17:12:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Gordeev X-Patchwork-Id: 284834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7D6B42C00E0 for ; Sat, 19 Oct 2013 17:47:40 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751027Ab3JSGri (ORCPT ); Sat, 19 Oct 2013 02:47:38 -0400 Received: from 221-186-24-89.in-addr.arpa ([89.24.186.221]:13845 "EHLO dhcp-26-207.brq.redhat.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750960Ab3JSGrh (ORCPT ); Sat, 19 Oct 2013 02:47:37 -0400 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 r9IHDftc004793; Fri, 18 Oct 2013 19:13:42 +0200 Received: (from agordeev@localhost) by dhcp-26-207.brq.redhat.com (8.14.5/8.14.5/Submit) id r9IHDfuL004791; Fri, 18 Oct 2013 19:13:41 +0200 From: Alexander Gordeev To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Bjorn Helgaas , Michael Ellerman , Benjamin Herrenschmidt , Tejun Heo , Ben Hutchings , David Laight , Mark Lord , "H. Peter Anvin" , linux-pci@vger.kernel.org Subject: [PATCH RFC v2 19/29] ntb: Make use of pcim_enable_msix/msix_exact() interfaces Date: Fri, 18 Oct 2013 19:12:19 +0200 Message-Id: <99464bf7495829672d97faa9beac3d456877b7b4.1382103786.git.agordeev@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: References: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Signed-off-by: Alexander Gordeev --- drivers/ntb/ntb_hw.c | 38 +++++++++++++------------------------- 1 files changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c index de2062c..b7d6eed 100644 --- a/drivers/ntb/ntb_hw.c +++ b/drivers/ntb/ntb_hw.c @@ -1032,22 +1032,15 @@ static int ntb_setup_msix(struct ntb_device *ndev) struct msix_entry *msix; int msix_entries; int rc, i; - u16 val; - if (!pdev->msix_cap) { - rc = -EIO; - goto err; - } - - rc = pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &val); - if (rc) + rc = pci_msix_table_size(pdev); + if (rc < 0) goto err; - - msix_entries = msix_table_size(val); - if (msix_entries > ndev->limits.msix_cnt) { + else if (rc > ndev->limits.msix_cnt) { rc = -EINVAL; goto err; - } + } else + msix_entries = rc; ndev->msix_entries = kmalloc(sizeof(struct msix_entry) * msix_entries, GFP_KERNEL); @@ -1059,26 +1052,21 @@ static int ntb_setup_msix(struct ntb_device *ndev) for (i = 0; i < msix_entries; i++) ndev->msix_entries[i].entry = i; - rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries); - if (rc < 0) - goto err1; - if (rc > 0) { + if (ndev->hw_type != BWD_HW) /* On SNB, the link interrupt is always tied to 4th vector. If * we can't get all 4, then we can't use MSI-X. */ - if (ndev->hw_type != BWD_HW) { - rc = -EIO; - goto err1; - } - + rc = pcim_enable_msix_exact(pdev, + ndev->msix_entries, msix_entries); + else + rc = pcim_enable_msix(pdev, ndev->msix_entries, msix_entries); + if (rc < 0) + goto err1; + else if (rc < msix_entries) { dev_warn(&pdev->dev, "Only %d MSI-X vectors. Limiting the number of queues to that number.\n", rc); msix_entries = rc; - - rc = pci_enable_msix(pdev, ndev->msix_entries, msix_entries); - if (rc) - goto err1; } for (i = 0; i < msix_entries; i++) {