[PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
From: Joe Damato
Date: Fri Nov 20 2026 - 10:28:55 EST
When HWRM_RING_FREE is sent over a completion ring, __hwrm_send() waits
for NAPI to consume the completion and gives up if it never arrives,
without looking at the response.
If a completion is not posted within the timeout, check the response
before giving up. If resp_len is set, the sequence id matches, and the
valid byte is set then the firmware completed the command and only the
notification was lost. Fall through to the normal error_code handling in
that case.
This check runs only after the full command timeout. A response that is
still being written reads a zero valid byte, so the command is still
treated as failed. The rest of the response is read only after the valid
byte has been seen.
Log the response state on both paths so there is more data when this rare
event occurs.
Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")
Signed-off-by: Joe Damato <joe@xxxxxxx>
---
.../net/ethernet/broadcom/bnxt/bnxt_hwrm.c | 47 +++++++++++++++++--
1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
index de02d1baa751..53667c0c38aa 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
@@ -582,11 +582,50 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
}
if (READ_ONCE(token->state) != BNXT_HWRM_COMPLETE) {
- hwrm_err(bp, ctx, "Resp cmpl intr err msg: 0x%x\n",
- req_type);
- goto exit;
+ __le16 resp_seq_id;
+ u8 valid_byte = 0;
+
+ /* Only HWRM_RING_FREE checks the response here. The
+ * other users of a completion ring depend on the
+ * completion itself: the IRQ self test, and
+ * HWRM_RING_RESET, which reuses the ring. A cancelled
+ * wait means the device is being torn down.
+ */
+ if (req_type != HWRM_RING_FREE ||
+ READ_ONCE(token->state) == BNXT_HWRM_CANCELLED) {
+ hwrm_err(bp, ctx, "Resp cmpl intr err msg: 0x%x\n",
+ req_type);
+ goto exit;
+ }
+
+ /* The completion was not delivered, but the firmware
+ * may still have freed the ring. Check the response
+ * before giving up and log the state.
+ */
+ resp_seq_id = READ_ONCE(ctx->resp->seq_id);
+ len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
+ if (len && resp_seq_id == ctx->req->seq_id)
+ valid_byte = READ_ONCE(*((u8 *)ctx->resp + len - 1));
+
+ if (!valid_byte) {
+ hwrm_err(bp, ctx,
+ "Resp cmpl intr err msg: 0x%x len:%d seq:0x%x/0x%x\n",
+ req_type, len,
+ le16_to_cpu(resp_seq_id),
+ le16_to_cpu(ctx->req->seq_id));
+ goto exit;
+ }
+
+ /* Read the rest of the response after the valid byte */
+ dma_rmb();
+ if (!(ctx->flags & BNXT_HWRM_CTX_SILENT))
+ netdev_warn(bp->dev,
+ "Resp cmpl intr not delivered, msg: 0x%x completed anyway (len:%d valid:0x%x err:0x%x)\n",
+ req_type, len, valid_byte,
+ le16_to_cpu(ctx->resp->error_code));
+ } else {
+ len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
}
- len = le16_to_cpu(READ_ONCE(ctx->resp->resp_len));
valid = ((u8 *)ctx->resp) + len - 1;
} else {
__le16 seen_out_of_seq = ctx->req->seq_id; /* will never see */
--
2.53.1-Meta