MIPS: asm: spinlock: Replace "sub" instruction with "addiu"
authorMarkos Chandras <markos.chandras@imgtec.com>
Mon, 24 Nov 2014 14:11:39 +0000 (14:11 +0000)
committerMarkos Chandras <markos.chandras@imgtec.com>
Tue, 17 Feb 2015 15:37:23 +0000 (15:37 +0000)
"sub $reg, imm" is not a real MIPS instruction. The assembler can
replace that with "addi $reg, -imm". However, addi has been removed
from R6, so we replace the "sub" instruction with the "addiu" one.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
arch/mips/include/asm/spinlock.h

index b5238404c05918fbf8c56af26a50ce6abbcd14c2..b4548690ade9916e1d94e844641a505fad43bea4 100644 (file)
@@ -254,9 +254,6 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
        smp_llsc_mb();
 }
 
-/* Note the use of sub, not subu which will make the kernel die with an
-   overflow exception if we ever try to unlock an rwlock that is already
-   unlocked or is being held by a writer.  */
 static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
        unsigned int tmp;
@@ -266,7 +263,7 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
                "1:     ll      %1, %2          # arch_read_unlock      \n"
-               "       sub     %1, 1                                   \n"
+               "       addiu   %1, 1                                   \n"
                "       sc      %1, %0                                  \n"
                "       beqzl   %1, 1b                                  \n"
                : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp)
@@ -276,7 +273,7 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
                do {
                        __asm__ __volatile__(
                        "1:     ll      %1, %2  # arch_read_unlock      \n"
-                       "       sub     %1, 1                           \n"
+                       "       addiu   %1, -1                          \n"
                        "       sc      %1, %0                          \n"
                        : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp)
                        : GCC_OFF_SMALL_ASM() (rw->lock)