Skip to content

Commit af042c4

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Do not fail to build on byte/halfword operations with Zawrs
riscv does not have lr instructions on byte and halfword but the qspinlock implementation actually uses such atomics provided by the Zabha extension, so those sizes are legitimate. Then instead of failing to build, just fallback to the !Zawrs path. Signed-off-by: Alexandre Ghiti <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Andrea Parri <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 010e12a commit af042c4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/riscv/include/asm/cmpxchg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ static __always_inline void __cmpwait(volatile void *ptr,
245245
: : : : no_zawrs);
246246

247247
switch (size) {
248+
case 1:
249+
fallthrough;
250+
case 2:
251+
/* RISC-V doesn't have lr instructions on byte and half-word. */
252+
goto no_zawrs;
248253
case 4:
249254
asm volatile(
250255
" lr.w %0, %1\n"

0 commit comments

Comments
 (0)