Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Joe Damato
Fri, 20 Nov 2026 15:28
[PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
Author: Joe Damato
Date: Fri, 20 Nov 2026 15:28
Date: Fri, 20 Nov 2026 15:28
86 lines
14011 bytes
14011 bytes
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@dama.to>
---
.../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
Re: [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
Author: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 18:30
Date: Mon, 23 Nov 2026 18:30
124 lines
12856 bytes
12856 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In __hwrm_send()
(drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c), when the HWRM_DONE…
--
bnxt_en: check HWRM response if completion never arrives
Before this patch, an HWRM_RING_FREE sent over a completion ring failed
if __hwrm_send() timed out waiting for the completion. With this patch,
__hwrm_send() checks the response buffer first. If resp_len is set, the
sequence id matches and the valid byte is set, the command is treated as
completed and goes through the normal error_code handling.
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> index de02d1baa7514..53667c0c38aaf 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)
[ ... ]
> + /* 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;
[Severity: Medium]
Is a set valid byte in ctx->resp enough to show that the ring is safe to
free?
The commit message calls this case one where "only the notification was
lost". But the commit in the Fixes: tag, 74608fc98d28, sent the
RING_FREE response to the completion ring so that the completion entry
itself would act as the fence:
"The response will be the last entry in the ring and we can free the
ring after getting the response. This will guarantee no spurious DMA
to freed memory."
The response buffer and the HWRM_DONE completion entry are two separate
device writes. Once token->state is BNXT_HWRM_COMPLETE, the existing
success path reads resp_len without waiting for the valid byte. That
suggests the response buffer is written before the completion entry.
So a set valid byte may not mean that the HWRM_DONE entry has landed. It
also may not mean that the TX/RX completions queued ahead of it on the
same ring have landed.
This path runs when NAPI has stopped draining the completion ring, for
example after a TX watchdog timeout, a lost IRQ or a full completion
ring. In that situation the hardware may still have completion DMA
pending.
Before this patch, this case returned -EBUSY. Later in this series,
"bnxt_en: stop DMA before releasing rings the firmware did not free"
makes bnxt_hwrm_ring_free() count only -EBUSY results as stuck rings.
__bnxt_close_nic() then calls bnxt_stop_dma():
if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i],
close_path) == -EBUSY)
stuck++;
...
if (bnxt_shutdown_nic(bp, irq_re_init))
bnxt_stop_dma(bp);
This is the close path that reaches this code:
__bnxt_close_nic()
bnxt_shutdown_nic()
bnxt_hwrm_resource_free()
bnxt_hwrm_ring_free()
bnxt_hwrm_tx_ring_free() / bnxt_hwrm_rx_ring_free() (close_path)
hwrm_ring_free_send_msg()
__hwrm_send()
This patch returns 0 when the fence was never seen. Would those rings
then skip the stuck count and bnxt_stop_dma()? If so, bnxt_free_skbs()
and bnxt_free_mem() would release the ring memory while bus mastering is
still enabled.
Also, if the HWRM_DONE entry shows up late and NAPI processes it after
the token has been released, does hwrm_update_token() just log an
"Invalid hwrm seq id" error?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120152830.699712-1-joe%40dama.to
Re: [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
Author: Joe Damato
Date: Mon, 23 Nov 2026 22:43
Date: Mon, 23 Nov 2026 22:43
136 lines
17339 bytes
17339 bytes
On Mon, Nov 23, 2026 at 06:30:59PM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] In __hwrm_send()
> (drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c), when the HWRM_DONE…
>
> --
>
> bnxt_en: check HWRM response if completion never arrives
>
> Before this patch, an HWRM_RING_FREE sent over a completion ring failed
> if __hwrm_send() timed out waiting for the completion. With this patch,
> __hwrm_send() checks the response buffer first. If resp_len is set, the
> sequence id matches and the valid byte is set, the command is treated as
> completed and goes through the normal error_code handling.
>
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> > index de02d1baa7514..53667c0c38aaf 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)
>
> [ ... ]
>
> > + /* 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;
>
> [Severity: Medium]
> Is a set valid byte in ctx->resp enough to show that the ring is safe to
> free?
>
> The commit message calls this case one where "only the notification was
> lost". But the commit in the Fixes: tag, 74608fc98d28, sent the
> RING_FREE response to the completion ring so that the completion entry
> itself would act as the fence:
>
> "The response will be the last entry in the ring and we can free the
> ring after getting the response. This will guarantee no spurious DMA
> to freed memory."
>
> The response buffer and the HWRM_DONE completion entry are two separate
> device writes. Once token->state is BNXT_HWRM_COMPLETE, the existing
> success path reads resp_len without waiting for the valid byte. That
> suggests the response buffer is written before the completion entry.
>
> So a set valid byte may not mean that the HWRM_DONE entry has landed. It
> also may not mean that the TX/RX completions queued ahead of it on the
> same ring have landed.
Agreed. The valid byte shows that the firmware finished HWRM_RING_FREE for
the TX/RX/AGG ring. It does not show that HWRM_DONE was posted to the
completion ring.
Michael, can you confirm that the firmware has stopped DMA for the ring
(other than completions to the completion ring) by the time it writes
the RING_FREE response?
If the response is written before the ring is quiesced, then this patch is
wrong.
> This path runs when NAPI has stopped draining the completion ring, for
> example after a TX watchdog timeout, a lost IRQ or a full completion
> ring. In that situation the hardware may still have completion DMA
> pending.
>
> Before this patch, this case returned -EBUSY. Later in this series,
> "bnxt_en: stop DMA before releasing rings the firmware did not free"
> makes bnxt_hwrm_ring_free() count only -EBUSY results as stuck rings.
> __bnxt_close_nic() then calls bnxt_stop_dma():
>
> if (bnxt_hwrm_tx_ring_free(bp, &bp->tx_ring[i],
> close_path) == -EBUSY)
> stuck++;
> ...
> if (bnxt_shutdown_nic(bp, irq_re_init))
> bnxt_stop_dma(bp);
>
> This is the close path that reaches this code:
>
> __bnxt_close_nic()
> bnxt_shutdown_nic()
> bnxt_hwrm_resource_free()
> bnxt_hwrm_ring_free()
> bnxt_hwrm_tx_ring_free() / bnxt_hwrm_rx_ring_free() (close_path)
> hwrm_ring_free_send_msg()
> __hwrm_send()
>
> This patch returns 0 when the fence was never seen. Would those rings
> then skip the stuck count and bnxt_stop_dma()? If so, bnxt_free_skbs()
> and bnxt_free_mem() would release the ring memory while bus mastering is
> still enabled.
>
> Also, if the HWRM_DONE entry shows up late and NAPI processes it after
> the token has been released, does hwrm_update_token() just log an
> "Invalid hwrm seq id" error?
Yes. NAPI is still enabled at this point in the close path, so a late
HWRM_DONE only produces that error message.
Re: [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
Author: Joe Damato
Date: Mon, 30 Nov 2026 14:46
Date: Mon, 30 Nov 2026 14:46
115 lines
17259 bytes
17259 bytes
On Thu, Nov 26, 2026 at 12:18:14PM +0100, Paolo Abeni wrote:
> On 11/23/26 23:43, Joe Damato wrote:
> > On Mon, Nov 23, 2026 at 06:30:59PM +0000, netdev-bot+sashiko@kernel.org wrote:
> > > Thank you for your contribution! Sashiko AI review found 1 potential
> > > > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
> > > > index de02d1baa7514..53667c0c38aaf 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)
> > >
> > > [ ... ]
> > >
> > > > + /* 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;
> > >
> > > [Severity: Medium]
> > > Is a set valid byte in ctx->resp enough to show that the ring is safe to
> > > free?
> > >
> > > The commit message calls this case one where "only the notification was
> > > lost". But the commit in the Fixes: tag, 74608fc98d28, sent the
> > > RING_FREE response to the completion ring so that the completion entry
> > > itself would act as the fence:
> > >
> > > "The response will be the last entry in the ring and we can free the
> > > ring after getting the response. This will guarantee no spurious DMA
> > > to freed memory."
> > >
> > > The response buffer and the HWRM_DONE completion entry are two separate
> > > device writes. Once token->state is BNXT_HWRM_COMPLETE, the existing
> > > success path reads resp_len without waiting for the valid byte. That
> > > suggests the response buffer is written before the completion entry.
> > >
> > > So a set valid byte may not mean that the HWRM_DONE entry has landed. It
> > > also may not mean that the TX/RX completions queued ahead of it on the
> > > same ring have landed.
> >
> > Agreed. The valid byte shows that the firmware finished HWRM_RING_FREE for
> > the TX/RX/AGG ring. It does not show that HWRM_DONE was posted to the
> > completion ring.
> >
> > Michael, can you confirm that the firmware has stopped DMA for the ring
> > (other than completions to the completion ring) by the time it writes
> > the RING_FREE response?
> >
> > If the response is written before the ring is quiesced, then this patch is
> > wrong.
> @Pavan, @Michael: there are pending question for you here and elsewhere
> in this series, please have a look.
>
> If nobody answer in a few days we will have to toss the series.
Just to clarify: did you mean this version of this code or this series in
general? I just want to make sure because I don't want to resubmit if you
meant that I should not resubmit.
> @Joe: could the issues be caused by a broken firmware? in such a case
> nothing would stop it from doing DMA at the bad time, right?
Yea, I suspect there is a firmware issue of some kind (IIRC Broadcom mentioned
there might be an issue with the RING FREE FW command with large ring sizes in
the last version).
The point of the series though was to try to harden the path in the driver to
avoid freeing memory that might still be in use by the firmware.
So, while I agree in principle that nothing can stop FW from doing a bad DMA I
think it's probably a good idea to make the driver check return values and
avoid freeing memory if it thinks FW is stuck.
I think the trouble with this series in particular is that Sashiko is finding
a lot of random stuff that is also potentially buggy, so I've been trying to
summarize the addressable points in a reply to the cover letter to help focus
Broadcom's feedback.
FWIW, the first several revisions of this series were RFCs and I just
continued with the version increment when it got "promoted" from RFC to a
"real" submission.
I don't plan on submitting this endlessly; if I can't get something workable
that Broadcom agrees with in the next revision or two then I will drop this
(unless you meant above that I should stop submitting this).
I've been trying to have conversations in the thread for each submission to
limit the number of revisions maintainers need to read, but unfortunately
Sashiko is smarter than me and finds stuff I didn't know was there.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads