Skip to content

Commit 5effcac

Browse files
selvintxavierrleon
authored andcommitted
RDMA/bnxt_re: Avoid initializing the software queue for user queues
Software Queues to hold the WRs needs to be created for only kernel queues. Avoid allocating the unnecessary memory for user Queues. Fixes: 1ac5a40 ("RDMA/bnxt_re: Add bnxt_re RoCE driver") Fixes: 159fb4c ("RDMA/bnxt_re: introduce a function to allocate swq") Signed-off-by: Selvin Xavier <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 79d330f commit 5effcac

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,6 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
659659
rc = bnxt_qplib_alloc_init_hwq(&srq->hwq, &hwq_attr);
660660
if (rc)
661661
return rc;
662-
663-
srq->swq = kcalloc(srq->hwq.max_elements, sizeof(*srq->swq),
664-
GFP_KERNEL);
665-
if (!srq->swq) {
666-
rc = -ENOMEM;
667-
goto fail;
668-
}
669662
srq->dbinfo.flags = 0;
670663
bnxt_qplib_rcfw_cmd_prep((struct cmdq_base *)&req,
671664
CMDQ_BASE_OPCODE_CREATE_SRQ,
@@ -694,9 +687,17 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
694687
spin_lock_init(&srq->lock);
695688
srq->start_idx = 0;
696689
srq->last_idx = srq->hwq.max_elements - 1;
697-
for (idx = 0; idx < srq->hwq.max_elements; idx++)
698-
srq->swq[idx].next_idx = idx + 1;
699-
srq->swq[srq->last_idx].next_idx = -1;
690+
if (!srq->hwq.is_user) {
691+
srq->swq = kcalloc(srq->hwq.max_elements, sizeof(*srq->swq),
692+
GFP_KERNEL);
693+
if (!srq->swq) {
694+
rc = -ENOMEM;
695+
goto fail;
696+
}
697+
for (idx = 0; idx < srq->hwq.max_elements; idx++)
698+
srq->swq[idx].next_idx = idx + 1;
699+
srq->swq[srq->last_idx].next_idx = -1;
700+
}
700701

701702
srq->id = le32_to_cpu(resp.xid);
702703
srq->dbinfo.hwq = &srq->hwq;
@@ -1042,13 +1043,14 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
10421043
if (rc)
10431044
return rc;
10441045

1045-
rc = bnxt_qplib_alloc_init_swq(sq);
1046-
if (rc)
1047-
goto fail_sq;
1048-
1049-
if (psn_sz)
1050-
bnxt_qplib_init_psn_ptr(qp, psn_sz);
1046+
if (!sq->hwq.is_user) {
1047+
rc = bnxt_qplib_alloc_init_swq(sq);
1048+
if (rc)
1049+
goto fail_sq;
10511050

1051+
if (psn_sz)
1052+
bnxt_qplib_init_psn_ptr(qp, psn_sz);
1053+
}
10521054
req.sq_size = cpu_to_le32(bnxt_qplib_set_sq_size(sq, qp->wqe_mode));
10531055
pbl = &sq->hwq.pbl[PBL_LVL_0];
10541056
req.sq_pbl = cpu_to_le64(pbl->pg_map_arr[0]);
@@ -1074,9 +1076,11 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
10741076
rc = bnxt_qplib_alloc_init_hwq(&rq->hwq, &hwq_attr);
10751077
if (rc)
10761078
goto sq_swq;
1077-
rc = bnxt_qplib_alloc_init_swq(rq);
1078-
if (rc)
1079-
goto fail_rq;
1079+
if (!rq->hwq.is_user) {
1080+
rc = bnxt_qplib_alloc_init_swq(rq);
1081+
if (rc)
1082+
goto fail_rq;
1083+
}
10801084

10811085
req.rq_size = cpu_to_le32(rq->max_wqe);
10821086
pbl = &rq->hwq.pbl[PBL_LVL_0];

0 commit comments

Comments
 (0)