From b5a3e2be5f5d41b6d999ad9346f1247e2b7ad247 Mon Sep 17 00:00:00 2001 From: Jonathan Toppins Date: Wed, 2 Oct 2019 18:23:25 -0400 Subject: [PATCH 70/96] [netdrv] bnxt_en: Add BNXT_STATE_IN_FW_RESET state Message-id: <7698266f568917253716b6f64ad8c2c5ae29a62a.1570027456.git.jtoppins@redhat.com> Patchwork-id: 276488 O-Subject: [RHEL-8.2 PATCH 63/78] bnxt_en: Add BNXT_STATE_IN_FW_RESET state. Bugzilla: 1724766 RH-Acked-by: John Linville RH-Acked-by: Jarod Wilson The new flag will be set in subsequent patches when firmware is going through reset. If bnxt_close() is called while the new flag is set, the FW reset sequence will have to be aborted because the NIC is prematurely closed before FW reset has completed. We also reject SRIOV configurations while FW reset is in progress. v2: No longer drop rtnl_lock() in close and wait for FW reset to complete. Signed-off-by: Michael Chan Signed-off-by: David S. Miller (cherry picked from commit 3bc7d4a352efe5b596883ef16b769055320db1f6) Bugzilla: 1724766 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=23809532 Tested: build, boot, basic ping Signed-off-by: Jonathan Toppins Signed-off-by: Bruno Meneguele --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 ++++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 5 +++++ 3 files changed, 26 insertions(+) Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.c =================================================================== --- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.c 2020-02-06 16:23:19.590477537 +0100 +++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.c 2020-02-06 16:23:19.749476077 +0100 @@ -8721,6 +8721,10 @@ if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_HOT_FW_RESET_DONE) fw_reset = true; + if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) { + netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n"); + return -ENODEV; + } if (resc_reinit || fw_reset) { if (fw_reset) { rc = bnxt_fw_init_one(bp); @@ -9231,6 +9235,10 @@ bnxt_debug_dev_exit(bp); bnxt_disable_napi(bp); del_timer_sync(&bp->timer); + if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && + pci_is_enabled(bp->pdev)) + pci_disable_device(bp->pdev); + bnxt_free_skbs(bp); /* Save ring stats before shutdown */ @@ -9247,6 +9255,18 @@ { int rc = 0; + if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { + /* If we get here, it means firmware reset is in progress + * while we are trying to close. We can safely proceed with + * the close because we are holding rtnl_lock(). Some firmware + * messages may fail as we proceed to close. We set the + * ABORT_ERR flag here so that the FW reset thread will later + * abort when it gets the rtnl_lock() and sees the flag. + */ + netdev_warn(bp->dev, "FW reset in progress during close, FW reset will be aborted\n"); + set_bit(BNXT_STATE_ABORT_ERR, &bp->state); + } + #ifdef CONFIG_BNXT_SRIOV if (bp->sriov_cfg) { rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.h =================================================================== --- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.h 2020-02-06 16:23:19.591477528 +0100 +++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.h 2020-02-06 16:23:19.750476068 +0100 @@ -1605,6 +1605,7 @@ #define BNXT_STATE_IN_SP_TASK 1 #define BNXT_STATE_READ_STATS 2 #define BNXT_STATE_FW_RESET_DET 3 +#define BNXT_STATE_IN_FW_RESET 4 #define BNXT_STATE_ABORT_ERR 5 struct bnxt_irq *irq_tbl; Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c =================================================================== --- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 2020-02-06 16:23:19.013482833 +0100 +++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 2020-02-06 16:23:19.750476068 +0100 @@ -828,6 +828,11 @@ rtnl_unlock(); return 0; } + if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { + netdev_warn(dev, "Reject SRIOV config request when FW reset is in progress\n"); + rtnl_unlock(); + return 0; + } bp->sriov_cfg = true; rtnl_unlock();