Commit b63fe1ba4409774738c971d4e6f0b12b54cc2c65

Authored by Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband:
  IB/mthca: Use IRQ safe locks to protect allocation bitmaps

Showing 1 changed file Side-by-side Diff

drivers/infiniband/hw/mthca/mthca_allocator.c
... ... @@ -41,9 +41,11 @@
41 41 /* Trivial bitmap-based allocator */
42 42 u32 mthca_alloc(struct mthca_alloc *alloc)
43 43 {
  44 + unsigned long flags;
44 45 u32 obj;
45 46  
46   - spin_lock(&alloc->lock);
  47 + spin_lock_irqsave(&alloc->lock, flags);
  48 +
47 49 obj = find_next_zero_bit(alloc->table, alloc->max, alloc->last);
48 50 if (obj >= alloc->max) {
49 51 alloc->top = (alloc->top + alloc->max) & alloc->mask;
50 52  
51 53  
52 54  
... ... @@ -56,19 +58,24 @@
56 58 } else
57 59 obj = -1;
58 60  
59   - spin_unlock(&alloc->lock);
  61 + spin_unlock_irqrestore(&alloc->lock, flags);
60 62  
61 63 return obj;
62 64 }
63 65  
64 66 void mthca_free(struct mthca_alloc *alloc, u32 obj)
65 67 {
  68 + unsigned long flags;
  69 +
66 70 obj &= alloc->max - 1;
67   - spin_lock(&alloc->lock);
  71 +
  72 + spin_lock_irqsave(&alloc->lock, flags);
  73 +
68 74 clear_bit(obj, alloc->table);
69 75 alloc->last = min(alloc->last, obj);
70 76 alloc->top = (alloc->top + alloc->max) & alloc->mask;
71   - spin_unlock(&alloc->lock);
  77 +
  78 + spin_unlock_irqrestore(&alloc->lock, flags);
72 79 }
73 80  
74 81 int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,