riscv/cmpxchg: Implement cmpxchg for variables of size 1 and 2
authorLeonardo Bras <leobras@redhat.com>
Wed, 3 Jan 2024 16:32:02 +0000 (13:32 -0300)
committerPalmer Dabbelt <palmer@rivosinc.com>
Mon, 8 Apr 2024 17:52:05 +0000 (10:52 -0700)
commit54280ca64626f73ce39ba8f7befa9139a6786ffd
tree385b3bd7e68255b7675876a043eb29b5dcce2c3f
parent9061237392721f0e9b399161876fa36ddb6c4226
riscv/cmpxchg: Implement cmpxchg for variables of size 1 and 2

cmpxchg for variables of size 1-byte and 2-bytes is not yet available for
riscv, even though its present in other architectures such as arm64 and
x86. This could lead to not being able to implement some locking mechanisms
or requiring some rework to make it work properly.

Implement 1-byte and 2-bytes cmpxchg in order to achieve parity with other
architectures.

Signed-off-by: Leonardo Bras <leobras@redhat.com>
Tested-by: Guo Ren <guoren@kernel.org>
Link: https://lore.kernel.org/r/20240103163203.72768-6-leobras@redhat.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/include/asm/cmpxchg.h