Skip to content

Commit a5ae8fc

Browse files
DmytroLinkinSaeed Mahameed
authored andcommitted
net/mlx5e: Don't create devices during unload flow
Running devlink reload command for port in switchdev mode cause resources to corrupt: driver can't release allocated EQ and reclaim memory pages, because "rdma" auxiliary device had add CQs which blocks EQ from deletion. Erroneous sequence happens during reload-down phase, and is following: 1. detach device - suspends auxiliary devices which support it, destroys others. During this step "eth-rep" and "rdma-rep" are destroyed, "eth" - suspended. 2. disable SRIOV - moves device to legacy mode; as part of disablement - rescans drivers. This step adds "rdma" auxiliary device. 3. destroy EQ table - <failure>. Driver shouldn't create any device during unload flows. To handle that implement MLX5_PRIV_FLAGS_DETACH flag, set it on device detach and unset on device attach. If flag is set do no-op on drivers rescan. Fixes: a925b5e ("net/mlx5: Register mlx5 devices to auxiliary virtual bus") Signed-off-by: Dmytro Linkin <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 65fb7d1 commit a5ae8fc

File tree

2 files changed

+8
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core
  • include/linux/mlx5

2 files changed

+8
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev)
303303
int ret = 0, i;
304304

305305
mutex_lock(&mlx5_intf_mutex);
306+
priv->flags &= ~MLX5_PRIV_FLAGS_DETACH;
306307
for (i = 0; i < ARRAY_SIZE(mlx5_adev_devices); i++) {
307308
if (!priv->adev[i]) {
308309
bool is_supported = false;
@@ -375,6 +376,7 @@ void mlx5_detach_device(struct mlx5_core_dev *dev)
375376
del_adev(&priv->adev[i]->adev);
376377
priv->adev[i] = NULL;
377378
}
379+
priv->flags |= MLX5_PRIV_FLAGS_DETACH;
378380
mutex_unlock(&mlx5_intf_mutex);
379381
}
380382

@@ -463,6 +465,8 @@ int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev)
463465
struct mlx5_priv *priv = &dev->priv;
464466

465467
lockdep_assert_held(&mlx5_intf_mutex);
468+
if (priv->flags & MLX5_PRIV_FLAGS_DETACH)
469+
return 0;
466470

467471
delete_drivers(dev);
468472
if (priv->flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV)

include/linux/mlx5/driver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ struct mlx5_core_roce {
542542
enum {
543543
MLX5_PRIV_FLAGS_DISABLE_IB_ADEV = 1 << 0,
544544
MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV = 1 << 1,
545+
/* Set during device detach to block any further devices
546+
* creation/deletion on drivers rescan. Unset during device attach.
547+
*/
548+
MLX5_PRIV_FLAGS_DETACH = 1 << 2,
545549
};
546550

547551
struct mlx5_adev {

0 commit comments

Comments
 (0)