* [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
* Re: [PATCH rdma-next] RDMA/bnxt_re: Don't republish a QP whose destroy failed
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
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-24 2:00 UTC (permalink / raw)
To: Yuho Choi; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] RDMA/bnxt_re: data race in bnxt_qplib_create_qp1() [1]
--
commit 1b21d21008b23e4ba7182837a1d5e17b617eab26
Author: Yuho Choi <oss.patchbox@gmail.com>
RDMA/bnxt_re: Don't republish a QP whose destroy failed
This commit drops the rcfw->qp_tbl rollback in bnxt_qplib_destroy_qp() so a
QP is not reinserted into the table if the DESTROY_QP firmware command
fails.
> diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
> index 5301e4f21ade0..a5660002d1840 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);
> }
[Severity: High]
This problem wasn't introduced by this patch, but shouldn't
bnxt_qplib_create_qp1() also hold rcfw->tbl_lock when populating
rcfw->qp_tbl [1]?
drivers/infiniband/hw/bnxt_re/qplib_fp.c:bnxt_qplib_create_qp1() {
...
tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw);
rcfw->qp_tbl[tbl_indx].qp_id = qp->id;
rcfw->qp_tbl[tbl_indx].qp_handle = (void *)qp;
return 0;
...
}
Once bnxt_qplib_rcfw_send_message() completes CREATE_QP1, firmware can
emit events for the new QP while bnxt_qplib_create_qp1() is still running:
CPU0 CPU1 (CREQ tasklet)
bnxt_qplib_create_qp1()
bnxt_qplib_rcfw_send_message()
bnxt_qplib_process_qp_event()
spin_lock(&rcfw->tbl_lock)
rcfw->qp_tbl[tbl_indx].qp_id = ...
rcfw->qp_tbl[tbl_indx].qp_handle = ...
reads rcfw->qp_tbl[tbl_indx]
<-- data race
spin_unlock(&rcfw->tbl_lock)
Without rcfw->tbl_lock, bnxt_qplib_process_qp_event() can observe a
partially updated qp_tbl entry, missing a QP error notification or
dereferencing an uninitialized qp_handle.
[1] https://sashiko.dev/#/bug/linux-c8dafdae-4eb3-4ddb-a2a2-5d1da6ca2da5
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124015141.294866-2-oss.patchbox@gmail.com?part=1
^ permalink raw reply [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