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 4/4] bnxt_en: refuse to open a device with stopped DMA
Date: Thu, 3 Dec 2026 18:26:49 -0800 [thread overview]
Message-ID: <axIk6ZWFl0+LLsfc@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <179632543413.3146.13728964654428418135@kernel.org>
On Thu, Dec 03, 2026 at 07:17:14PM +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: 1 · Medium: 2 · 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).
>
> - [High] bnxt_stop_dma() (bnxt.c:7845) returns without clearing Bus
> Master Enable and without setting BNXT_STATE_DMA_STOPPED whenever…
> - [Medium] This series makes 'rebind the driver' the only recovery after
> bnxt_stop_dma() has run.
> - [Medium] bnxt_en: pci_set_master() called when BNXT_STATE_DMA_STOPPED
> is set
>
> --
>
> bnxt_en: refuse to open a device with stopped DMA
>
> This commit adds BNXT_STATE_DMA_STOPPED, sets it in bnxt_stop_dma(), and
> refuses to open the device while the bit is set. It also adds the bit to
> BNXT_NO_FW_ACCESS(), so most HWRM commands fail right away after DMA has
> been stopped. Rebinding the driver is the only way to recover.
>
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > index c1c58f5c930a0..1f40914610bb8 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> > @@ -7848,9 +7848,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]
> bnxt_stop_dma() clears bus mastering so the device cannot DMA into the
> ring and RX buffer memory that __bnxt_close_nic() frees next. The new
> bit is supposed to keep it that way until the driver is rebound.
> bnxt_resume(), bnxt_fw_reset_task() and bnxt_io_slot_reset() still call
> pci_set_master() without looking at BNXT_STATE_DMA_STOPPED.
>
> The notes defer those callers to net-next. However, with
> BNXT_STATE_DMA_STOPPED in BNXT_NO_FW_ACCESS(), these paths now turn bus
> mastering back on and then fail part way through. The device is left
> enabled as a bus master with nobody driving it.
>
> Suspend looks like the easiest way to get there. bnxt_suspend() calls
> bnxt_close(), which returns 0 even when bnxt_shutdown_nic() hits the
> HWRM_RING_FREE timeout and calls bnxt_stop_dma(). On resume:
>
> bnxt_resume()
> pci_set_master(bp->pdev)
> bnxt_hwrm_ver_get()
> bnxt_hwrm_func_reset()
> bnxt_hwrm_func_qcaps() <- -EBUSY from BNXT_NO_FW_ACCESS()
> goto resume_exit <- bus mastering left on
>
> The firmware ring state may survive suspend (s2idle, or D3hot without a
> soft reset). In that case, can the device write into the freed buffers
> between pci_set_master() and HWRM_FUNC_RESET? That includes the VF
> bnxt_hwrm_poll() retry loop. If HWRM_VER_GET or HWRM_FUNC_RESET fails
> on an unresponsive firmware, that window never closes.
>
> bnxt_fw_reset_task() is similar: BNXT_FW_RESET_STATE_ENABLE_DEV calls
> pci_set_master(), then bnxt_open() refuses with -ENODEV. In
> bnxt_io_slot_reset(), pci_set_master() runs and bnxt_io_resume() then
> fails in bnxt_hwrm_func_qcaps().
>
> Could these paths check BNXT_STATE_DMA_STOPPED before pci_set_master()
> and bail out? Or could they clear bus mastering again on their error
> exits? This patch is what makes them fail with bus mastering on, so it
> seems worth handling here rather than in net-next.
idk. I don't think this patch makes it worse.
HWRM_VER_GET and HWRM_FUNC_RESET are exempt from BNXT_NO_FW_ACCESS(), so in
bnxt_resume() the function is reset before bnxt_hwrm_func_qcaps() fails.
After that the firmware no longer holds the old rings. bnxt_fw_reset_task()
and bnxt_io_slot_reset() only get there after a firmware or slot reset.
The window between pci_set_master() and HWRM_FUNC_RESET, and the error
exits after VER_GET or FUNC_RESET fail, exist without this patch.
> [Severity: High]
>
> bnxt_stop_dma() returns early before it reaches this point:
>
> /* A firmware reset resets the device, and the fatal error path
> * already disables it.
> */
> if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) ||
> test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state))
> return;
>
> When IN_FW_RESET is set, neither pci_clear_master() nor the new set_bit()
> runs. Is a reset guaranteed to happen before the device can reach the
> freed ring memory?
>
> One path where it doesn't seem to: bnxt_fw_reset() with active VFs sets
> IN_FW_RESET and moves to BNXT_FW_RESET_STATE_POLL_VF, and the device
> stays open. If the user then closes the device:
>
> bnxt_close()
> bnxt_close_nic()
> set_bit(BNXT_STATE_ABORT_ERR, &bp->state);
> __bnxt_close_nic()
> HWRM_RING_FREE gets no answer (-EBUSY)
> bnxt_stop_dma() <- returns early, bus mastering stays on
> bnxt_free_mem()
>
> Then the POLL_VF case in bnxt_fw_reset_task() does:
>
> netdev_lock(bp->dev);
> if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) {
> netdev_unlock(bp->dev);
> goto fw_reset_abort;
> }
>
> bnxt_fw_reset_abort() clears IN_FW_RESET and closes the device. It never
> issues a reset or calls pci_disable_device(). The VF timeout branch in
> POLL_VF also clears IN_FW_RESET without a reset.
>
> Wouldn't the firmware then still own rings that point at freed memory,
> with bus mastering on? BNXT_STATE_DMA_STOPPED would also never get set,
> so the new open-time check would not fire.
>
> The normal non-fatal reset path seems to have a smaller window too.
> bnxt_fw_reset_close() frees ring memory before bus mastering is cleared:
>
> __bnxt_close_nic(bp, true, false);
> bnxt_vf_reps_free(bp);
> bnxt_clear_int_mode(bp);
> bnxt_hwrm_func_drv_unrgtr(bp);
> if (pci_is_enabled(bp->pdev))
> pci_disable_device(bp->pdev);
>
> bnxt_hwrm_func_drv_unrgtr() can wait for a full HWRM timeout if the
> firmware does not respond. Later, a failed bnxt_reset_all() only logs
> "Unable to reset FW rc=%d". BNXT_FW_RESET_STATE_ENABLE_DEV then calls
> pci_set_master() anyway.
>
> Could the IN_FW_RESET skip depend on a reset or pci_disable_device()
> actually happening? Alternatively, could bus mastering be cleared on
> these paths as well?
Same as my reply to patch 3: this is the early return listed in the
notes. These paths need a firmware reset to overlap a RING_FREE timeout
during close, and they behave the same as before the series. The
ordering in bnxt_fw_reset_close() is not changed by this series.
> > 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_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]
>
> Rebinding is now the only recovery. What clears the firmware's ring
> state before bus mastering is turned back on at the next probe?
>
> With DMA_STOPPED in BNXT_NO_FW_ACCESS(), bnxt_remove_one() now skips its
> bnxt_hwrm_func_drv_unrgtr() call right away. The return value is ignored
> and no FLR follows. bnxt_shutdown() handles the same failure with an FLR:
>
> if (bnxt_hwrm_func_drv_unrgtr(bp)) {
> pcie_flr(pdev);
> goto shutdown_exit;
> }
>
> On rebind, the order is:
>
> bnxt_init_one()
> bnxt_init_board()
> pci_set_master(pdev);
> ...
> bnxt_fw_init_one_p1()
> bnxt_hwrm_ver_get()
> (on failure: msleep(100), bnxt_try_recover_fw(), ver_get again)
> bnxt_hwrm_func_reset()
>
> bnxt_hwrm_ring_free() says:
>
> /* -EBUSY means the firmware never answered, so it may still own
> * the ring.
> */
>
> Between pci_set_master() and HWRM_FUNC_RESET, could DMA engines that
> still hold the previous binding's rings read descriptors from, or write
> packets, completions or stats into, memory the previous instance freed?
>
> bnxt_kdump_reset() already clears bus mastering and runs pcie_flr()
> before probe to clear pending DMA from a previous instance, but only in
> the kdump case.
>
> Would either of these close the window: a pcie_flr() in bnxt_remove_one()
> when BNXT_STATE_DMA_STOPPED is set, or a reset before pci_set_master()
> at probe?
See my reply to patch 3. bnxt_remove_one() now skips
bnxt_hwrm_func_drv_unrgtr() right away, but the outcome is the same as
before this patch: with DMA off its response can't arrive, so it used to
fail after the timeout instead.
next prev parent reply other threads:[~2026-12-04 2:26 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
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 [this message]
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=axIk6ZWFl0+LLsfc@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