Skip to content

Commit 3bc7d4a

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add BNXT_STATE_IN_FW_RESET state.
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7e91402 commit 3bc7d4a

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8716,6 +8716,10 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
87168716
if (flags & FUNC_DRV_IF_CHANGE_RESP_FLAGS_HOT_FW_RESET_DONE)
87178717
fw_reset = true;
87188718

8719+
if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) {
8720+
netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n");
8721+
return -ENODEV;
8722+
}
87198723
if (resc_reinit || fw_reset) {
87208724
if (fw_reset) {
87218725
rc = bnxt_fw_init_one(bp);
@@ -9226,6 +9230,10 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,
92269230
bnxt_debug_dev_exit(bp);
92279231
bnxt_disable_napi(bp);
92289232
del_timer_sync(&bp->timer);
9233+
if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) &&
9234+
pci_is_enabled(bp->pdev))
9235+
pci_disable_device(bp->pdev);
9236+
92299237
bnxt_free_skbs(bp);
92309238

92319239
/* Save ring stats before shutdown */
@@ -9242,6 +9250,18 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
92429250
{
92439251
int rc = 0;
92449252

9253+
if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
9254+
/* If we get here, it means firmware reset is in progress
9255+
* while we are trying to close. We can safely proceed with
9256+
* the close because we are holding rtnl_lock(). Some firmware
9257+
* messages may fail as we proceed to close. We set the
9258+
* ABORT_ERR flag here so that the FW reset thread will later
9259+
* abort when it gets the rtnl_lock() and sees the flag.
9260+
*/
9261+
netdev_warn(bp->dev, "FW reset in progress during close, FW reset will be aborted\n");
9262+
set_bit(BNXT_STATE_ABORT_ERR, &bp->state);
9263+
}
9264+
92459265
#ifdef CONFIG_BNXT_SRIOV
92469266
if (bp->sriov_cfg) {
92479267
rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait,

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,7 @@ struct bnxt {
16051605
#define BNXT_STATE_IN_SP_TASK 1
16061606
#define BNXT_STATE_READ_STATS 2
16071607
#define BNXT_STATE_FW_RESET_DET 3
1608+
#define BNXT_STATE_IN_FW_RESET 4
16081609
#define BNXT_STATE_ABORT_ERR 5
16091610

16101611
struct bnxt_irq *irq_tbl;

drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,11 @@ int bnxt_sriov_configure(struct pci_dev *pdev, int num_vfs)
828828
rtnl_unlock();
829829
return 0;
830830
}
831+
if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
832+
netdev_warn(dev, "Reject SRIOV config request when FW reset is in progress\n");
833+
rtnl_unlock();
834+
return 0;
835+
}
831836
bp->sriov_cfg = true;
832837
rtnl_unlock();
833838

0 commit comments

Comments
 (0)