forked from luck/tmp_suning_uos_patched
IB/ipath: Fix potential deadlock with multicast spinlocks
Lockdep found the following potential deadlock between mcast_lock and n_mcast_grps_lock: mcast_lock is taken from both interrupt context and process context, so spin_lock_irqsave() must be used to take it. n_mcast_grps_lock is only taken from process context, so at first it seems safe to take it with plain spin_lock(); however, it also nests inside mcast_lock, and hence we could deadlock: cpu A cpu B ipath_mcast_add(): spin_lock_irq(&mcast_lock); ipath_mcast_detach(): spin_lock(&n_mcast_grps_lock); <enter interrupt> ipath_mcast_find(): spin_lock_irqsave(&mcast_lock); spin_lock(&n_mcast_grps_lock); Fix this by using spin_lock_irq() to take n_mcast_grps_lock. Signed-off-by: Roland Dreier <rolandd@cisco.com>
This commit is contained in:
parent
7b82cd8ee7
commit
8b8c8bca3a
@ -165,10 +165,9 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
|
|||||||
{
|
{
|
||||||
struct rb_node **n = &mcast_tree.rb_node;
|
struct rb_node **n = &mcast_tree.rb_node;
|
||||||
struct rb_node *pn = NULL;
|
struct rb_node *pn = NULL;
|
||||||
unsigned long flags;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
spin_lock_irqsave(&mcast_lock, flags);
|
spin_lock_irq(&mcast_lock);
|
||||||
|
|
||||||
while (*n) {
|
while (*n) {
|
||||||
struct ipath_mcast *tmcast;
|
struct ipath_mcast *tmcast;
|
||||||
@ -228,7 +227,7 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
spin_unlock_irqrestore(&mcast_lock, flags);
|
spin_unlock_irq(&mcast_lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -289,17 +288,16 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
|
|||||||
struct ipath_mcast *mcast = NULL;
|
struct ipath_mcast *mcast = NULL;
|
||||||
struct ipath_mcast_qp *p, *tmp;
|
struct ipath_mcast_qp *p, *tmp;
|
||||||
struct rb_node *n;
|
struct rb_node *n;
|
||||||
unsigned long flags;
|
|
||||||
int last = 0;
|
int last = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
spin_lock_irqsave(&mcast_lock, flags);
|
spin_lock_irq(&mcast_lock);
|
||||||
|
|
||||||
/* Find the GID in the mcast table. */
|
/* Find the GID in the mcast table. */
|
||||||
n = mcast_tree.rb_node;
|
n = mcast_tree.rb_node;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (n == NULL) {
|
if (n == NULL) {
|
||||||
spin_unlock_irqrestore(&mcast_lock, flags);
|
spin_unlock_irq(&mcast_lock);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
@ -334,7 +332,7 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&mcast_lock, flags);
|
spin_unlock_irq(&mcast_lock);
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
/*
|
/*
|
||||||
@ -348,9 +346,9 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
|
|||||||
atomic_dec(&mcast->refcount);
|
atomic_dec(&mcast->refcount);
|
||||||
wait_event(mcast->wait, !atomic_read(&mcast->refcount));
|
wait_event(mcast->wait, !atomic_read(&mcast->refcount));
|
||||||
ipath_mcast_free(mcast);
|
ipath_mcast_free(mcast);
|
||||||
spin_lock(&dev->n_mcast_grps_lock);
|
spin_lock_irq(&dev->n_mcast_grps_lock);
|
||||||
dev->n_mcast_grps_allocated--;
|
dev->n_mcast_grps_allocated--;
|
||||||
spin_unlock(&dev->n_mcast_grps_lock);
|
spin_unlock_irq(&dev->n_mcast_grps_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user