@@ -198,6 +198,8 @@ static int rxe_init(struct rxe_dev *rxe)
if (err)
return err;
+ spin_lock_init(&rxe->mcg_lock);
+
/* init pending mmap list */
spin_lock_init(&rxe->mmap_offset_lock);
spin_lock_init(&rxe->pending_lock);
@@ -25,7 +25,7 @@ static int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid)
return dev_mc_del(rxe->ndev, ll_addr);
}
-/* caller should hold mc_grp_pool->pool_lock */
+/* caller should hold rxe->mcg_lock */
static int __rxe_create_mcg(struct rxe_dev *rxe, struct rxe_pool *pool,
union ib_gid *mgid, struct rxe_mcg **mcg_p)
{
@@ -43,7 +43,6 @@ static int __rxe_create_mcg(struct rxe_dev *rxe, struct rxe_pool *pool,
}
INIT_LIST_HEAD(&mcg->qp_list);
- spin_lock_init(&mcg->mcg_lock);
mcg->rxe = rxe;
rxe_add_ref(mcg);
@@ -72,7 +71,7 @@ static int rxe_mcast_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid,
if (rxe->attr.max_mcast_qp_attach == 0)
return -EINVAL;
- write_lock_bh(&pool->pool_lock);
+ spin_lock_bh(&rxe->mcg_lock);
mcg = rxe_pool_get_key_locked(pool, mgid);
if (mcg)
@@ -80,12 +79,12 @@ static int rxe_mcast_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid,
err = __rxe_create_mcg(rxe, pool, mgid, &mcg);
if (err) {
- write_unlock_bh(&pool->pool_lock);
+ spin_unlock_bh(&rxe->mcg_lock);
return err;
}
done:
- write_unlock_bh(&pool->pool_lock);
+ spin_unlock_bh(&rxe->mcg_lock);
*mcg_p = mcg;
return 0;
}
@@ -97,21 +96,21 @@ static int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
struct rxe_mca *mca, *new_mca;
/* check to see if the qp is already a member of the group */
- spin_lock_bh(&mcg->mcg_lock);
+ spin_lock_bh(&rxe->mcg_lock);
list_for_each_entry(mca, &mcg->qp_list, qp_list) {
if (mca->qp == qp) {
- spin_unlock_bh(&mcg->mcg_lock);
+ spin_unlock_bh(&rxe->mcg_lock);
return 0;
}
}
- spin_unlock_bh(&mcg->mcg_lock);
+ spin_unlock_bh(&rxe->mcg_lock);
/* speculative alloc new mca without using GFP_ATOMIC */
new_mca = kzalloc(sizeof(*mca), GFP_KERNEL);
if (!new_mca)
return -ENOMEM;
- spin_lock_bh(&mcg->mcg_lock);
+ spin_lock_bh(&rxe->mcg_lock);
/* re-check to see if someone else just attached qp */
list_for_each_entry(mca, &mcg->qp_list, qp_list) {
if (mca->qp == qp) {
@@ -135,7 +134,7 @@ static int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
err = 0;
out:
- spin_unlock_bh(&mcg->mcg_lock);
+ spin_unlock_bh(&rxe->mcg_lock);
return err;
}
@@ -149,7 +148,7 @@ static int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
if (!mcg)
goto err1;
- spin_lock_bh(&mcg->mcg_lock);
+ spin_lock_bh(&rxe->mcg_lock);
list_for_each_entry_safe(mca, tmp, &mcg->qp_list, qp_list) {
if (mca->qp == qp) {
@@ -158,14 +157,14 @@ static int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
__rxe_destroy_mcg(mcg);
atomic_dec(&qp->mcg_num);
- spin_unlock_bh(&mcg->mcg_lock);
+ spin_unlock_bh(&rxe->mcg_lock);
rxe_drop_ref(mcg);
kfree(mca);
return 0;
}
}
- spin_unlock_bh(&mcg->mcg_lock);
+ spin_unlock_bh(&rxe->mcg_lock);
rxe_drop_ref(mcg);
err1:
return -EINVAL;
@@ -267,14 +267,14 @@ static void rxe_rcv_mcast_pkt(struct sk_buff *skb)
qp_array = kmalloc_array(nmax, sizeof(qp), GFP_KERNEL);
n = 0;
- spin_lock_bh(&mcg->mcg_lock);
+ spin_lock_bh(&rxe->mcg_lock);
list_for_each_entry(mca, &mcg->qp_list, qp_list) {
rxe_add_ref(mca->qp);
qp_array[n++] = mca->qp;
if (n == nmax)
break;
}
- spin_unlock_bh(&mcg->mcg_lock);
+ spin_unlock_bh(&rxe->mcg_lock);
nmax = n;
/* this is unreliable datagram service so we let
@@ -353,7 +353,6 @@ struct rxe_mw {
struct rxe_mcg {
struct rxe_pool_elem elem;
- spinlock_t mcg_lock; /* guard group */
struct rxe_dev *rxe;
struct list_head qp_list;
atomic_t qp_num;
@@ -397,6 +396,8 @@ struct rxe_dev {
struct rxe_pool mw_pool;
struct rxe_pool mc_grp_pool;
+ spinlock_t mcg_lock; /* guard multicast groups */
+
spinlock_t pending_lock; /* guard pending_mmaps */
struct list_head pending_mmaps;
Starting to decouple mcg from rxe pools, replace the spin lock mcg->mcg_lock and the read/write lock pool->pool_lock by rxe->mcg_lock. Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> --- drivers/infiniband/sw/rxe/rxe.c | 2 ++ drivers/infiniband/sw/rxe/rxe_mcast.c | 25 ++++++++++++------------- drivers/infiniband/sw/rxe/rxe_recv.c | 4 ++-- drivers/infiniband/sw/rxe/rxe_verbs.h | 3 ++- 4 files changed, 18 insertions(+), 16 deletions(-)