[PATCH RFC v2 19/29] ntb: Make use of pcim_enable_msix/msix_exact() interfaces

From: Alexander Gordeev
Date: Sat Oct 19 2013 - 02:47:42 EST


Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxx>
---
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++) {
--
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/