[PATCH 6/6] xtensa: Emulate two-byte cmpxchg

From: Bradley Morgan

Date: Fri Sep 11 2026 - 15:33:13 EST


Xtensa has no byte or halfword atomic memory operations, so the
__cmpxchg() switch routes case 1 through cmpxchg_emu_u8() and
lets case 2 hit the default, __cmpxchg_called_with_bad_pointer(),
which is declared but never defined, so a two-byte cmpxchg() fails
at link time. Route case 2 through the new cmpxchg_emu_u16().

Signed-off-by: Bradley Morgan <brads@xxxxxxxxxxxxxx>
---
arch/xtensa/include/asm/cmpxchg.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/xtensa/include/asm/cmpxchg.h b/arch/xtensa/include/asm/cmpxchg.h
index b6db4838b175..8dea8e357fc0 100644
--- a/arch/xtensa/include/asm/cmpxchg.h
+++ b/arch/xtensa/include/asm/cmpxchg.h
@@ -76,6 +76,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
{
switch (size) {
case 1: return cmpxchg_emu_u8(ptr, old, new);
+ case 2: return cmpxchg_emu_u16(ptr, old, new);
case 4: return __cmpxchg_u32(ptr, old, new);
default: __cmpxchg_called_with_bad_pointer();
return old;
--
2.47.3