patch-2.1.126 linux/include/asm-alpha/spinlock.h

Next file: linux/include/asm-alpha/system.h
Previous file: linux/include/asm-alpha/processor.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.125/linux/include/asm-alpha/spinlock.h linux/include/asm-alpha/spinlock.h
@@ -63,15 +63,24 @@
  */
 
 typedef struct {
-	volatile unsigned long lock;
+	volatile unsigned int lock;
+#if DEBUG_SPINLOCK
+	char debug_state, target_ipl, saved_ipl, on_cpu;
 	void *previous;
 	struct task_struct * task;
+#endif
 } spinlock_t;
 
-#define SPIN_LOCK_UNLOCKED { 0, 0, 0 }
+#if DEBUG_SPINLOCK
+#define SPIN_LOCK_UNLOCKED {0, 1, 0, 0, 0, 0}
+#define spin_lock_init(x)						\
+	((x)->lock = 0, (x)->target_ipl = 0, (x)->debug_state = 1,	\
+	 (x)->previous = 0, (x)->task = 0)
+#else
+#define SPIN_LOCK_UNLOCKED	{ 0 }
+#define spin_lock_init(x)	((x)->lock = 0)
+#endif
 
-#define spin_lock_init(x) \
-	((x)->lock = 0, (x)->previous = 0, (x)->task = 0)
 #define spin_unlock_wait(x) \
 	({ do { barrier(); } while(((volatile spinlock_t *)x)->lock); })
 
@@ -79,8 +88,25 @@
 #define __dummy_lock(lock) (*(__dummy_lock_t *)(lock))
 
 #if DEBUG_SPINLOCK
+extern void spin_unlock(spinlock_t * lock);
 extern void spin_lock(spinlock_t * lock);
+extern int spin_trylock(spinlock_t * lock);
+
+#define spin_lock_own(LOCK, LOCATION)					\
+do {									\
+	if (!((LOCK)->lock && (LOCK)->on_cpu == smp_processor_id()))	\
+		printk("%s: called on %d from %p but lock %s on %d\n",	\
+		       LOCATION, smp_processor_id(),			\
+		       __builtin_return_address(0),			\
+		       (LOCK)->lock ? "taken" : "freed", (LOCK)->on_cpu); \
+} while (0)
 #else
+static inline void spin_unlock(spinlock_t * lock)
+{
+	mb();
+	lock->lock = 0;
+}
+
 static inline void spin_lock(spinlock_t * lock)
 {
 	long tmp;
@@ -89,29 +115,24 @@
 	   of this object file's text section so as to perfect
 	   branch prediction.  */
 	__asm__ __volatile__(
-	"1:	ldq_l	%0,%1\n"
+	"1:	ldl_l	%0,%1\n"
 	"	blbs	%0,2f\n"
 	"	or	%0,1,%0\n"
-	"	stq_c	%0,%1\n"
+	"	stl_c	%0,%1\n"
 	"	beq	%0,2f\n"
 	"	mb\n"
 	".section .text2,\"ax\"\n"
-	"2:	ldq	%0,%1\n"
+	"2:	ldl	%0,%1\n"
 	"	blbs	%0,2b\n"
 	"	br	1b\n"
 	".previous"
 	: "=r" (tmp), "=m" (__dummy_lock(lock))
 	: "m"(__dummy_lock(lock)));
 }
-#endif /* DEBUG_SPINLOCK */
-
-static inline void spin_unlock(spinlock_t * lock)
-{
-	mb();
-	lock->lock = 0;
-}
 
 #define spin_trylock(lock) (!test_and_set_bit(0,(lock)))
+#define spin_lock_own(LOCK, LOCATION)	((void)0)
+#endif /* DEBUG_SPINLOCK */
 
 #define spin_lock_irq(lock) \
   (__cli(), spin_lock(lock))

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov