Skip to contentSkip to conversation

fix locking bugs in mv64x60 code

PATCH In review Mark A. Greer 1 participant 2 messages Feb 3, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix locking bugs in mv64x60 code

[Original patch slightly edited by mgreer]

This patch fixes 2 SMP deadlocks. The first is that mv64x60_read() was returning before the unlock. The second was mv64x60_modify() locks the spin lock and calls mv64x60_read() and mv64x60_write() which also lock the same spin lock.

Please apply.

#1 lore raw

And with the patch this time...
--

Quoted 10 lines · Mark A. Greer

[Original patch slightly edited by mgreer]

This patch fixes 2 SMP deadlocks. The first is that mv64x60_read() was returning before the unlock. The second was mv64x60_modify() locks the spin lock and calls mv64x60_read() and mv64x60_write() which also lock the same spin lock.

Please apply.

arch/ppc/syslib/mv64x60.c +1 -1
diff -Nru a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
@@ -32,7 +32,7 @@
 
 
 u8		mv64x60_pci_exclude_bridge = 1;
-spinlock_t	mv64x60_lock; /* Only really used by PIC code once init done */
+spinlock_t	mv64x60_lock = SPIN_LOCK_UNLOCKED;
 
 static phys_addr_t 	mv64x60_bridge_pbase = 0;
 static void 		*mv64x60_bridge_vbase = 0;
include/asm-ppc/mv64x60.h +6 -4
diff -Nru a/include/asm-ppc/mv64x60.h b/include/asm-ppc/mv64x60.h
@@ -254,10 +254,12 @@
 extern inline u32
 mv64x60_read(struct mv64x60_handle *bh, u32 offset) {
 	ulong	flags;
+	u32     reg;
 
 	spin_lock_irqsave(&mv64x60_lock, flags);
-	return in_le32(bh->v_base + offset);
+	reg = in_le32(bh->v_base + offset);
 	spin_unlock_irqrestore(&mv64x60_lock, flags);
+	return reg;
 }
 
 extern inline void
@@ -267,9 +269,9 @@
 	ulong	flags;
 
 	spin_lock_irqsave(&mv64x60_lock, flags);
-	reg = mv64x60_read(bh, offs) & (~mask); /* zero bits we care about */
-	reg |= data & mask; /* set bits from the data */
-	mv64x60_write(bh, offs, reg);
+	reg = in_le32(bh->v_base + offs) & (~mask);
+	reg |= data & mask;
+	out_le32(bh->v_base + offs, reg);
 	spin_unlock_irqrestore(&mv64x60_lock, flags);
 }