Commit 13d2a838 authored by Grzegorz Andrejczuk's avatar Grzegorz Andrejczuk Committed by Jason Gunthorpe

IB/hfi1: Decouple IRQ name from type

IRQ name was connected to IRQ type, this is not sufficient and it would be
better to use name as argument to msix_request_irq instead of assigning it
to variables when function is called.

Index argument was required to generate name and now it can be removed.

To generate name correctly helpers function were added and updated.

Link: https://lore.kernel.org/r/20200106134216.119356.44478.stgit@awfm-01.aw.intel.comReviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarGrzegorz Andrejczuk <grzegorz.andrejczuk@intel.com>
Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 62661038
...@@ -115,13 +115,11 @@ int msix_initialize(struct hfi1_devdata *dd) ...@@ -115,13 +115,11 @@ int msix_initialize(struct hfi1_devdata *dd)
*/ */
static int msix_request_irq(struct hfi1_devdata *dd, void *arg, static int msix_request_irq(struct hfi1_devdata *dd, void *arg,
irq_handler_t handler, irq_handler_t thread, irq_handler_t handler, irq_handler_t thread,
u32 idx, enum irq_type type) enum irq_type type, const char *name)
{ {
unsigned long nr; unsigned long nr;
int irq; int irq;
int ret; int ret;
const char *err_info;
char name[MAX_NAME_SIZE];
struct hfi1_msix_entry *me; struct hfi1_msix_entry *me;
/* Allocate an MSIx vector */ /* Allocate an MSIx vector */
...@@ -135,43 +133,15 @@ static int msix_request_irq(struct hfi1_devdata *dd, void *arg, ...@@ -135,43 +133,15 @@ static int msix_request_irq(struct hfi1_devdata *dd, void *arg,
if (nr == dd->msix_info.max_requested) if (nr == dd->msix_info.max_requested)
return -ENOSPC; return -ENOSPC;
/* Specific verification and determine the name */ if (type < IRQ_SDMA && type >= IRQ_OTHER)
switch (type) {
case IRQ_GENERAL:
/* general interrupt must be MSIx vector 0 */
if (nr) {
spin_lock(&dd->msix_info.msix_lock);
__clear_bit(nr, dd->msix_info.in_use_msix);
spin_unlock(&dd->msix_info.msix_lock);
dd_dev_err(dd, "Invalid index %lu for GENERAL IRQ\n",
nr);
return -EINVAL;
}
snprintf(name, sizeof(name), DRIVER_NAME "_%d", dd->unit);
err_info = "general";
break;
case IRQ_SDMA:
snprintf(name, sizeof(name), DRIVER_NAME "_%d sdma%d",
dd->unit, idx);
err_info = "sdma";
break;
case IRQ_RCVCTXT:
snprintf(name, sizeof(name), DRIVER_NAME "_%d kctxt%d",
dd->unit, idx);
err_info = "receive context";
break;
case IRQ_OTHER:
default:
return -EINVAL; return -EINVAL;
}
name[sizeof(name) - 1] = 0;
irq = pci_irq_vector(dd->pcidev, nr); irq = pci_irq_vector(dd->pcidev, nr);
ret = pci_request_irq(dd->pcidev, nr, handler, thread, arg, name); ret = pci_request_irq(dd->pcidev, nr, handler, thread, arg, name);
if (ret) { if (ret) {
dd_dev_err(dd, dd_dev_err(dd,
"%s: request for IRQ %d failed, MSIx %d, err %d\n", "%s: request for IRQ %d failed, MSIx %lu, err %d\n",
err_info, irq, idx, ret); name, irq, nr, ret);
spin_lock(&dd->msix_info.msix_lock); spin_lock(&dd->msix_info.msix_lock);
__clear_bit(nr, dd->msix_info.in_use_msix); __clear_bit(nr, dd->msix_info.in_use_msix);
spin_unlock(&dd->msix_info.msix_lock); spin_unlock(&dd->msix_info.msix_lock);
...@@ -195,17 +165,13 @@ static int msix_request_irq(struct hfi1_devdata *dd, void *arg, ...@@ -195,17 +165,13 @@ static int msix_request_irq(struct hfi1_devdata *dd, void *arg,
return nr; return nr;
} }
/** static int msix_request_rcd_irq_common(struct hfi1_ctxtdata *rcd,
* msix_request_rcd_irq() - Helper function for RCVAVAIL IRQs irq_handler_t handler,
* @rcd: valid rcd context irq_handler_t thread,
* const char *name)
*/
int msix_request_rcd_irq(struct hfi1_ctxtdata *rcd)
{ {
int nr; int nr = msix_request_irq(rcd->dd, rcd, handler, thread,
IRQ_RCVCTXT, name);
nr = msix_request_irq(rcd->dd, rcd, receive_context_interrupt,
receive_context_thread, rcd->ctxt, IRQ_RCVCTXT);
if (nr < 0) if (nr < 0)
return nr; return nr;
...@@ -221,6 +187,22 @@ int msix_request_rcd_irq(struct hfi1_ctxtdata *rcd) ...@@ -221,6 +187,22 @@ int msix_request_rcd_irq(struct hfi1_ctxtdata *rcd)
return 0; return 0;
} }
/**
* msix_request_rcd_irq() - Helper function for RCVAVAIL IRQs
* @rcd: valid rcd context
*
*/
int msix_request_rcd_irq(struct hfi1_ctxtdata *rcd)
{
char name[MAX_NAME_SIZE];
snprintf(name, sizeof(name), DRIVER_NAME "_%d kctxt%d",
rcd->dd->unit, rcd->ctxt);
return msix_request_rcd_irq_common(rcd, receive_context_interrupt,
receive_context_thread, name);
}
/** /**
* msix_request_smda_ira() - Helper for getting SDMA IRQ resources * msix_request_smda_ira() - Helper for getting SDMA IRQ resources
* @sde: valid sdma engine * @sde: valid sdma engine
...@@ -229,9 +211,12 @@ int msix_request_rcd_irq(struct hfi1_ctxtdata *rcd) ...@@ -229,9 +211,12 @@ int msix_request_rcd_irq(struct hfi1_ctxtdata *rcd)
int msix_request_sdma_irq(struct sdma_engine *sde) int msix_request_sdma_irq(struct sdma_engine *sde)
{ {
int nr; int nr;
char name[MAX_NAME_SIZE];
snprintf(name, sizeof(name), DRIVER_NAME "_%d sdma%d",
sde->dd->unit, sde->this_idx);
nr = msix_request_irq(sde->dd, sde, sdma_interrupt, NULL, nr = msix_request_irq(sde->dd, sde, sdma_interrupt, NULL,
sde->this_idx, IRQ_SDMA); IRQ_SDMA, name);
if (nr < 0) if (nr < 0)
return nr; return nr;
sde->msix_intr = nr; sde->msix_intr = nr;
...@@ -240,6 +225,32 @@ int msix_request_sdma_irq(struct sdma_engine *sde) ...@@ -240,6 +225,32 @@ int msix_request_sdma_irq(struct sdma_engine *sde)
return 0; return 0;
} }
/**
* msix_request_general_irq(void) - Helper for getting general IRQ
* resources
* @dd: valid device data
*/
int msix_request_general_irq(struct hfi1_devdata *dd)
{
int nr;
char name[MAX_NAME_SIZE];
snprintf(name, sizeof(name), DRIVER_NAME "_%d", dd->unit);
nr = msix_request_irq(dd, dd, general_interrupt, NULL, IRQ_GENERAL,
name);
if (nr < 0)
return nr;
/* general interrupt must be MSIx vector 0 */
if (nr) {
msix_free_irq(dd, (u8)nr);
dd_dev_err(dd, "Invalid index %d for GENERAL IRQ\n", nr);
return -EINVAL;
}
return 0;
}
/** /**
* enable_sdma_src() - Helper to enable SDMA IRQ srcs * enable_sdma_src() - Helper to enable SDMA IRQ srcs
* @dd: valid devdata structure * @dd: valid devdata structure
...@@ -265,10 +276,9 @@ static void enable_sdma_srcs(struct hfi1_devdata *dd, int i) ...@@ -265,10 +276,9 @@ static void enable_sdma_srcs(struct hfi1_devdata *dd, int i)
int msix_request_irqs(struct hfi1_devdata *dd) int msix_request_irqs(struct hfi1_devdata *dd)
{ {
int i; int i;
int ret; int ret = msix_request_general_irq(dd);
ret = msix_request_irq(dd, dd, general_interrupt, NULL, 0, IRQ_GENERAL); if (ret)
if (ret < 0)
return ret; return ret;
for (i = 0; i < dd->num_sdma; i++) { for (i = 0; i < dd->num_sdma; i++) {
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
int msix_initialize(struct hfi1_devdata *dd); int msix_initialize(struct hfi1_devdata *dd);
int msix_request_irqs(struct hfi1_devdata *dd); int msix_request_irqs(struct hfi1_devdata *dd);
void msix_clean_up_interrupts(struct hfi1_devdata *dd); void msix_clean_up_interrupts(struct hfi1_devdata *dd);
int msix_request_general_irq(struct hfi1_devdata *dd);
int msix_request_rcd_irq(struct hfi1_ctxtdata *rcd); int msix_request_rcd_irq(struct hfi1_ctxtdata *rcd);
int msix_request_sdma_irq(struct sdma_engine *sde); int msix_request_sdma_irq(struct sdma_engine *sde);
void msix_free_irq(struct hfi1_devdata *dd, u8 msix_intr); void msix_free_irq(struct hfi1_devdata *dd, u8 msix_intr);
......
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