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 4/5] bnxt_en: refuse to open a device with stopped DMA
Date: Mon, 23 Nov 2026 15:10:06 -0800	[thread overview]
Message-ID: <awTHzto2KqruYx78@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <179545866233.3135.17505837220604349272@kernel.org>

On Mon, Nov 23, 2026 at 06:31:02PM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 3 · 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] BNXT_STATE_DMA_STOPPED is set once in bnxt_stop_dma()
>   (bnxt.c:7850) and never cleared.
> - [Medium] The commit message says DMA_STOPPED is added to
>   BNXT_NO_FW_ACCESS() "so HWRM commands sent after DMA is stopped fail…
> - [Medium] BNXT_STATE_DMA_STOPPED records a specific hazard: firmware did
>   not free its rings, so the device may still hold DMA addresses of…
> 
> --
> 
> bnxt_en: refuse to open a device with stopped DMA
> 
> This patch adds BNXT_STATE_DMA_STOPPED. The bit is set in bnxt_stop_dma(),
> and bnxt_open(), bnxt_open_nic() and bnxt_half_open_nic() refuse to open
> the device while it is set. The bit is also added to BNXT_NO_FW_ACCESS()
> so that HWRM commands fail fast once DMA has been stopped.
> 
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > index 600a8c866f3c3..9daf053293a42 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > @@ -7847,9 +7847,20 @@ static void bnxt_stop_dma(struct bnxt *bp)
> >  
> >  	netdev_err(bp->dev,
> >  		   "Disabling DMA before releasing ring memory, the driver must be rebound to recover\n");
> > +	set_bit(BNXT_STATE_DMA_STOPPED, &bp->state);
> >  	pci_clear_master(bp->pdev);
> >  }
> 
> [Severity: Medium]
> Is BNXT_STATE_DMA_STOPPED ever cleared? This set_bit() and the test_bit()
> calls are the only places that touch it. Once set, it stays set even
> after the PCI function or slot has been reset and bus mastering has been
> turned back on.
> 
> The comment at the top of bnxt_stop_dma() says "A firmware reset resets
> the device". Even so, two recovery paths that reset the function now fail
> partway because the bit is stale.
> 
> In bnxt_resume():
> 
>     pci_set_master(bp->pdev);
>     ...
>     if (bnxt_hwrm_ver_get(bp)) {
>     ...
>     rc = bnxt_hwrm_func_reset(bp);
>     ...
>     rc = bnxt_hwrm_func_qcaps(bp);
>     if (rc)
>         goto resume_exit;
> 
> __hwrm_send() exempts VER_GET and FUNC_RESET, so both reach the firmware
> and the function is reset. BNXT_NO_FW_ACCESS() then skips
> bnxt_hwrm_func_qcaps(), which returns -EBUSY. Resume fails with bus
> mastering on, HWRM_FUNC_DRV_RGTR is never sent, and the netdev stays
> detached.
> 
> One way to reach this is through the suspend path, when
> bnxt_shutdown_nic() fails:
> 
> bnxt_suspend()->bnxt_close()->__bnxt_close_nic()->bnxt_stop_dma()
> 
> AER recovery has the same problem. bnxt_io_slot_reset() calls
> pci_set_master(), bnxt_try_recover_fw() and bnxt_hwrm_func_reset(), then
> returns PCI_ERS_RESULT_RECOVERED. bnxt_io_resume() then fails in one of
> two places:
> 
>     err = bnxt_hwrm_func_qcaps(bp);
>     if (!err) {
>         if (netif_running(netdev)) {
>             err = bnxt_open(netdev);
> 
> It fails either in bnxt_hwrm_func_qcaps() or in
> bnxt_open()->bnxt_check_dma_stopped(), so the device never reattaches.
> 
> Before this patch, with the earlier "stop DMA before releasing rings"
> change applied, both paths re-initialized the device. Also,
> bnxt_check_dma_stopped() would then print "DMA was disabled ..." even
> though bus mastering has been turned back on.
> 
> Should the bit be cleared once the function has actually been reset?

No, this is intentional. Recovery is rebind only. The device gets into
this state because the firmware stopped answering. I don't want resume
or AER recovery to turn the device back on without knowing the stale
ring state is gone.

Resume and AER only fail if a RING_FREE has already failed before them.
I haven't seen that. If it happens, the device stays down and has to be
rebound.

> [ ... ]
> 
> > @@ -13519,6 +13535,10 @@ static int bnxt_open(struct net_device *dev)
> >  	struct bnxt *bp = netdev_priv(dev);
> >  	int rc;
> >  
> > +	rc = bnxt_check_dma_stopped(bp);
> > +	if (rc)
> > +		return rc;
> > +
> 
> [Severity: Medium]
> The new bit is only checked in the three open functions. Can
> bnxt_resume() turn DMA back on while the device still holds stale ring
> addresses?
> 
> The bit is set because the firmware did not free its rings. Clearing bus
> mastering is the only thing that stops the device from writing into ring,
> RX buffer and stats memory after __bnxt_close_nic() frees it.
> bnxt_suspend() runs bnxt_close(), which may set the bit. bnxt_resume()
> then does this without looking at BNXT_STATE_DMA_STOPPED:
> 
>     pci_set_master(bp->pdev);
>     if (BNXT_VF(bp)) {
>         for (i = 0; i < BNXT_RESUME_MAX_RETRY; i++) {
>             rc = bnxt_hwrm_poll(bp);
>     ...
>     if (bnxt_hwrm_ver_get(bp)) {
>         rc = -ENODEV;
>         goto resume_exit;
>     }
>     rc = bnxt_hwrm_func_reset(bp);
>     if (rc) {
>         rc = -EBUSY;
>         goto resume_exit;
>     }
> 
> Suppose the function's firmware ring state survives suspend, for example
> with s2idle or D3hot with No_Soft_Reset. The device can then do
> bus-master DMA from pci_set_master() until FUNC_RESET completes. For a
> VF, that window also covers the bnxt_hwrm_poll() retries and their
> sleeps. Whether this happens depends on platform and firmware behavior.
> 
> VER_GET or FUNC_RESET may well fail here, since the firmware has already
> stopped answering RING_FREE. If they do, resume jumps to resume_exit with
> bus mastering still on and the stale rings still live. Because the flag
> is stale (see the comment above), resume then gives up anyway.
> 
> The rebind recovery that the commit message prescribes uses the same
> order. bnxt_init_board() calls pci_set_master() before
> bnxt_fw_init_one_p1() sends FUNC_RESET. In the kdump case,
> bnxt_init_one() calls bnxt_kdump_reset() (pcie_flr()) before probing, to
> avoid this kind of stale DMA.
> 
> Should bnxt_resume() check BNXT_STATE_DMA_STOPPED, or reset the function
> with something like an FLR, before it turns bus mastering back on?

This is in the "leaving out" section of the cover letter.

> [ ... ]
> 
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> > index 41d05efd6307a..50c024dd3c6c4 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> > @@ -2474,9 +2474,11 @@ struct bnxt {
> >  #define BNXT_STATE_FW_NON_FATAL_COND	13
> >  #define BNXT_STATE_FW_ACTIVATE_RESET	14
> >  #define BNXT_STATE_HALF_OPEN		15	/* For offline ethtool tests */
> > +#define BNXT_STATE_DMA_STOPPED		16
> >  
> >  #define BNXT_NO_FW_ACCESS(bp)					\
> >  	(test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) ||	\
> > +	 test_bit(BNXT_STATE_DMA_STOPPED, &(bp)->state) ||	\
> >  	 pci_channel_offline((bp)->pdev))
> 
> [Severity: Medium]
> The commit message says:
> 
>     Also add the bit to BNXT_NO_FW_ACCESS() so HWRM commands sent after
>     DMA is stopped fail right away instead of waiting for the timeout.
> 
> Does that hold for every command? __hwrm_send() still lets two request
> types through when BNXT_NO_FW_ACCESS() is true:
> 
>     if (BNXT_NO_FW_ACCESS(bp) &&
>         (req_type != HWRM_FUNC_RESET && req_type != HWRM_VER_GET)) {
> 
> The device writes HWRM responses into ctx->resp by DMA. With bus
> mastering cleared, HWRM_VER_GET and HWRM_FUNC_RESET cannot complete, so
> they still wait for the full timeout. The exemption list was written for
> fatal-error and channel-offline recovery, where bus mastering is or will
> be enabled again.
> 
> Devlink reload can reach this. The first reload fails in
> bnxt_dl_reload_down(): bnxt_hwrm_func_drv_unrgtr() clears
> BNXT_STATE_DRV_REGISTERED and then gets -EBUSY. On a second reload,
> unrgtr returns 0 and devlink calls bnxt_dl_reload_up():
> 
> bnxt_dl_reload_up()
>   bnxt_fw_init_one()
>     bnxt_fw_init_one_p1()
>       bnxt_hwrm_ver_get()       <- waits for the timeout, then msleep(100)
>       bnxt_try_recover_fw()
>         bnxt_hwrm_poll()        <- another VER_GET
>       bnxt_hwrm_ver_get()
>       bnxt_hwrm_func_reset()
> 
> Nothing on this path checks BNXT_STATE_DMA_STOPPED. Only bnxt_open_nic(),
> which runs later, does. Each exempt command sent along the way waits for
> the full HWRM timeout.
> 
> Should __hwrm_send() also refuse these two commands while
> BNXT_STATE_DMA_STOPPED is set, or should the commit message be reworded?

Yea the commit message could be reworded. I don't know if it's worth a respin
just for that. Like I said in response to an earlier patch (I think patch 1?)
if I need to send a v7, I'll include a commit message update.

  reply	other threads:[~2026-11-23 23:10 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
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 [this message]
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=awTHzto2KqruYx78@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