Skip to content

Commit bdf2747

Browse files
DmytroLinkinSaeed Mahameed
authored andcommitted
net/mlx5e: Don't attach netdev profile while handling internal error
As part of switchdev mode disablement, driver changes port netdevice profile from uplink to nic. If this process is triggered by health recovery flow (PCI reset, for ex.) profile attach would fail because all fw commands aborted when internal error flag is set. As a result, nic netdevice profile is not attached and driver fails to rollback to uplink profile, which leave driver in broken state and cause crash later. To handle broken state do netdevice profile initialization only instead of full attachment and release mdev resources on driver suspend as expected. Actual netdevice attachment is done during driver load. Fixes: c4d7eb5 ("net/mxl5e: Add change profile method") Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 5d862ec commit bdf2747

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

  • drivers/net/ethernet/mellanox/mlx5/core

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5833,8 +5833,8 @@ void mlx5e_detach_netdev(struct mlx5e_priv *priv)
58335833
}
58345834

58355835
static int
5836-
mlx5e_netdev_attach_profile(struct net_device *netdev, struct mlx5_core_dev *mdev,
5837-
const struct mlx5e_profile *new_profile, void *new_ppriv)
5836+
mlx5e_netdev_init_profile(struct net_device *netdev, struct mlx5_core_dev *mdev,
5837+
const struct mlx5e_profile *new_profile, void *new_ppriv)
58385838
{
58395839
struct mlx5e_priv *priv = netdev_priv(netdev);
58405840
int err;
@@ -5850,14 +5850,32 @@ mlx5e_netdev_attach_profile(struct net_device *netdev, struct mlx5_core_dev *mde
58505850
err = new_profile->init(priv->mdev, priv->netdev);
58515851
if (err)
58525852
goto priv_cleanup;
5853+
5854+
return 0;
5855+
5856+
priv_cleanup:
5857+
mlx5e_priv_cleanup(priv);
5858+
return err;
5859+
}
5860+
5861+
static int
5862+
mlx5e_netdev_attach_profile(struct net_device *netdev, struct mlx5_core_dev *mdev,
5863+
const struct mlx5e_profile *new_profile, void *new_ppriv)
5864+
{
5865+
struct mlx5e_priv *priv = netdev_priv(netdev);
5866+
int err;
5867+
5868+
err = mlx5e_netdev_init_profile(netdev, mdev, new_profile, new_ppriv);
5869+
if (err)
5870+
return err;
5871+
58535872
err = mlx5e_attach_netdev(priv);
58545873
if (err)
58555874
goto profile_cleanup;
58565875
return err;
58575876

58585877
profile_cleanup:
58595878
new_profile->cleanup(priv);
5860-
priv_cleanup:
58615879
mlx5e_priv_cleanup(priv);
58625880
return err;
58635881
}
@@ -5876,6 +5894,12 @@ int mlx5e_netdev_change_profile(struct mlx5e_priv *priv,
58765894
priv->profile->cleanup(priv);
58775895
mlx5e_priv_cleanup(priv);
58785896

5897+
if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
5898+
mlx5e_netdev_init_profile(netdev, mdev, new_profile, new_ppriv);
5899+
set_bit(MLX5E_STATE_DESTROYING, &priv->state);
5900+
return -EIO;
5901+
}
5902+
58795903
err = mlx5e_netdev_attach_profile(netdev, mdev, new_profile, new_ppriv);
58805904
if (err) { /* roll back to original profile */
58815905
netdev_warn(netdev, "%s: new profile init failed, %d\n", __func__, err);
@@ -5937,8 +5961,11 @@ static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state)
59375961
struct net_device *netdev = priv->netdev;
59385962
struct mlx5_core_dev *mdev = priv->mdev;
59395963

5940-
if (!netif_device_present(netdev))
5964+
if (!netif_device_present(netdev)) {
5965+
if (test_bit(MLX5E_STATE_DESTROYING, &priv->state))
5966+
mlx5e_destroy_mdev_resources(mdev);
59415967
return -ENODEV;
5968+
}
59425969

59435970
mlx5e_detach_netdev(priv);
59445971
mlx5e_destroy_mdev_resources(mdev);

0 commit comments

Comments
 (0)