Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8b8c8bca3a63073bac20f0fca178e00fdf7f5a09
Commit:     8b8c8bca3a63073bac20f0fca178e00fdf7f5a09
Parent:     7b82cd8ee7374f803a3daf9a6cbc6eb4bbb10a63
Author:     Roland Dreier <[EMAIL PROTECTED]>
AuthorDate: Sat May 19 08:51:53 2007 -0700
Committer:  Roland Dreier <[EMAIL PROTECTED]>
CommitDate: Sat May 19 08:51:53 2007 -0700

    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 <[EMAIL PROTECTED]>
---
 drivers/infiniband/hw/ipath/ipath_verbs_mcast.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c 
b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
index 085e28b..dd691cf 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
@@ -165,10 +165,9 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
 {
        struct rb_node **n = &mcast_tree.rb_node;
        struct rb_node *pn = NULL;
-       unsigned long flags;
        int ret;
 
-       spin_lock_irqsave(&mcast_lock, flags);
+       spin_lock_irq(&mcast_lock);
 
        while (*n) {
                struct ipath_mcast *tmcast;
@@ -228,7 +227,7 @@ static int ipath_mcast_add(struct ipath_ibdev *dev,
        ret = 0;
 
 bail:
-       spin_unlock_irqrestore(&mcast_lock, flags);
+       spin_unlock_irq(&mcast_lock);
 
        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_qp *p, *tmp;
        struct rb_node *n;
-       unsigned long flags;
        int last = 0;
        int ret;
 
-       spin_lock_irqsave(&mcast_lock, flags);
+       spin_lock_irq(&mcast_lock);
 
        /* Find the GID in the mcast table. */
        n = mcast_tree.rb_node;
        while (1) {
                if (n == NULL) {
-                       spin_unlock_irqrestore(&mcast_lock, flags);
+                       spin_unlock_irq(&mcast_lock);
                        ret = -EINVAL;
                        goto bail;
                }
@@ -334,7 +332,7 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid 
*gid, u16 lid)
                break;
        }
 
-       spin_unlock_irqrestore(&mcast_lock, flags);
+       spin_unlock_irq(&mcast_lock);
 
        if (p) {
                /*
@@ -348,9 +346,9 @@ int ipath_multicast_detach(struct ib_qp *ibqp, union ib_gid 
*gid, u16 lid)
                atomic_dec(&mcast->refcount);
                wait_event(mcast->wait, !atomic_read(&mcast->refcount));
                ipath_mcast_free(mcast);
-               spin_lock(&dev->n_mcast_grps_lock);
+               spin_lock_irq(&dev->n_mcast_grps_lock);
                dev->n_mcast_grps_allocated--;
-               spin_unlock(&dev->n_mcast_grps_lock);
+               spin_unlock_irq(&dev->n_mcast_grps_lock);
        }
 
        ret = 0;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to