RDMA/bnxt_re: Use unique names while registering interrupts
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Fri, 19 May 2023 06:48:13 +0000 (23:48 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 19 May 2023 16:26:18 +0000 (13:26 -0300)
bnxt_re currently uses the names "bnxt_qplib_creq" and "bnxt_qplib_nq-0"
while registering IRQs. There is no way to distinguish the IRQs of
different device ports when there are multiple IB devices registered.
This could make the scenarios worse where one want to pin IRQs of a device
port to certain CPUs.

Fixed the code to use unique names which has PCI BDF information while
registering interrupts like: "bnxt_re-nq-0@pci:0000:65:00.0" and
"bnxt_re-creq@pci:0000:65:00.1".

Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Link: https://lore.kernel.org/r/1684478897-12247-4-git-send-email-selvin.xavier@broadcom.com
Reviewed-by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/bnxt_re/qplib_fp.c
drivers/infiniband/hw/bnxt_re/qplib_fp.h
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h

index 298d89390e66dde0a18c648268bf5b4a7eabb70d..ff33d7733369f64e2876ca66fea99ae28ff01c67 100644 (file)
@@ -412,6 +412,8 @@ void bnxt_qplib_nq_stop_irq(struct bnxt_qplib_nq *nq, bool kill)
 
        irq_set_affinity_hint(nq->msix_vec, NULL);
        free_irq(nq->msix_vec, nq);
+       kfree(nq->name);
+       nq->name = NULL;
        nq->requested = false;
 }
 
@@ -438,6 +440,7 @@ void bnxt_qplib_disable_nq(struct bnxt_qplib_nq *nq)
 int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
                            int msix_vector, bool need_init)
 {
+       struct bnxt_qplib_res *res = nq->res;
        int rc;
 
        if (nq->requested)
@@ -449,9 +452,14 @@ int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
        else
                tasklet_enable(&nq->nq_tasklet);
 
-       snprintf(nq->name, sizeof(nq->name), "bnxt_qplib_nq-%d", nq_indx);
+       nq->name = kasprintf(GFP_KERNEL, "bnxt_re-nq-%d@pci:%s",
+                            nq_indx, pci_name(res->pdev));
+       if (!nq->name)
+               return -ENOMEM;
        rc = request_irq(nq->msix_vec, bnxt_qplib_nq_irq, 0, nq->name, nq);
        if (rc) {
+               kfree(nq->name);
+               nq->name = NULL;
                tasklet_disable(&nq->nq_tasklet);
                return rc;
        }
@@ -465,7 +473,7 @@ int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
                         nq->msix_vec, nq_indx);
        }
        nq->requested = true;
-       bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, nq->res->cctx, true);
+       bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, res->cctx, true);
 
        return rc;
 }
index d74d5ead2e32a2de2e8a05969af4ad0ccc859c2d..a42820821c473073973331750924c7f8421cb9b6 100644 (file)
@@ -472,7 +472,7 @@ typedef int (*srqn_handler_t)(struct bnxt_qplib_nq *nq,
 struct bnxt_qplib_nq {
        struct pci_dev                  *pdev;
        struct bnxt_qplib_res           *res;
-       char                            name[32];
+       char                            *name;
        struct bnxt_qplib_hwq           hwq;
        struct bnxt_qplib_nq_db         nq_db;
        u16                             ring_id;
index a668f877a7bf74a5acc2ba33daeadbdd29a57632..688eaa01db649ff36376aedc756a6ea79dd112d6 100644 (file)
@@ -649,6 +649,8 @@ void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill)
                tasklet_kill(&creq->creq_tasklet);
 
        free_irq(creq->msix_vec, rcfw);
+       kfree(creq->irq_name);
+       creq->irq_name = NULL;
        creq->requested = false;
 }
 
@@ -681,9 +683,11 @@ int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector,
                              bool need_init)
 {
        struct bnxt_qplib_creq_ctx *creq;
+       struct bnxt_qplib_res *res;
        int rc;
 
        creq = &rcfw->creq;
+       res = rcfw->res;
 
        if (creq->requested)
                return -EFAULT;
@@ -693,15 +697,22 @@ int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector,
                tasklet_setup(&creq->creq_tasklet, bnxt_qplib_service_creq);
        else
                tasklet_enable(&creq->creq_tasklet);
+
+       creq->irq_name = kasprintf(GFP_KERNEL, "bnxt_re-creq@pci:%s",
+                                  pci_name(res->pdev));
+       if (!creq->irq_name)
+               return -ENOMEM;
        rc = request_irq(creq->msix_vec, bnxt_qplib_creq_irq, 0,
-                        "bnxt_qplib_creq", rcfw);
+                        creq->irq_name, rcfw);
        if (rc) {
+               kfree(creq->irq_name);
+               creq->irq_name = NULL;
                tasklet_disable(&creq->creq_tasklet);
                return rc;
        }
        creq->requested = true;
 
-       bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, rcfw->res->cctx, true);
+       bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true);
 
        return 0;
 }
index dd5651478bbb77be1c1f343c48265178853353ba..92f7a25533d3bdfbf16d47fcc5269ef9322e0822 100644 (file)
@@ -186,6 +186,7 @@ struct bnxt_qplib_creq_ctx {
        u16                             ring_id;
        int                             msix_vec;
        bool                            requested; /*irq handler installed */
+       char                            *irq_name;
 };
 
 /* RCFW Communication Channels */