RDMA/rxe: Move mcg_lock to rxe
Replace mcg->mcg_lock and mc_grp_pool->pool_lock by rxe->mcg_lock. This is the first step of several intended to decouple the mc_grp and mc_elem objects from the rxe pool code. Link: https://lore.kernel.org/r/20220208211644.123457-2-rpearsonhpe@gmail.com Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
a099b08599
commit
9fd0eb7c3c
|
@ -211,6 +211,8 @@ static int rxe_init(struct rxe_dev *rxe)
|
|||
spin_lock_init(&rxe->pending_lock);
|
||||
INIT_LIST_HEAD(&rxe->pending_mmaps);
|
||||
|
||||
spin_lock_init(&rxe->mcg_lock);
|
||||
|
||||
mutex_init(&rxe->usdev_lock);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -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 struct rxe_mcg *create_grp(struct rxe_dev *rxe,
|
||||
struct rxe_pool *pool,
|
||||
union ib_gid *mgid)
|
||||
|
@ -38,7 +38,6 @@ static struct rxe_mcg *create_grp(struct rxe_dev *rxe,
|
|||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
INIT_LIST_HEAD(&grp->qp_list);
|
||||
spin_lock_init(&grp->mcg_lock);
|
||||
grp->rxe = rxe;
|
||||
rxe_add_key_locked(grp, mgid);
|
||||
|
||||
|
@ -63,7 +62,7 @@ static int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid,
|
|||
if (rxe->attr.max_mcast_qp_attach == 0)
|
||||
return -EINVAL;
|
||||
|
||||
write_lock_irqsave(&pool->pool_lock, flags);
|
||||
spin_lock_irqsave(&rxe->mcg_lock, flags);
|
||||
|
||||
grp = rxe_pool_get_key_locked(pool, mgid);
|
||||
if (grp)
|
||||
|
@ -71,13 +70,13 @@ static int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid,
|
|||
|
||||
grp = create_grp(rxe, pool, mgid);
|
||||
if (IS_ERR(grp)) {
|
||||
write_unlock_irqrestore(&pool->pool_lock, flags);
|
||||
spin_unlock_irqrestore(&rxe->mcg_lock, flags);
|
||||
err = PTR_ERR(grp);
|
||||
return err;
|
||||
}
|
||||
|
||||
done:
|
||||
write_unlock_irqrestore(&pool->pool_lock, flags);
|
||||
spin_unlock_irqrestore(&rxe->mcg_lock, flags);
|
||||
*grp_p = grp;
|
||||
return 0;
|
||||
}
|
||||
|
@ -90,7 +89,7 @@ static int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
|
|||
unsigned long flags;
|
||||
|
||||
/* check to see of the qp is already a member of the group */
|
||||
spin_lock_irqsave(&grp->mcg_lock, flags);
|
||||
spin_lock_irqsave(&rxe->mcg_lock, flags);
|
||||
list_for_each_entry(elem, &grp->qp_list, qp_list) {
|
||||
if (elem->qp == qp) {
|
||||
err = 0;
|
||||
|
@ -120,7 +119,7 @@ static int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
|
|||
|
||||
err = 0;
|
||||
out:
|
||||
spin_unlock_irqrestore(&grp->mcg_lock, flags);
|
||||
spin_unlock_irqrestore(&rxe->mcg_lock, flags);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -135,7 +134,7 @@ static int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
|
|||
if (!grp)
|
||||
goto err1;
|
||||
|
||||
spin_lock_irqsave(&grp->mcg_lock, flags);
|
||||
spin_lock_irqsave(&rxe->mcg_lock, flags);
|
||||
|
||||
list_for_each_entry_safe(elem, tmp, &grp->qp_list, qp_list) {
|
||||
if (elem->qp == qp) {
|
||||
|
@ -143,7 +142,7 @@ static int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
|
|||
grp->num_qp--;
|
||||
atomic_dec(&qp->mcg_num);
|
||||
|
||||
spin_unlock_irqrestore(&grp->mcg_lock, flags);
|
||||
spin_unlock_irqrestore(&rxe->mcg_lock, flags);
|
||||
rxe_drop_ref(elem);
|
||||
rxe_drop_ref(grp); /* ref held by QP */
|
||||
rxe_drop_ref(grp); /* ref from get_key */
|
||||
|
@ -151,7 +150,7 @@ static int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
|
|||
}
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&grp->mcg_lock, flags);
|
||||
spin_unlock_irqrestore(&rxe->mcg_lock, flags);
|
||||
rxe_drop_ref(grp); /* ref from get_key */
|
||||
err1:
|
||||
return -EINVAL;
|
||||
|
|
|
@ -250,7 +250,7 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
|
|||
if (!mcg)
|
||||
goto drop; /* mcast group not registered */
|
||||
|
||||
spin_lock_bh(&mcg->mcg_lock);
|
||||
spin_lock_bh(&rxe->mcg_lock);
|
||||
|
||||
/* this is unreliable datagram service so we let
|
||||
* failures to deliver a multicast packet to a
|
||||
|
@ -298,7 +298,7 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
|
|||
}
|
||||
}
|
||||
|
||||
spin_unlock_bh(&mcg->mcg_lock);
|
||||
spin_unlock_bh(&rxe->mcg_lock);
|
||||
|
||||
rxe_drop_ref(mcg); /* drop ref from rxe_pool_get_key. */
|
||||
|
||||
|
|
|
@ -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;
|
||||
union ib_gid mgid;
|
||||
|
@ -399,6 +398,8 @@ struct rxe_dev {
|
|||
struct rxe_pool mc_grp_pool;
|
||||
struct rxe_pool mc_elem_pool;
|
||||
|
||||
spinlock_t mcg_lock;
|
||||
|
||||
spinlock_t pending_lock; /* guard pending_mmaps */
|
||||
struct list_head pending_mmaps;
|
||||
|
||||
|
|
Loading…
Reference in New Issue