]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
riscv: cmpxchg: Use riscv_has_extension_likely
authorVivian Wang <wangruikang@iscas.ac.cn>
Tue, 18 Nov 2025 04:19:23 +0000 (21:19 -0700)
committerPaul Walmsley <pjw@kernel.org>
Wed, 19 Nov 2025 16:19:28 +0000 (09:19 -0700)
Use riscv_has_extension_likely() to check for RISCV_ISA_EXT_ZAWRS,
replacing the use of asm goto with ALTERNATIVE.

The "likely" variant is used to match the behavior of the original
implementation using ALTERNATIVE("j %l[no_zawrs]", "nop", ...).

Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Link: https://patch.msgid.link/20251020-riscv-altn-helper-wip-v4-5-ef941c87669a@iscas.ac.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/include/asm/cmpxchg.h

index 122e1485d39a0ad44ec4357cb23148dc6e58dc6b..8712cf9c69dcb3690058c60e60481fc4c3ffea06 100644 (file)
@@ -373,9 +373,10 @@ static __always_inline void __cmpwait(volatile void *ptr,
        u32 *__ptr32b;
        ulong __s, __val, __mask;
 
-       asm goto(ALTERNATIVE("j %l[no_zawrs]", "nop",
-                            0, RISCV_ISA_EXT_ZAWRS, 1)
-                : : : : no_zawrs);
+       if (!riscv_has_extension_likely(RISCV_ISA_EXT_ZAWRS)) {
+               ALT_RISCV_PAUSE();
+               return;
+       }
 
        switch (size) {
        case 1:
@@ -437,11 +438,6 @@ static __always_inline void __cmpwait(volatile void *ptr,
        default:
                BUILD_BUG();
        }
-
-       return;
-
-no_zawrs:
-       ALT_RISCV_PAUSE();
 }
 
 #define __cmpwait_relaxed(ptr, val) \