Netdev List
 help / color / mirror / Atom feed
From: Joe Damato <joe@dama.to>
To: netdev-bot+sashiko@kernel.org
Cc: netdev@vger.kernel.org, michael.chan@broadcom.com,
	pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, prashant@broadcom.com, edumazet@google.com,
	horms@kernel.org, selvin.xavier@broadcom.com,
	kalesh-anakkur.purayil@broadcom.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives
Date: Mon, 23 Nov 2026 14:43:31 -0800	[thread overview]
Message-ID: <awTBkxA0DV4BiQym@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <179545865940.3135.4199576162321798829@kernel.org>

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.

  reply	other threads:[~2026-11-23 22:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 15:28 [PATCH net v6 0/5] bnxt_en: Make RING FREE more robust Joe Damato
2026-11-20 15:28 ` [PATCH net v6 1/5] bnxt_en: return the RING_FREE status to callers Joe Damato
2026-11-23 18:30   ` netdev-bot+sashiko
2026-11-23 21:18     ` Joe Damato
2026-11-20 15:28 ` [PATCH net v6 2/5] bnxt_en: check HWRM response if completion never arrives Joe Damato
2026-11-23 18:30   ` netdev-bot+sashiko
2026-11-23 22:43     ` Joe Damato [this message]
2026-11-20 15:28 ` [PATCH net v6 3/5] bnxt_en: stop DMA before releasing rings the firmware did not free Joe Damato
2026-11-23 18:31   ` netdev-bot+sashiko
2026-11-23 23:03     ` Joe Damato
2026-11-20 15:28 ` [PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA Joe Damato
2026-11-23 18:31   ` netdev-bot+sashiko
2026-11-23 23:10     ` Joe Damato
2026-11-20 15:28 ` [PATCH net v6 5/5] bnxt_en: stop the ULP around the reset task Joe Damato
2026-11-23 18:31   ` netdev-bot+sashiko
2026-11-23 23:16     ` Joe Damato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awTBkxA0DV4BiQym@devvm20253.cco0.facebook.com \
    --to=joe@dama.to \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=prashant@broadcom.com \
    --cc=selvin.xavier@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox