Merge tag 'net-6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / fw_reset.c
index 07c583996c2975b2ba1aaee7be21d13a6d060f55..1e46f9afa40e0fd2370a700ae3b73dc45d28660b 100644 (file)
@@ -9,7 +9,8 @@ enum {
        MLX5_FW_RESET_FLAGS_RESET_REQUESTED,
        MLX5_FW_RESET_FLAGS_NACK_RESET_REQUEST,
        MLX5_FW_RESET_FLAGS_PENDING_COMP,
-       MLX5_FW_RESET_FLAGS_DROP_NEW_REQUESTS
+       MLX5_FW_RESET_FLAGS_DROP_NEW_REQUESTS,
+       MLX5_FW_RESET_FLAGS_RELOAD_REQUIRED
 };
 
 struct mlx5_fw_reset {
@@ -152,7 +153,8 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev)
                mlx5_unload_one(dev);
                if (mlx5_health_wait_pci_up(dev))
                        mlx5_core_err(dev, "reset reload flow aborted, PCI reads still not working\n");
-               mlx5_load_one(dev, false);
+               else
+                       mlx5_load_one(dev, false);
                devlink_remote_reload_actions_performed(priv_to_devlink(dev), 0,
                                                        BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) |
                                                        BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE));
@@ -405,7 +407,7 @@ static void mlx5_sync_reset_now_event(struct work_struct *work)
        err = mlx5_pci_link_toggle(dev);
        if (err) {
                mlx5_core_warn(dev, "mlx5_pci_link_toggle failed, no reset done, err %d\n", err);
-               goto done;
+               set_bit(MLX5_FW_RESET_FLAGS_RELOAD_REQUIRED, &fw_reset->reset_flags);
        }
 
        mlx5_enter_error_state(dev, true);
@@ -481,6 +483,10 @@ int mlx5_fw_reset_wait_reset_done(struct mlx5_core_dev *dev)
                goto out;
        }
        err = fw_reset->ret;
+       if (test_and_clear_bit(MLX5_FW_RESET_FLAGS_RELOAD_REQUIRED, &fw_reset->reset_flags)) {
+               mlx5_unload_one_devl_locked(dev);
+               mlx5_load_one_devl_locked(dev, false);
+       }
 out:
        clear_bit(MLX5_FW_RESET_FLAGS_PENDING_COMP, &fw_reset->reset_flags);
        return err;