bnxt_en: Fix error handling path in bnxt_init_chip()
authorShravya KN <shravya.k-n@broadcom.com>
Mon, 28 Apr 2025 22:58:56 +0000 (15:58 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Apr 2025 12:03:21 +0000 (13:03 +0100)
WARN_ON() is triggered in __flush_work() if bnxt_init_chip() fails
because we call cancel_work_sync() on dim work that has not been
initialized.

WARNING: CPU: 37 PID: 5223 at kernel/workqueue.c:4201 __flush_work.isra.0+0x212/0x230

The driver relies on the BNXT_STATE_NAPI_DISABLED bit to check if dim
work has already been cancelled.  But in the bnxt_open() path,
BNXT_STATE_NAPI_DISABLED is not set and this causes the error
path to think that it needs to cancel the uninitalized dim work.
Fix it by setting BNXT_STATE_NAPI_DISABLED during initialization.
The bit will be cleared when we enable NAPI and initialize dim work.

Fixes: 40452969a506 ("bnxt_en: Fix DIM shutdown")
Suggested-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Shravya KN <shravya.k-n@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index 2c8e2c19d8548403b55be568f8b86e35de0ae91e..c4bccc683597c4743aa6453bfcbce0775258cb75 100644 (file)
@@ -11602,6 +11602,9 @@ static void bnxt_init_napi(struct bnxt *bp)
                poll_fn = bnxt_poll_p5;
        else if (BNXT_CHIP_TYPE_NITRO_A0(bp))
                cp_nr_rings--;
+
+       set_bit(BNXT_STATE_NAPI_DISABLED, &bp->state);
+
        for (i = 0; i < cp_nr_rings; i++) {
                bnapi = bp->bnapi[i];
                netif_napi_add_config_locked(bp->dev, &bnapi->napi, poll_fn,