Commit aad028ca authored by Paul Burton's avatar Paul Burton

MIPS: bitops: Avoid redundant zero-comparison for non-LLSC

The IRQ-disabling non-LLSC fallbacks for bitops on UP systems already
return a zero or one, so there's no need to perform another comparison
against zero. Move these comparisons into the LLSC paths to avoid the
redundant work.
Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
Cc: linux-mips@vger.kernel.org
Cc: Huacai Chen <chenhc@lemote.com>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: linux-kernel@vger.kernel.org
parent d6103510
...@@ -264,6 +264,8 @@ static inline int test_and_set_bit_lock(unsigned long nr, ...@@ -264,6 +264,8 @@ static inline int test_and_set_bit_lock(unsigned long nr,
: "=&r" (temp), "+m" (*m), "=&r" (res) : "=&r" (temp), "+m" (*m), "=&r" (res)
: "ir" (BIT(bit)) : "ir" (BIT(bit))
: __LLSC_CLOBBER); : __LLSC_CLOBBER);
res = res != 0;
} else { } else {
loongson_llsc_mb(); loongson_llsc_mb();
do { do {
...@@ -279,12 +281,12 @@ static inline int test_and_set_bit_lock(unsigned long nr, ...@@ -279,12 +281,12 @@ static inline int test_and_set_bit_lock(unsigned long nr,
: __LLSC_CLOBBER); : __LLSC_CLOBBER);
} while (unlikely(!res)); } while (unlikely(!res));
res = temp & BIT(bit); res = (temp & BIT(bit)) != 0;
} }
smp_llsc_mb(); smp_llsc_mb();
return res != 0; return res;
} }
/* /*
...@@ -335,6 +337,8 @@ static inline int test_and_clear_bit(unsigned long nr, ...@@ -335,6 +337,8 @@ static inline int test_and_clear_bit(unsigned long nr,
: "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (*m), "=&r" (res) : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (*m), "=&r" (res)
: "ir" (BIT(bit)) : "ir" (BIT(bit))
: __LLSC_CLOBBER); : __LLSC_CLOBBER);
res = res != 0;
} else if ((MIPS_ISA_REV >= 2) && __builtin_constant_p(nr)) { } else if ((MIPS_ISA_REV >= 2) && __builtin_constant_p(nr)) {
loongson_llsc_mb(); loongson_llsc_mb();
do { do {
...@@ -363,12 +367,12 @@ static inline int test_and_clear_bit(unsigned long nr, ...@@ -363,12 +367,12 @@ static inline int test_and_clear_bit(unsigned long nr,
: __LLSC_CLOBBER); : __LLSC_CLOBBER);
} while (unlikely(!res)); } while (unlikely(!res));
res = temp & BIT(bit); res = (temp & BIT(bit)) != 0;
} }
smp_llsc_mb(); smp_llsc_mb();
return res != 0; return res;
} }
/* /*
...@@ -403,6 +407,8 @@ static inline int test_and_change_bit(unsigned long nr, ...@@ -403,6 +407,8 @@ static inline int test_and_change_bit(unsigned long nr,
: "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (*m), "=&r" (res) : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (*m), "=&r" (res)
: "ir" (BIT(bit)) : "ir" (BIT(bit))
: __LLSC_CLOBBER); : __LLSC_CLOBBER);
res = res != 0;
} else { } else {
loongson_llsc_mb(); loongson_llsc_mb();
do { do {
...@@ -418,12 +424,12 @@ static inline int test_and_change_bit(unsigned long nr, ...@@ -418,12 +424,12 @@ static inline int test_and_change_bit(unsigned long nr,
: __LLSC_CLOBBER); : __LLSC_CLOBBER);
} while (unlikely(!res)); } while (unlikely(!res));
res = temp & BIT(bit); res = (temp & BIT(bit)) != 0;
} }
smp_llsc_mb(); smp_llsc_mb();
return res != 0; return res;
} }
#include <asm-generic/bitops/non-atomic.h> #include <asm-generic/bitops/non-atomic.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment