mirror of https://lore.kernel.org/lkml/
 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,
	selvin.xavier@broadcom.com, kalesh-anakkur.purayil@broadcom.com,
	edumazet@google.com, horms@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v7 1/4] bnxt_en: return the RING_FREE status to callers
Date: Thu, 3 Dec 2026 18:14:33 -0800	[thread overview]
Message-ID: <axIiCaiuGvJWLY/Q@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <179632543122.3146.2991834310660738786@kernel.org>

On Thu, Dec 03, 2026 at 07:17:11PM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
> 
> Low priority / nit picks for your consideration:
> 
> - [Low] The commit message says that from hwrm_ring_free_send_msg() and
>   the TX/RX/AGG ring-free helpers…
> 
> Pre-existing issues:
> - [Low] bnxt_hwrm_tx_ring_free(), bnxt_hwrm_rx_ring_free() and
>   bnxt_hwrm_rx_agg_ring_free() set ring->fw_ring_id (and for RX also…
> 
> --
> 
> bnxt_en: return the RING_FREE status to callers
> 
> This commit changes hwrm_ring_free_send_msg() to return the errno from
> hwrm_req_init() or hwrm_req_send() instead of always returning -EIO. It
> also makes bnxt_hwrm_tx_ring_free(), bnxt_hwrm_rx_ring_free() and
> bnxt_hwrm_rx_agg_ring_free() return that value. No caller acts on it yet.
> 
> > Return the errno instead. -EBUSY means the request was sent but no
> > response arrived: the wait timed out or was abandoned.
> 
> [Severity: Low]
> Is this always true? __hwrm_send() starts with rc set to -EBUSY. It
> returns that value from the BNXT_NO_FW_ACCESS() early exit, before
> anything is written to BAR0:
> 
> drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c:__hwrm_send() {
>     ...
> 	int rc = -EBUSY;
>     ...
> 	if (BNXT_NO_FW_ACCESS(bp) &&
> 	    (req_type != HWRM_FUNC_RESET && req_type != HWRM_VER_GET)) {
> 		...
> 		goto exit;
> 	}
>     ...
> }
> 
> hwrm_ring_free_send_msg() runs its own BNXT_NO_FW_ACCESS() check first.
> The two checks are not atomic, though. BNXT_STATE_FW_FATAL_COND could be
> set, or pci_channel_offline() could become true, between them. In that
> case the helper returns -EBUSY for a RING_FREE that was never sent.
> 
> The opposite case also exists. After the doorbell has been rung, a device
> that is no longer enabled makes __hwrm_send() return -ENODEV, not -EBUSY:
> 
> 	writel(1, bp->bar0 + doorbell_offset);
>     ...
> 	if (!pci_is_enabled(bp->pdev)) {
> 		rc = -ENODEV;
> 		goto exit;
> 	}
> 
> The kernel-doc for hwrm_req_send() also gives EBUSY a wider meaning:
> 
>  *	EBUSY: The firmware is in a fatal state or the request timed out
> 
> Neither case seems to cause a functional problem in the series. A
> RING_FREE that was never sent leaves the ring owned by firmware, so later
> treating -EBUSY as stuck is still correct. -ENODEV only happens after
> pci_disable_device() has already cleared bus mastering.
> 
> Could the commit message be reworded so it matches what -EBUSY can
> actually mean here?

Yea, if I need to respin I can reword the commit message. Not sure it is worth
a v8 for this though.

> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > index 85ce4b2e297ec..c3777e85a6d98 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > @@ -7674,55 +7674,62 @@ static int hwrm_ring_free_send_msg(struct bnxt *bp,
> 
> [ ... ]
> 
> > -static void bnxt_hwrm_tx_ring_free(struct bnxt *bp,
> > -				   struct bnxt_tx_ring_info *txr,
> > -				   bool close_path)
> > +static int bnxt_hwrm_tx_ring_free(struct bnxt *bp,
> > +				  struct bnxt_tx_ring_info *txr,
> > +				  bool close_path)
> >  {
> >  	struct bnxt_ring_struct *ring = &txr->tx_ring_struct;
> >  	u32 cmpl_ring_id;
> > +	int rc;
> >  
> >  	if (ring->fw_ring_id == INVALID_HW_RING_ID)
> > -		return;
> > +		return 0;
> >  
> >  	cmpl_ring_id = close_path ? bnxt_cp_ring_for_tx(bp, txr) :
> >  		       INVALID_HW_RING_ID;
> > -	hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX,
> > -				cmpl_ring_id);
> > +	rc = hwrm_ring_free_send_msg(bp, ring, RING_FREE_REQ_RING_TYPE_TX,
> > +				     cmpl_ring_id);
> >  	ring->fw_ring_id = INVALID_HW_RING_ID;
> > +	return rc;
> >  }
> 
> [Severity: Low]
> This isn't a bug introduced by this patch, but the ring ID is cleared
> here even when hwrm_ring_free_send_msg() fails. The same happens in
> bnxt_hwrm_rx_ring_free() and bnxt_hwrm_rx_agg_ring_free(). Those two also
> clear bp->grp_info[grp_idx].rx_fw_ring_id and agg_fw_ring_id. Does this
> drop the driver's only handle to a ring the firmware may still own?
> 
> After an unanswered (-EBUSY) RING_FREE, the main risk is DMA into memory
> that has already been freed. Later patches in the series seem to cover
> that:
> 
>   "bnxt_en: stop DMA before releasing rings the firmware did not free"
>   makes __bnxt_close_nic() call bnxt_stop_dma() before bnxt_free_skbs()
>   and bnxt_free_mem().
> 
>   "bnxt_en: refuse to open a device with stopped DMA" then requires the
>   driver to be rebound.
> 
> That leaves a RING_FREE the firmware rejects, for example with -EAGAIN.
> It is not counted as stuck, and the ring ID is still thrown away. Is it
> known whether firmware can keep a rejected ring DMA-active?

This predates the series. An error reply means the firmware is alive
and handled the request, and Broadcom confirmed on v6 that only a
missing response should count as stuck. Every TX/RX/AGG failure in the
production logs was a missing response.

  reply	other threads:[~2026-12-04  2:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 18:56 [PATCH net v7 0/4] bnxt_en: Make RING FREE more robust Joe Damato
2026-12-02 18:56 ` [PATCH net v7 1/4] bnxt_en: return the RING_FREE status to callers Joe Damato
2026-12-03 19:17   ` netdev-bot+sashiko
2026-12-04  2:14     ` Joe Damato [this message]
2026-12-02 18:56 ` [PATCH net v7 2/4] bnxt_en: check HWRM response if completion never arrives Joe Damato
2026-12-02 18:56 ` [PATCH net v7 3/4] bnxt_en: stop DMA before releasing rings the firmware did not free Joe Damato
2026-12-03 19:17   ` netdev-bot+sashiko
2026-12-04  2:21     ` Joe Damato
2026-12-02 18:56 ` [PATCH net v7 4/4] bnxt_en: refuse to open a device with stopped DMA Joe Damato
2026-12-03 19:17   ` netdev-bot+sashiko
2026-12-04  2:26     ` Joe Damato
2026-12-04  2:34 ` [PATCH net v7 0/4] bnxt_en: Make RING FREE more robust 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=axIiCaiuGvJWLY/Q@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

all inboxes | Powered by JetHome®