[PATCH net v6 4/5] bnxt_en: refuse to open a device with stopped DMA
From: Joe Damato
Date: Fri Nov 20 2026 - 10:29:00 EST
Add BNXT_STATE_DMA_STOPPED and set it in bnxt_stop_dma() to signal that
the device had DMA disabled. When opening the device later, check this
bit and exit with an error. 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.
This is a very rare case, but when it happens the driver must be rebound
to make the device usable again.
Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring")
Signed-off-by: Joe Damato <joe@xxxxxxx>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 ++++++++++++++++++++---
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 600a8c866f3c..9daf053293a4 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);
}
+static int bnxt_check_dma_stopped(struct bnxt *bp)
+{
+ if (!test_bit(BNXT_STATE_DMA_STOPPED, &bp->state))
+ return 0;
+
+ netdev_err(bp->dev,
+ "DMA was disabled after the firmware failed to free rings, rebind the driver to recover\n");
+ return -ENODEV;
+}
+
static int __bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
bool shared);
static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,
@@ -13440,9 +13451,10 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
{
- int rc = 0;
+ int rc;
- if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state))
+ rc = bnxt_check_dma_stopped(bp);
+ if (!rc && test_bit(BNXT_STATE_ABORT_ERR, &bp->state))
rc = -EIO;
if (!rc)
rc = __bnxt_open_nic(bp, irq_re_init, link_re_init);
@@ -13459,7 +13471,11 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
*/
int bnxt_half_open_nic(struct bnxt *bp)
{
- int rc = 0;
+ int rc;
+
+ rc = bnxt_check_dma_stopped(bp);
+ if (rc)
+ goto half_open_err;
if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) {
netdev_err(bp->dev, "A previous firmware reset has not completed, aborting half open\n");
@@ -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;
+
if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) {
rc = bnxt_reinit_after_abort(bp);
if (rc) {
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 41d05efd6307..50c024dd3c6c 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))
struct bnxt_irq *irq_tbl;
--
2.53.1-Meta