Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH rdma-next] RDMA/bnxt_re: Don't republish a QP whose destroy failed
@ 2026-11-24  1:51 Yuho Choi
  2026-11-24  2:00 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-11-24  1:51 UTC (permalink / raw)
  To: Selvin Xavier, Kalesh AP
  Cc: Jason Gunthorpe, Leon Romanovsky, linux-rdma, Yuho Choi

bnxt_qplib_destroy_qp() removes the QP from rcfw->qp_tbl before sending
DESTROY_QP and re-inserts it if bnxt_qplib_rcfw_send_message() fails.

No caller uses the QP after a failure, though:
- bnxt_re_destroy_qp() logs the error and returns 0 since
  commit d507d29bfde3 ("RDMA/bnxt_re: Don't fail destroy QP and cleanup
  debugfs earlier"), so the IB core frees the QP.
- bnxt_re_destroy_gsi_sqp() logs the error and frees gsi_sqp.
- bnxt_re_create_qp() frees the QP resources and returns the error so the
  IB core frees the QP.
- bnxt_re_create_shadow_gsi() abandons the shadow QP on failure.

Moreover, on the error paths of bnxt_qplib_create_qp() and
bnxt_qplib_create_qp1(), bnxt_qplib_destroy_qp() is called before the QP
is even inserted into rcfw->qp_tbl (and before sq_flush/rq_flush are
initialized in bnxt_qplib_create_qp()), so the rollback publishes a
half-initialized QP that is about to be freed.

Except for the abandoned shadow QP, the QP is freed right after, so
rcfw->qp_tbl is left with a dangling pointer. On a later QP error
notification, bnxt_qplib_process_qp_event() marks that QP in error and
passes it to the async event handler.

Drop the rollback so the QP stays out of rcfw->qp_tbl when DESTROY_QP
fails.

Fixes: f218d67ef004 ("RDMA/bnxt_re: Allow posting when QPs are in error")
Fixes: d507d29bfde3 ("RDMA/bnxt_re: Don't fail destroy QP and cleanup debugfs earlier")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Compile-tested only (x86_64 with INFINIBAND_BNXT_RE, W=1). I have no
NetXtreme-E RoCE hardware, and DESTROY_QP only fails when the firmware
times out or returns an error status, so I could not trigger it.

 drivers/infiniband/hw/bnxt_re/qplib_fp.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
index 5301e4f21ade..a5660002d184 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
@@ -1473,7 +1473,6 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res,
 	struct bnxt_qplib_cmdqmsg msg = {};
 	struct cmdq_destroy_qp req = {};
 	u32 tbl_indx;
-	int rc;
 
 	spin_lock_bh(&rcfw->tbl_lock);
 	tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw);
@@ -1488,16 +1487,11 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res,
 	req.qp_cid = cpu_to_le32(qp->id);
 	bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, NULL, sizeof(req),
 				sizeof(resp), 0);
-	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
-	if (rc) {
-		spin_lock_bh(&rcfw->tbl_lock);
-		rcfw->qp_tbl[tbl_indx].qp_id = qp->id;
-		rcfw->qp_tbl[tbl_indx].qp_handle = qp;
-		spin_unlock_bh(&rcfw->tbl_lock);
-		return rc;
-	}
-
-	return 0;
+	/*
+	 * Don't put the QP back into qp_tbl if the command fails: no caller
+	 * uses the QP after a failure, and most of them free it right away.
+	 */
+	return bnxt_qplib_rcfw_send_message(rcfw, &msg);
 }
 
 void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res,

base-commit: 8dac6df92a2e66e2098bbc69061964cfe7e8375b
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24  2:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  1:51 [PATCH rdma-next] RDMA/bnxt_re: Don't republish a QP whose destroy failed Yuho Choi
2026-11-24  2:00 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox