[openib-general] lockdep warnings

Roland Dreier rdreier at cisco.com
Thu Aug 31 17:29:56 PDT 2006


    Michael> Hi, Roland!  I got a load of lockdep warnings after
    Michael> loading all modules and configuring ipoib. This doesn't
    Michael> usually happen, not sure what I changed this time.  I'm a
    Michael> bit too busy this week - could you take a look at the
    Michael> log, please?

This would only happen on a mem-full HCA.  I just asked Linus to pull
the following fix.

commit 02113bd77e86386d02a9a606cdad53803a6e2794
Author: Roland Dreier <rolandd at cisco.com>
Date:   Thu Aug 31 16:43:06 2006 -0700

    IB/mthca: Use IRQ safe locks to protect allocation bitmaps
    
    It is supposed to be OK to call mthca_create_ah() and mthca_destroy_ah()
    from any context.  However, for mem-full HCAs, these functions use the
    mthca_alloc() and mthca_free() bitmap helpers, and those helpers use
    non-IRQ-safe spin_lock() internally.  Lockdep correctly warns that
    this could lead to a deadlock.  Fix this by changing mthca_alloc() and
    mthca_free() to use spin_lock_irqsave().
    
    Signed-off-by: Roland Dreier <rolandd at cisco.com>

diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infiniband/hw/mthca/mthca_allocator.c
index 25157f5..f930e55 100644
--- a/drivers/infiniband/hw/mthca/mthca_allocator.c
+++ b/drivers/infiniband/hw/mthca/mthca_allocator.c
@@ -41,9 +41,11 @@ #include "mthca_dev.h"
 /* Trivial bitmap-based allocator */
 u32 mthca_alloc(struct mthca_alloc *alloc)
 {
+	unsigned long flags;
 	u32 obj;
 
-	spin_lock(&alloc->lock);
+	spin_lock_irqsave(&alloc->lock, flags);
+
 	obj = find_next_zero_bit(alloc->table, alloc->max, alloc->last);
 	if (obj >= alloc->max) {
 		alloc->top = (alloc->top + alloc->max) & alloc->mask;
@@ -56,19 +58,24 @@ u32 mthca_alloc(struct mthca_alloc *allo
 	} else
 		obj = -1;
 
-	spin_unlock(&alloc->lock);
+	spin_unlock_irqrestore(&alloc->lock, flags);
 
 	return obj;
 }
 
 void mthca_free(struct mthca_alloc *alloc, u32 obj)
 {
+	unsigned long flags;
+
 	obj &= alloc->max - 1;
-	spin_lock(&alloc->lock);
+
+	spin_lock_irqsave(&alloc->lock, flags);
+
 	clear_bit(obj, alloc->table);
 	alloc->last = min(alloc->last, obj);
 	alloc->top = (alloc->top + alloc->max) & alloc->mask;
-	spin_unlock(&alloc->lock);
+
+	spin_unlock_irqrestore(&alloc->lock, flags);
 }
 
 int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,




More information about the general mailing list