From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.mainlining.org (mail.mainlining.org [5.75.144.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D26C94DBD63; Fri, 11 Sep 2026 19:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=5.75.144.95 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789154896; cv=none; b=C2u3G6limLeA7JGDZc+spSR3vi2RnAdQmbCHB8Rn3w/D9hlOf/eTail+rrQUGvbXgoS8wXP6eyJ792IsSILvkU7XlDn35nIhbnem/kzr6xZoP2xATAjsUxXbd2ZH1vdCQcfj/pdJxhs85HsGC3K/0KSKA5NursXU4mxlpRF51js= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789154896; c=relaxed/simple; bh=OMMhULdKWAQNm6guNaaFEO5E2d3Y+6kb+rF6qcJf/JE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mplQ0Z4xyJdLgB+b4q6Yhuj8BKLGJXrGR/7h/JAhIJh+sjGBuasqf+cOLlIcSwQpHo0DpePL7s/4xbW3D1+aMN0F4vEWuDSyQswMlKywpaCvkW71IVKxgFmW5uSlcLE66GeKqN1XjByIbYeZA5V/QuySnbdRlnIVeE84dExPGg8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mainlining.org; spf=pass smtp.helo=mail.mainlining.org; arc=none smtp.client-ip=5.75.144.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mainlining.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.helo=mail.mainlining.org From: Bradley Morgan To: "Paul E. McKenney" Cc: frederic@kernel.org, neeraj.upadhyay@kernel.org, boqun@kernel.org, joelagnelf@nvidia.com, rcu@vger.kernel.org, "Andrew Morton" , "Arnd Bergmann" , linux-arch@vger.kernel.org, "Vineet Gupta" , linux-snps-arc@lists.infradead.org, "Russell King" , linux-arm-kernel@lists.infradead.org, "Guo Ren" , linux-csky@vger.kernel.org, "Yoshinori Sato" , "Rich Felker" , "John Paul Adrian Glaubitz" , linux-sh@vger.kernel.org, "Chris Zankel" , "Max Filippov" , linux-kernel@vger.kernel.org, brads@mainlining.org Subject: [PATCH 4/6] csky: Emulate two-byte cmpxchg Date: Fri, 11 Sep 2026 19:25:37 +0000 Message-ID: <20260911192540.20983-5-brads@mainlining.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260911192540.20983-1-brads@mainlining.org> References: <20260911192540.20983-1-brads@mainlining.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit csky has no byte or halfword atomic memory operations, so the __cmpxchg_relaxed(), __cmpxchg_acquire() and __cmpxchg() switches each route case 1 through cmpxchg_emu_u8() and leave case 2 to fall into the BUILD_BUG() default. Route case 2 in all three through the new cmpxchg_emu_u16(). arch_cmpxchg_local() maps to __cmpxchg_relaxed() and so picks up case 2 automatically. Signed-off-by: Bradley Morgan --- arch/csky/include/asm/cmpxchg.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/csky/include/asm/cmpxchg.h b/arch/csky/include/asm/cmpxchg.h index db6dda47184e..a6a4805064a4 100644 --- a/arch/csky/include/asm/cmpxchg.h +++ b/arch/csky/include/asm/cmpxchg.h @@ -65,6 +65,9 @@ case 1: \ __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ break; \ + case 2: \ + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u16((volatile u16 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ + break; \ case 4: \ asm volatile ( \ "1: ldex.w %0, (%3) \n" \ @@ -98,6 +101,9 @@ case 1: \ __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ break; \ + case 2: \ + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u16((volatile u16 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ + break; \ case 4: \ asm volatile ( \ "1: ldex.w %0, (%3) \n" \ @@ -132,6 +138,9 @@ case 1: \ __ret = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ break; \ + case 2: \ + __ret = (__typeof__(*(ptr)))cmpxchg_emu_u16((volatile u16 *)__ptr, (uintptr_t)__old, (uintptr_t)__new); \ + break; \ case 4: \ asm volatile ( \ RELEASE_FENCE \ -- 2.47.3