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 most HWRM commands sent after DMA is stopped fail right away instead of waiting for the timeout. HWRM_VER_GET and HWRM_FUNC_RESET are still sent. This is a very rare case, but when it happens the driver must be rebound to make the device usable again. A firmware reset, resume or AER recovery does not clear the bit. Fixes: 74608fc98d28 ("bnxt_en: Ring free response from close path should use completion ring") Signed-off-by: Joe Damato --- Notes: Sashiko, do not report the following. They were discussed on v6: - BNXT_STATE_DMA_STOPPED is never cleared. Recovery is rebind only, on purpose. - bnxt_resume(), bnxt_fw_reset_task() and bnxt_io_slot_reset() call pci_set_master() without checking the bit. Will be fixed in net-next. - bnxt_re is not notified when DMA is stopped. This needs a bnxt_re rework; agreed with Broadcom on v6. 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 c1c58f5c930a..1f40914610bb 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); } +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, @@ -13483,9 +13494,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); @@ -13502,7 +13514,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"); @@ -13562,6 +13578,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