maltalinux-cvs-patches
[Top] [All Lists]

CVS Update@linux-mips.org: malta

To: maltalinux-cvs-patches@linux-mips.org
Subject: CVS Update@linux-mips.org: malta
From: chris@linux-mips.org
Date: Thu, 28 Jul 2005 18:22:01 +0100
Reply-to: linux-mips@linux-mips.org
Sender: maltalinux-cvs-patches-bounce@linux-mips.org
CVSROOT:        /home/cvs
Module name:    malta
Changes by:     chris@ftp.linux-mips.org        05/07/28 18:22:00

Modified files:
        linux/include/asm-mips: Tag: MaltaRef_2_6 spinlock.h 

Log message:
        * include/asm-mips/spinlock.h: Added DEBUG_SPINLOCK support.

diff -urN malta/linux/include/asm-mips/spinlock.h 
malta/linux/include/asm-mips/spinlock.h
--- malta/linux/include/asm-mips/spinlock.h     2005/06/21 13:36:24     
1.23.1000.2
+++ malta/linux/include/asm-mips/spinlock.h     2005/07/28 17:22:00     
1.23.1000.3
@@ -18,14 +18,25 @@
 
 typedef struct {
        volatile unsigned int lock;
+#ifdef CONFIG_DEBUG_SPINLOCK
+       unsigned int magic;
+#endif
 #ifdef CONFIG_PREEMPT
        unsigned int break_lock;
 #endif
 } spinlock_t;
 
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
+#define SPINLOCK_MAGIC 0xdead4ead
+
+#ifdef CONFIG_DEBUG_SPINLOCK
+#define SPINLOCK_MAGIC_INIT    , SPINLOCK_MAGIC
+#else
+#define SPINLOCK_MAGIC_INIT    /* */
+#endif
 
-#define spin_lock_init(x)      do { (x)->lock = 0; } while(0)
+#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 SPINLOCK_MAGIC_INIT }
+
+#define spin_lock_init(x)      do { *(x) = SPIN_LOCK_UNLOCKED; } while(0)
 
 #define spin_is_locked(x)      ((x)->lock != 0)
 #define spin_unlock_wait(x)    do { barrier(); } while ((x)->lock)
@@ -42,6 +53,14 @@
 {
        unsigned int tmp;
 
+#ifdef CONFIG_DEBUG_SPINLOCK
+here:
+       if (unlikely(lock->magic != SPINLOCK_MAGIC)) {
+               printk("eip: %p\n", &&here);
+               BUG();
+       }
+#endif
+
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
                "       .set    noreorder       # _raw_spin_lock        \n"
@@ -74,6 +93,10 @@
 
 static inline void _raw_spin_unlock(spinlock_t *lock)
 {
+#ifdef CONFIG_DEBUG_SPINLOCK
+       BUG_ON(lock->magic != SPINLOCK_MAGIC);
+       BUG_ON(!spin_is_locked(lock));
+#endif
        __asm__ __volatile__(
        "       .set    noreorder       # _raw_spin_unlock      \n"
        "       sync                                            \n"
@@ -131,12 +154,23 @@
 
 typedef struct {
        volatile unsigned int lock;
+#ifdef CONFIG_DEBUG_SPINLOCK
+       unsigned magic;
+#endif
 #ifdef CONFIG_PREEMPT
        unsigned int break_lock;
 #endif
 } rwlock_t;
 
-#define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
+#define RWLOCK_MAGIC   0xdeaf1eed
+
+#ifdef CONFIG_DEBUG_SPINLOCK
+#define RWLOCK_MAGIC_INIT      , RWLOCK_MAGIC
+#else
+#define RWLOCK_MAGIC_INIT      /* */
+#endif
+
+#define RW_LOCK_UNLOCKED (rwlock_t) { 0 RWLOCK_MAGIC_INIT }
 
 #define rwlock_init(x)  do { *(x) = RW_LOCK_UNLOCKED; } while(0)
 
@@ -156,6 +190,9 @@
 {
        unsigned int tmp;
 
+#ifdef CONFIG_DEBUG_SPINLOCK
+       BUG_ON(rw->magic != RWLOCK_MAGIC);
+#endif
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
                "       .set    noreorder       # _raw_read_lock        \n"
@@ -193,6 +230,9 @@
 {
        unsigned int tmp;
 
+#ifdef CONFIG_DEBUG_SPINLOCK
+       BUG_ON(rw->magic != RWLOCK_MAGIC);
+#endif
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
                "1:     ll      %1, %2          # _raw_read_unlock      \n"
@@ -222,6 +262,9 @@
 {
        unsigned int tmp;
 
+#ifdef CONFIG_DEBUG_SPINLOCK
+       BUG_ON(rw->magic != RWLOCK_MAGIC);
+#endif
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
                "       .set    noreorder       # _raw_write_lock       \n"
@@ -253,6 +296,9 @@
 
 static inline void _raw_write_unlock(rwlock_t *rw)
 {
+#ifdef CONFIG_DEBUG_SPINLOCK
+       BUG_ON(rw->magic != RWLOCK_MAGIC);
+#endif
        __asm__ __volatile__(
        "       sync                    # _raw_write_unlock     \n"
        "       sw      $0, %0                                  \n"
@@ -268,6 +314,9 @@
        unsigned int tmp;
        int ret;
 
+#ifdef CONFIG_DEBUG_SPINLOCK
+       BUG_ON(rw->magic != RWLOCK_MAGIC);
+#endif
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
                "       .set    noreorder       # _raw_write_trylock    \n"

<Prev in Thread] Current Thread [Next in Thread>