Commit bf3f043e authored by Alexander Gordeev's avatar Alexander Gordeev Committed by Roland Dreier

IB/qib: Use pci_enable_msix_range() instead of pci_enable_msix()

As result of the deprecation of the MSI-X/MSI enablement functions
pci_enable_msix() and pci_enable_msi_block(), all drivers using these
two interfaces need to be updated to use the new pci_enable_msi_range()
and pci_enable_msix_range() interfaces.
Signed-off-by: default avatarAlexander Gordeev <agordeev@redhat.com>
Acked-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 877f075a
...@@ -197,46 +197,47 @@ static void qib_msix_setup(struct qib_devdata *dd, int pos, u32 *msixcnt, ...@@ -197,46 +197,47 @@ static void qib_msix_setup(struct qib_devdata *dd, int pos, u32 *msixcnt,
struct qib_msix_entry *qib_msix_entry) struct qib_msix_entry *qib_msix_entry)
{ {
int ret; int ret;
u32 tabsize = 0; int nvec = *msixcnt;
u16 msix_flags;
struct msix_entry *msix_entry; struct msix_entry *msix_entry;
int i; int i;
ret = pci_msix_vec_count(dd->pcidev);
if (ret < 0)
goto do_intx;
nvec = min(nvec, ret);
/* We can't pass qib_msix_entry array to qib_msix_setup /* We can't pass qib_msix_entry array to qib_msix_setup
* so use a dummy msix_entry array and copy the allocated * so use a dummy msix_entry array and copy the allocated
* irq back to the qib_msix_entry array. */ * irq back to the qib_msix_entry array. */
msix_entry = kmalloc(*msixcnt * sizeof(*msix_entry), GFP_KERNEL); msix_entry = kmalloc(nvec * sizeof(*msix_entry), GFP_KERNEL);
if (!msix_entry) { if (!msix_entry)
ret = -ENOMEM;
goto do_intx; goto do_intx;
}
for (i = 0; i < *msixcnt; i++) for (i = 0; i < nvec; i++)
msix_entry[i] = qib_msix_entry[i].msix; msix_entry[i] = qib_msix_entry[i].msix;
pci_read_config_word(dd->pcidev, pos + PCI_MSIX_FLAGS, &msix_flags); ret = pci_enable_msix_range(dd->pcidev, msix_entry, 1, nvec);
tabsize = 1 + (msix_flags & PCI_MSIX_FLAGS_QSIZE); if (ret < 0)
if (tabsize > *msixcnt) goto free_msix_entry;
tabsize = *msixcnt; else
ret = pci_enable_msix(dd->pcidev, msix_entry, tabsize); nvec = ret;
if (ret > 0) {
tabsize = ret; for (i = 0; i < nvec; i++)
ret = pci_enable_msix(dd->pcidev, msix_entry, tabsize);
}
do_intx:
if (ret) {
qib_dev_err(dd,
"pci_enable_msix %d vectors failed: %d, falling back to INTx\n",
tabsize, ret);
tabsize = 0;
}
for (i = 0; i < tabsize; i++)
qib_msix_entry[i].msix = msix_entry[i]; qib_msix_entry[i].msix = msix_entry[i];
kfree(msix_entry); kfree(msix_entry);
*msixcnt = tabsize; *msixcnt = nvec;
return;
if (ret) free_msix_entry:
qib_enable_intx(dd->pcidev); kfree(msix_entry);
do_intx:
qib_dev_err(dd, "pci_enable_msix_range %d vectors failed: %d, "
"falling back to INTx\n", nvec, ret);
*msixcnt = 0;
qib_enable_intx(dd->pcidev);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment