Commit f743ff3b authored by Saeed Mahameed's avatar Saeed Mahameed Committed by Jason Gunthorpe

RDMA/mlx5: Replace spinlock protected write with atomic var

mkey variant calculation was spinlock protected to make it atomic, replace
that with one atomic variable.

Link: https://lore.kernel.org/r/20200310082238.239865-4-leon@kernel.orgSigned-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent a3cfdd39
...@@ -6390,7 +6390,7 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) ...@@ -6390,7 +6390,7 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
spin_lock_init(&dev->reset_flow_resource_lock); spin_lock_init(&dev->reset_flow_resource_lock);
xa_init(&dev->odp_mkeys); xa_init(&dev->odp_mkeys);
xa_init(&dev->sig_mrs); xa_init(&dev->sig_mrs);
spin_lock_init(&dev->mkey_lock); atomic_set(&dev->mkey_var, 0);
spin_lock_init(&dev->dm.lock); spin_lock_init(&dev->dm.lock);
dev->dm.dev = mdev; dev->dm.dev = mdev;
......
...@@ -993,10 +993,7 @@ struct mlx5_ib_dev { ...@@ -993,10 +993,7 @@ struct mlx5_ib_dev {
*/ */
struct mlx5_ib_resources devr; struct mlx5_ib_resources devr;
/* protect mkey key part */ atomic_t mkey_var;
spinlock_t mkey_lock;
u8 mkey_key;
struct mlx5_mr_cache cache; struct mlx5_mr_cache cache;
struct timer_list delay_timer; struct timer_list delay_timer;
/* Prevents soft lock on massive reg MRs */ /* Prevents soft lock on massive reg MRs */
......
...@@ -54,12 +54,8 @@ static void ...@@ -54,12 +54,8 @@ static void
assign_mkey_variant(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey, assign_mkey_variant(struct mlx5_ib_dev *dev, struct mlx5_core_mkey *mkey,
u32 *in) u32 *in)
{ {
u8 key = atomic_inc_return(&dev->mkey_var);
void *mkc; void *mkc;
u8 key;
spin_lock_irq(&dev->mkey_lock);
key = dev->mkey_key++;
spin_unlock_irq(&dev->mkey_lock);
mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry); mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
MLX5_SET(mkc, mkc, mkey_7_0, key); MLX5_SET(mkc, mkc, mkey_7_0, key);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment