Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: barrier: Make __smp_mb__before_atomic() a no-op for Loongson3

Loongson3 systems with CONFIG_CPU_LOONGSON3_WORKAROUNDS enabled already
emit a full completion barrier as part of the inline assembly containing
LL/SC loops for atomic operations. As such the barrier emitted by
__smp_mb__before_atomic() is redundant, and we can remove it.

Signed-off-by: Paul 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

+11 -1
+11 -1
arch/mips/include/asm/barrier.h
··· 119 119 #define nudge_writes() mb() 120 120 #endif 121 121 122 - #define __smp_mb__before_atomic() __smp_mb__before_llsc() 122 + /* 123 + * In the Loongson3 LL/SC workaround case, all of our LL/SC loops already have 124 + * a completion barrier immediately preceding the LL instruction. Therefore we 125 + * can skip emitting a barrier from __smp_mb__before_atomic(). 126 + */ 127 + #ifdef CONFIG_CPU_LOONGSON3_WORKAROUNDS 128 + # define __smp_mb__before_atomic() 129 + #else 130 + # define __smp_mb__before_atomic() __smp_mb__before_llsc() 131 + #endif 132 + 123 133 #define __smp_mb__after_atomic() smp_llsc_mb() 124 134 125 135 static inline void sync_ginv(void)