mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
net/mlx5e: Add a lock on tir list
[ Upstream commit80a2a9026b
] Refresh tirs is looping over a global list of tirs while netdevs are adding and removing tirs from that list. That is why a lock is required. Fixes:724b2aa151
("net/mlx5e: TIRs management refactoring") Signed-off-by: Yuval Avnery <yuvalav@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7143c8997a
commit
b5ba76a58b
2 changed files with 9 additions and 0 deletions
|
@ -45,7 +45,9 @@ int mlx5e_create_tir(struct mlx5_core_dev *mdev,
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
mutex_lock(&mdev->mlx5e_res.td.list_lock);
|
||||||
list_add(&tir->list, &mdev->mlx5e_res.td.tirs_list);
|
list_add(&tir->list, &mdev->mlx5e_res.td.tirs_list);
|
||||||
|
mutex_unlock(&mdev->mlx5e_res.td.list_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -53,8 +55,10 @@ int mlx5e_create_tir(struct mlx5_core_dev *mdev,
|
||||||
void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
|
void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
|
||||||
struct mlx5e_tir *tir)
|
struct mlx5e_tir *tir)
|
||||||
{
|
{
|
||||||
|
mutex_lock(&mdev->mlx5e_res.td.list_lock);
|
||||||
mlx5_core_destroy_tir(mdev, tir->tirn);
|
mlx5_core_destroy_tir(mdev, tir->tirn);
|
||||||
list_del(&tir->list);
|
list_del(&tir->list);
|
||||||
|
mutex_unlock(&mdev->mlx5e_res.td.list_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,
|
static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn,
|
||||||
|
@ -114,6 +118,7 @@ int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list);
|
INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list);
|
||||||
|
mutex_init(&mdev->mlx5e_res.td.list_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -158,6 +163,7 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb)
|
||||||
|
|
||||||
MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1);
|
MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1);
|
||||||
|
|
||||||
|
mutex_lock(&mdev->mlx5e_res.td.list_lock);
|
||||||
list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) {
|
list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) {
|
||||||
tirn = tir->tirn;
|
tirn = tir->tirn;
|
||||||
err = mlx5_core_modify_tir(mdev, tirn, in, inlen);
|
err = mlx5_core_modify_tir(mdev, tirn, in, inlen);
|
||||||
|
@ -169,6 +175,7 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb)
|
||||||
kvfree(in);
|
kvfree(in);
|
||||||
if (err)
|
if (err)
|
||||||
netdev_err(priv->netdev, "refresh tir(0x%x) failed, %d\n", tirn, err);
|
netdev_err(priv->netdev, "refresh tir(0x%x) failed, %d\n", tirn, err);
|
||||||
|
mutex_unlock(&mdev->mlx5e_res.td.list_lock);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,6 +743,8 @@ struct mlx5_pagefault {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mlx5_td {
|
struct mlx5_td {
|
||||||
|
/* protects tirs list changes while tirs refresh */
|
||||||
|
struct mutex list_lock;
|
||||||
struct list_head tirs_list;
|
struct list_head tirs_list;
|
||||||
u32 tdn;
|
u32 tdn;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue