Skip to contentSkip to conversation

riscv/atomic.h : use RISCV_FULL_BARRIER in _arch_atomic* function.

PATCH Applied Zongmin Zhou 2 participants 2 messages Nov 20, 2025 – Nov 26, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv/atomic.h : use RISCV_FULL_BARRIER in _arch_atomic* function.

From: Zongmin Zhou <[email protected]>

Replace the same code with the pre-defined macro
RISCV_FULL_BARRIER to simplify the code.

---
 arch/riscv/include/asm/atomic.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/riscv/include/asm/atomic.h +4 -4
index 5b96c2f61adb..3f33dc54f94b 100644
@@ -203,7 +203,7 @@ ATOMIC_OPS(xor, xor, i)
 		"	add            %[rc], %[p], %[a]\n"		\
 		"	sc." sfx ".rl  %[rc], %[rc], %[c]\n"		\
 		"	bnez           %[rc], 0b\n"			\
-		"	fence          rw, rw\n"			\
+		RISCV_FULL_BARRIER					\
 		"1:\n"							\
 		: [p]"=&r" (_prev), [rc]"=&r" (_rc), [c]"+A" (counter)	\
 		: [a]"r" (_a), [u]"r" (_u)				\
@@ -242,7 +242,7 @@ static __always_inline s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a,
 		"	addi            %[rc], %[p], 1\n"		\
 		"	sc." sfx ".rl   %[rc], %[rc], %[c]\n"		\
 		"	bnez            %[rc], 0b\n"			\
-		"	fence           rw, rw\n"			\
+		RISCV_FULL_BARRIER					\
 		"1:\n"							\
 		: [p]"=&r" (_prev), [rc]"=&r" (_rc), [c]"+A" (counter)	\
 		:							\
@@ -268,7 +268,7 @@ static __always_inline bool arch_atomic_inc_unless_negative(atomic_t *v)
 		"	addi            %[rc], %[p], -1\n"		\
 		"	sc." sfx ".rl   %[rc], %[rc], %[c]\n"		\
 		"	bnez            %[rc], 0b\n"			\
-		"	fence           rw, rw\n"			\
+		RISCV_FULL_BARRIER					\
 		"1:\n"							\
 		: [p]"=&r" (_prev), [rc]"=&r" (_rc), [c]"+A" (counter)	\
 		:							\
@@ -294,7 +294,7 @@ static __always_inline bool arch_atomic_dec_unless_positive(atomic_t *v)
 		"	bltz           %[rc], 1f\n"			\
 		"	sc." sfx ".rl  %[rc], %[rc], %[c]\n"		\
 		"	bnez           %[rc], 0b\n"			\
-		"	fence          rw, rw\n"			\
+		RISCV_FULL_BARRIER					\
 		"1:\n"							\
 		: [p]"=&r" (_prev), [rc]"=&r" (_rc), [c]"+A" (counter)	\
 		:							\
Signature · 1 line
2.34.1
#1 lore raw
This patch was applied to riscv/linux.git (for-next) by Paul Walmsley <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (for-next) by Paul Walmsley <[email protected]>:

Quoted 8 lines · On Thu, 20 Nov 2025 17:58:31 +0800 you wrote:

From: Zongmin Zhou <[email protected]>

Replace the same code with the pre-defined macro
RISCV_FULL_BARRIER to simplify the code.

[...]

Here is the summary with links:
- riscv/atomic.h : use RISCV_FULL_BARRIER in _arch_atomic* function.

    https://git.kernel.org/riscv/c/c0fe46b64f12

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html