Commit 30353bfc authored by Leon Romanovsky's avatar Leon Romanovsky Committed by David S. Miller

net/mlx4_core: Use RCU to perform radix tree lookup for SRQ

Radix tree lookup can be performed without locking.

Fixes: 225c7b1f ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters")
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Suggested-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 57c970c2
...@@ -45,15 +45,12 @@ void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type) ...@@ -45,15 +45,12 @@ void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type)
struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table; struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
struct mlx4_srq *srq; struct mlx4_srq *srq;
spin_lock(&srq_table->lock); rcu_read_lock();
srq = radix_tree_lookup(&srq_table->tree, srqn & (dev->caps.num_srqs - 1)); srq = radix_tree_lookup(&srq_table->tree, srqn & (dev->caps.num_srqs - 1));
rcu_read_unlock();
if (srq) if (srq)
atomic_inc(&srq->refcount); atomic_inc(&srq->refcount);
else {
spin_unlock(&srq_table->lock);
if (!srq) {
mlx4_warn(dev, "Async event for bogus SRQ %08x\n", srqn); mlx4_warn(dev, "Async event for bogus SRQ %08x\n", srqn);
return; return;
} }
...@@ -301,12 +298,11 @@ struct mlx4_srq *mlx4_srq_lookup(struct mlx4_dev *dev, u32 srqn) ...@@ -301,12 +298,11 @@ struct mlx4_srq *mlx4_srq_lookup(struct mlx4_dev *dev, u32 srqn)
{ {
struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table; struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
struct mlx4_srq *srq; struct mlx4_srq *srq;
unsigned long flags;
spin_lock_irqsave(&srq_table->lock, flags); rcu_read_lock();
srq = radix_tree_lookup(&srq_table->tree, srq = radix_tree_lookup(&srq_table->tree,
srqn & (dev->caps.num_srqs - 1)); srqn & (dev->caps.num_srqs - 1));
spin_unlock_irqrestore(&srq_table->lock, flags); rcu_read_unlock();
return srq; return srq;
} }
......
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