Commit bb7dde87 authored by Michael J. Ruhl's avatar Michael J. Ruhl Committed by Doug Ledford

IB/hfi1: Replace deprecated pci functions with new API

pci_enable_msix_range() and pci_disable_msix() have been deprecated.
Updating to the new pci_alloc_irq_vectors() interface.
Reviewed-by: default avatarSebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 721c4621
/* /*
* Copyright(c) 2015, 2016 Intel Corporation. * Copyright(c) 2015 - 2017 Intel Corporation.
* *
* This file is provided under a dual BSD/GPLv2 license. When using or * This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license. * redistributing this file, you may do so under either license.
...@@ -335,10 +335,10 @@ static void hfi1_update_sdma_affinity(struct hfi1_msix_entry *msix, int cpu) ...@@ -335,10 +335,10 @@ static void hfi1_update_sdma_affinity(struct hfi1_msix_entry *msix, int cpu)
sde->cpu = cpu; sde->cpu = cpu;
cpumask_clear(&msix->mask); cpumask_clear(&msix->mask);
cpumask_set_cpu(cpu, &msix->mask); cpumask_set_cpu(cpu, &msix->mask);
dd_dev_dbg(dd, "IRQ vector: %u, type %s engine %u -> cpu: %d\n", dd_dev_dbg(dd, "IRQ: %u, type %s engine %u -> cpu: %d\n",
msix->msix.vector, irq_type_names[msix->type], msix->irq, irq_type_names[msix->type],
sde->this_idx, cpu); sde->this_idx, cpu);
irq_set_affinity_hint(msix->msix.vector, &msix->mask); irq_set_affinity_hint(msix->irq, &msix->mask);
/* /*
* Set the new cpu in the hfi1_affinity_node and clean * Set the new cpu in the hfi1_affinity_node and clean
...@@ -387,7 +387,7 @@ static void hfi1_setup_sdma_notifier(struct hfi1_msix_entry *msix) ...@@ -387,7 +387,7 @@ static void hfi1_setup_sdma_notifier(struct hfi1_msix_entry *msix)
{ {
struct irq_affinity_notify *notify = &msix->notify; struct irq_affinity_notify *notify = &msix->notify;
notify->irq = msix->msix.vector; notify->irq = msix->irq;
notify->notify = hfi1_irq_notifier_notify; notify->notify = hfi1_irq_notifier_notify;
notify->release = hfi1_irq_notifier_release; notify->release = hfi1_irq_notifier_release;
...@@ -472,10 +472,10 @@ static int get_irq_affinity(struct hfi1_devdata *dd, ...@@ -472,10 +472,10 @@ static int get_irq_affinity(struct hfi1_devdata *dd,
} }
cpumask_set_cpu(cpu, &msix->mask); cpumask_set_cpu(cpu, &msix->mask);
dd_dev_info(dd, "IRQ vector: %u, type %s %s -> cpu: %d\n", dd_dev_info(dd, "IRQ: %u, type %s %s -> cpu: %d\n",
msix->msix.vector, irq_type_names[msix->type], msix->irq, irq_type_names[msix->type],
extra, cpu); extra, cpu);
irq_set_affinity_hint(msix->msix.vector, &msix->mask); irq_set_affinity_hint(msix->irq, &msix->mask);
if (msix->type == IRQ_SDMA) { if (msix->type == IRQ_SDMA) {
sde->cpu = cpu; sde->cpu = cpu;
...@@ -533,7 +533,7 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd, ...@@ -533,7 +533,7 @@ void hfi1_put_irq_affinity(struct hfi1_devdata *dd,
} }
} }
irq_set_affinity_hint(msix->msix.vector, NULL); irq_set_affinity_hint(msix->irq, NULL);
cpumask_clear(&msix->mask); cpumask_clear(&msix->mask);
mutex_unlock(&node_affinity.lock); mutex_unlock(&node_affinity.lock);
} }
......
...@@ -12800,30 +12800,24 @@ static void clean_up_interrupts(struct hfi1_devdata *dd) ...@@ -12800,30 +12800,24 @@ static void clean_up_interrupts(struct hfi1_devdata *dd)
for (i = 0; i < dd->num_msix_entries; i++, me++) { for (i = 0; i < dd->num_msix_entries; i++, me++) {
if (!me->arg) /* => no irq, no affinity */ if (!me->arg) /* => no irq, no affinity */
continue; continue;
hfi1_put_irq_affinity(dd, &dd->msix_entries[i]); hfi1_put_irq_affinity(dd, me);
free_irq(me->msix.vector, me->arg); free_irq(me->irq, me->arg);
} }
/* clean structures */
kfree(dd->msix_entries);
dd->msix_entries = NULL;
dd->num_msix_entries = 0;
} else { } else {
/* INTx */ /* INTx */
if (dd->requested_intx_irq) { if (dd->requested_intx_irq) {
free_irq(dd->pcidev->irq, dd); free_irq(dd->pcidev->irq, dd);
dd->requested_intx_irq = 0; dd->requested_intx_irq = 0;
} }
}
/* turn off interrupts */
if (dd->num_msix_entries) {
/* MSI-X */
pci_disable_msix(dd->pcidev);
} else {
/* INTx */
disable_intx(dd->pcidev); disable_intx(dd->pcidev);
} }
/* clean structures */ pci_free_irq_vectors(dd->pcidev);
kfree(dd->msix_entries);
dd->msix_entries = NULL;
dd->num_msix_entries = 0;
} }
/* /*
...@@ -12972,13 +12966,21 @@ static int request_msix_irqs(struct hfi1_devdata *dd) ...@@ -12972,13 +12966,21 @@ static int request_msix_irqs(struct hfi1_devdata *dd)
continue; continue;
/* make sure the name is terminated */ /* make sure the name is terminated */
me->name[sizeof(me->name) - 1] = 0; me->name[sizeof(me->name) - 1] = 0;
me->irq = pci_irq_vector(dd->pcidev, i);
/*
* On err return me->irq. Don't need to clear this
* because 'arg' has not been set, and cleanup will
* do the right thing.
*/
if (me->irq < 0)
return me->irq;
ret = request_threaded_irq(me->msix.vector, handler, thread, 0, ret = request_threaded_irq(me->irq, handler, thread, 0,
me->name, arg); me->name, arg);
if (ret) { if (ret) {
dd_dev_err(dd, dd_dev_err(dd,
"unable to allocate %s interrupt, vector %d, index %d, err %d\n", "unable to allocate %s interrupt, irq %d, index %d, err %d\n",
err_info, me->msix.vector, idx, ret); err_info, me->irq, idx, ret);
return ret; return ret;
} }
/* /*
...@@ -12989,8 +12991,7 @@ static int request_msix_irqs(struct hfi1_devdata *dd) ...@@ -12989,8 +12991,7 @@ static int request_msix_irqs(struct hfi1_devdata *dd)
ret = hfi1_get_irq_affinity(dd, me); ret = hfi1_get_irq_affinity(dd, me);
if (ret) if (ret)
dd_dev_err(dd, dd_dev_err(dd, "unable to pin IRQ %d\n", ret);
"unable to pin IRQ %d\n", ret);
} }
return ret; return ret;
...@@ -13009,7 +13010,7 @@ void hfi1_vnic_synchronize_irq(struct hfi1_devdata *dd) ...@@ -13009,7 +13010,7 @@ void hfi1_vnic_synchronize_irq(struct hfi1_devdata *dd)
struct hfi1_ctxtdata *rcd = dd->vnic.ctxt[i]; struct hfi1_ctxtdata *rcd = dd->vnic.ctxt[i];
struct hfi1_msix_entry *me = &dd->msix_entries[rcd->msix_intr]; struct hfi1_msix_entry *me = &dd->msix_entries[rcd->msix_intr];
synchronize_irq(me->msix.vector); synchronize_irq(me->irq);
} }
} }
...@@ -13022,7 +13023,7 @@ void hfi1_reset_vnic_msix_info(struct hfi1_ctxtdata *rcd) ...@@ -13022,7 +13023,7 @@ void hfi1_reset_vnic_msix_info(struct hfi1_ctxtdata *rcd)
return; return;
hfi1_put_irq_affinity(dd, me); hfi1_put_irq_affinity(dd, me);
free_irq(me->msix.vector, me->arg); free_irq(me->irq, me->arg);
me->arg = NULL; me->arg = NULL;
} }
...@@ -13050,14 +13051,19 @@ void hfi1_set_vnic_msix_info(struct hfi1_ctxtdata *rcd) ...@@ -13050,14 +13051,19 @@ void hfi1_set_vnic_msix_info(struct hfi1_ctxtdata *rcd)
DRIVER_NAME "_%d kctxt%d", dd->unit, idx); DRIVER_NAME "_%d kctxt%d", dd->unit, idx);
me->name[sizeof(me->name) - 1] = 0; me->name[sizeof(me->name) - 1] = 0;
me->type = IRQ_RCVCTXT; me->type = IRQ_RCVCTXT;
me->irq = pci_irq_vector(dd->pcidev, rcd->msix_intr);
if (me->irq < 0) {
dd_dev_err(dd, "vnic irq vector request (idx %d) fail %d\n",
idx, me->irq);
return;
}
remap_intr(dd, IS_RCVAVAIL_START + idx, rcd->msix_intr); remap_intr(dd, IS_RCVAVAIL_START + idx, rcd->msix_intr);
ret = request_threaded_irq(me->msix.vector, receive_context_interrupt, ret = request_threaded_irq(me->irq, receive_context_interrupt,
receive_context_thread, 0, me->name, arg); receive_context_thread, 0, me->name, arg);
if (ret) { if (ret) {
dd_dev_err(dd, "vnic irq request (vector %d, idx %d) fail %d\n", dd_dev_err(dd, "vnic irq request (irq %d, idx %d) fail %d\n",
me->msix.vector, idx, ret); me->irq, idx, ret);
return; return;
} }
/* /*
...@@ -13070,7 +13076,7 @@ void hfi1_set_vnic_msix_info(struct hfi1_ctxtdata *rcd) ...@@ -13070,7 +13076,7 @@ void hfi1_set_vnic_msix_info(struct hfi1_ctxtdata *rcd)
if (ret) { if (ret) {
dd_dev_err(dd, dd_dev_err(dd,
"unable to pin IRQ %d\n", ret); "unable to pin IRQ %d\n", ret);
free_irq(me->msix.vector, me->arg); free_irq(me->irq, me->arg);
} }
} }
...@@ -13093,9 +13099,8 @@ static void reset_interrupts(struct hfi1_devdata *dd) ...@@ -13093,9 +13099,8 @@ static void reset_interrupts(struct hfi1_devdata *dd)
static int set_up_interrupts(struct hfi1_devdata *dd) static int set_up_interrupts(struct hfi1_devdata *dd)
{ {
struct hfi1_msix_entry *entries; u32 total;
u32 total, request; int ret, request;
int i, ret;
int single_interrupt = 0; /* we expect to have all the interrupts */ int single_interrupt = 0; /* we expect to have all the interrupts */
/* /*
...@@ -13107,39 +13112,31 @@ static int set_up_interrupts(struct hfi1_devdata *dd) ...@@ -13107,39 +13112,31 @@ static int set_up_interrupts(struct hfi1_devdata *dd)
*/ */
total = 1 + dd->num_sdma + dd->n_krcv_queues + HFI1_NUM_VNIC_CTXT; total = 1 + dd->num_sdma + dd->n_krcv_queues + HFI1_NUM_VNIC_CTXT;
entries = kcalloc(total, sizeof(*entries), GFP_KERNEL);
if (!entries) {
ret = -ENOMEM;
goto fail;
}
/* 1-1 MSI-X entry assignment */
for (i = 0; i < total; i++)
entries[i].msix.entry = i;
/* ask for MSI-X interrupts */ /* ask for MSI-X interrupts */
request = total; request = request_msix(dd, total);
request_msix(dd, &request, entries); if (request < 0) {
ret = request;
if (request == 0) { goto fail;
} else if (request == 0) {
/* using INTx */ /* using INTx */
/* dd->num_msix_entries already zero */ /* dd->num_msix_entries already zero */
kfree(entries);
single_interrupt = 1; single_interrupt = 1;
dd_dev_err(dd, "MSI-X failed, using INTx interrupts\n"); dd_dev_err(dd, "MSI-X failed, using INTx interrupts\n");
} else { } else if (request < total) {
/* using MSI-X */
dd->num_msix_entries = request;
dd->msix_entries = entries;
if (request != total) {
/* using MSI-X, with reduced interrupts */ /* using MSI-X, with reduced interrupts */
dd_dev_err( dd_dev_err(dd, "reduced interrupt found, wanted %u, got %u\n",
dd,
"cannot handle reduced interrupt case, want %u, got %u\n",
total, request); total, request);
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
} else {
dd->msix_entries = kcalloc(total, sizeof(*dd->msix_entries),
GFP_KERNEL);
if (!dd->msix_entries) {
ret = -ENOMEM;
goto fail;
} }
/* using MSI-X */
dd->num_msix_entries = total;
dd_dev_info(dd, "%u MSI-X interrupts allocated\n", total); dd_dev_info(dd, "%u MSI-X interrupts allocated\n", total);
} }
......
...@@ -521,7 +521,7 @@ static inline void incr_cntr32(u32 *cntr) ...@@ -521,7 +521,7 @@ static inline void incr_cntr32(u32 *cntr)
#define MAX_NAME_SIZE 64 #define MAX_NAME_SIZE 64
struct hfi1_msix_entry { struct hfi1_msix_entry {
enum irq_type type; enum irq_type type;
struct msix_entry msix; int irq;
void *arg; void *arg;
char name[MAX_NAME_SIZE]; char name[MAX_NAME_SIZE];
cpumask_t mask; cpumask_t mask;
...@@ -1838,9 +1838,7 @@ void hfi1_pcie_cleanup(struct pci_dev *pdev); ...@@ -1838,9 +1838,7 @@ void hfi1_pcie_cleanup(struct pci_dev *pdev);
int hfi1_pcie_ddinit(struct hfi1_devdata *dd, struct pci_dev *pdev); int hfi1_pcie_ddinit(struct hfi1_devdata *dd, struct pci_dev *pdev);
void hfi1_pcie_ddcleanup(struct hfi1_devdata *); void hfi1_pcie_ddcleanup(struct hfi1_devdata *);
int pcie_speeds(struct hfi1_devdata *dd); int pcie_speeds(struct hfi1_devdata *dd);
void request_msix(struct hfi1_devdata *dd, u32 *nent, int request_msix(struct hfi1_devdata *dd, u32 msireq);
struct hfi1_msix_entry *entry);
void hfi1_enable_intx(struct pci_dev *pdev);
void restore_pci_variables(struct hfi1_devdata *dd); void restore_pci_variables(struct hfi1_devdata *dd);
int do_pcie_gen3_transition(struct hfi1_devdata *dd); int do_pcie_gen3_transition(struct hfi1_devdata *dd);
int parse_platform_config(struct hfi1_devdata *dd); int parse_platform_config(struct hfi1_devdata *dd);
......
/* /*
* Copyright(c) 2015, 2016 Intel Corporation. * Copyright(c) 2015 - 2017 Intel Corporation.
* *
* This file is provided under a dual BSD/GPLv2 license. When using or * This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license. * redistributing this file, you may do so under either license.
...@@ -240,50 +240,6 @@ void hfi1_pcie_ddcleanup(struct hfi1_devdata *dd) ...@@ -240,50 +240,6 @@ void hfi1_pcie_ddcleanup(struct hfi1_devdata *dd)
iounmap(dd->piobase); iounmap(dd->piobase);
} }
static void msix_setup(struct hfi1_devdata *dd, int pos, u32 *msixcnt,
struct hfi1_msix_entry *hfi1_msix_entry)
{
int ret;
int nvec = *msixcnt;
struct msix_entry *msix_entry;
int i;
/*
* We can't pass hfi1_msix_entry array to msix_setup
* so use a dummy msix_entry array and copy the allocated
* irq back to the hfi1_msix_entry array.
*/
msix_entry = kmalloc_array(nvec, sizeof(*msix_entry), GFP_KERNEL);
if (!msix_entry) {
ret = -ENOMEM;
goto do_intx;
}
for (i = 0; i < nvec; i++)
msix_entry[i] = hfi1_msix_entry[i].msix;
ret = pci_enable_msix_range(dd->pcidev, msix_entry, 1, nvec);
if (ret < 0)
goto free_msix_entry;
nvec = ret;
for (i = 0; i < nvec; i++)
hfi1_msix_entry[i].msix = msix_entry[i];
kfree(msix_entry);
*msixcnt = nvec;
return;
free_msix_entry:
kfree(msix_entry);
do_intx:
dd_dev_err(dd, "pci_enable_msix_range %d vectors failed: %d, falling back to INTx\n",
nvec, ret);
*msixcnt = 0;
hfi1_enable_intx(dd->pcidev);
}
/* return the PCIe link speed from the given link status */ /* return the PCIe link speed from the given link status */
static u32 extract_speed(u16 linkstat) static u32 extract_speed(u16 linkstat)
{ {
...@@ -364,33 +320,29 @@ int pcie_speeds(struct hfi1_devdata *dd) ...@@ -364,33 +320,29 @@ int pcie_speeds(struct hfi1_devdata *dd)
} }
/* /*
* Returns in *nent: * Returns:
* - actual number of interrupts allocated * - actual number of interrupts allocated or
* - 0 if fell back to INTx. * - 0 if fell back to INTx.
* - error
*/ */
void request_msix(struct hfi1_devdata *dd, u32 *nent, int request_msix(struct hfi1_devdata *dd, u32 msireq)
struct hfi1_msix_entry *entry)
{ {
int pos; int nvec;
pos = dd->pcidev->msix_cap; nvec = pci_alloc_irq_vectors(dd->pcidev, 1, msireq,
if (*nent && pos) { PCI_IRQ_MSIX | PCI_IRQ_LEGACY);
msix_setup(dd, pos, nent, entry); if (nvec < 0) {
/* did it, either MSI-X or INTx */ dd_dev_err(dd, "pci_alloc_irq_vectors() failed: %d\n", nvec);
} else { return nvec;
*nent = 0;
hfi1_enable_intx(dd->pcidev);
} }
tune_pcie_caps(dd); tune_pcie_caps(dd);
}
void hfi1_enable_intx(struct pci_dev *pdev) /* check for legacy IRQ */
{ if (nvec == 1 && !dd->pcidev->msix_enabled)
/* first, turn on INTx */ return 0;
pci_intx(pdev, 1);
/* then turn off MSI-X */ return nvec;
pci_disable_msix(pdev);
} }
/* restore command and BARs after a reset has wiped them out */ /* restore command and BARs after a reset has wiped them out */
......
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