From nobody Mon Feb 9 01:08:15 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 780F41B2EEF; Wed, 21 Aug 2024 18:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263813; cv=none; b=pQ404HRjvn7XPOVGRNCXrqyMydY8YYl/DwPyzj4WGbAEuLzRSoVyCXGR98j9Bt5zOMrDYMeoRGMhmKW2AIVwNwpOqyQpAx0/EfCfeJychBDZJnq2xkqV438I84j/KDrK+hgyx8JL2xA5e61scBCHIMF3fCIG25b9/G+ru8GssAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263813; c=relaxed/simple; bh=SsfSYlvMJfbrFJhxWSLRoEWcjcncMnxVxwE9E1US2+0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UnOTh7F8Bqsip4OX7ZDEshZpHogMYS7OUW6T+ENVVAQZIvts+qn3uQ1rawaE9etvjh9NbZ72GgUEVF1pk/c8RaR1moCATbZD/ZA4UjQX5kEieWQ566iaLDZy9LXaWHSV6DplKF0FexHuehNNrFjbsqVT2zZRndGUguVFpJuGv9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mi8hKXWv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mi8hKXWv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26FEAC4AF09; Wed, 21 Aug 2024 18:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724263813; bh=SsfSYlvMJfbrFJhxWSLRoEWcjcncMnxVxwE9E1US2+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mi8hKXWvAOjmdqCKmwwPBuyC/Bi6ih8OGQOxWRnoREf7UzDrED43aPxGGpuM65Q5e PCujx8KWqnrkuVLpxYriJVGOqPZ+8wfc3GdKh4jIn2YtEOi+ah6HZl/kvRWfs3/cxI idoK/rTHjBnwoapgNadhElunGQsTA8pLce86C5iLsNwUVfi4fCH6NaW2Vfnx/mHEIE cmiiHDwaROmnKcVr1+YfAxefVzg/g+yks0Nk+iPy8f9EKHEgWWdUdODMpX6OEg78wF BUK/jBh39c9QkUWK1AmQKaSFN1luClo/Xm40/YUORWOazweQe1W69LGIhbiUJIBYZn 5JPMRv+hEjM3g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B99BDCE160F; Wed, 21 Aug 2024 11:10:12 -0700 (PDT) From: "Paul E. McKenney" To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, elver@google.com Cc: akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, arnd@arndb.de, geert@linux-m68k.org, kernel-team@meta.com, "Paul E. McKenney" , Yujie Liu , Andi Shyti Subject: [PATCH v2 cmpxchg 1/3] xtensa: Emulate one-byte cmpxchg Date: Wed, 21 Aug 2024 11:10:09 -0700 Message-Id: <20240821181011.2604152-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <04a6010c-536d-4906-bf7c-b2335a2f54b0@paulmck-laptop> References: <04a6010c-536d-4906-bf7c-b2335a2f54b0@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on xtensa. [ paulmck: Apply kernel test robot feedback. ] [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] [ Apply Geert Uytterhoeven feedback. ] Signed-off-by: Paul E. McKenney Tested-by: Yujie Liu Cc: Andi Shyti Cc: Geert Uytterhoeven Cc: Arnd Bergmann Cc: "Peter Zijlstra (Intel)" --- arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/cmpxchg.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index f200a4ec044e6..d3db28f2f8110 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -14,6 +14,7 @@ config XTENSA select ARCH_HAS_DMA_SET_UNCACHED if MMU select ARCH_HAS_STRNCPY_FROM_USER if !KASAN select ARCH_HAS_STRNLEN_USER + select ARCH_NEED_CMPXCHG_1_EMU select ARCH_USE_MEMTEST select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_SPINLOCKS diff --git a/arch/xtensa/include/asm/cmpxchg.h b/arch/xtensa/include/asm/cm= pxchg.h index 675a11ea8de76..95e33a913962d 100644 --- a/arch/xtensa/include/asm/cmpxchg.h +++ b/arch/xtensa/include/asm/cmpxchg.h @@ -15,6 +15,7 @@ =20 #include #include +#include =20 /* * cmpxchg @@ -74,6 +75,7 @@ static __inline__ unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int si= ze) { switch (size) { + case 1: return cmpxchg_emu_u8(ptr, old, new); case 4: return __cmpxchg_u32(ptr, old, new); default: __cmpxchg_called_with_bad_pointer(); return old; --=20 2.40.1 From nobody Mon Feb 9 01:08:15 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7814B1B2EF6; Wed, 21 Aug 2024 18:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263813; cv=none; b=CWaNvZ76+E5sTI9NZTgapeEkqUr31+76AyFSb2iDYrNrjNyr4cf+KGvu0ssA4hJRLX6XhE5wMg9LDJe5AwvlnwdX9RK5HgcOFYlVrBhUQQMq4H0EXl5DH+jRdCs7Mij5/UMWYBoqYGHshctEQedZ3d3ZLazHz8GGU6uC5BK2IQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263813; c=relaxed/simple; bh=A1ZjBdu0p6P+IfhPi1T9QOGeX9FqrNLLWzvUxef5bSI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C4whzenAtOjp0abX8liVMR40Gv4nsZS8R7aCXMgLkijfJre6AWbZse94ahKSM9CiJ/5clFyqNRfV01vbYXboYMAMPU0YfKK8BUUmP9xx1zPzdG9ZzLL8I9Zood7FA1F8Zn1UWvbv2atSHrgbWz8STvXn/pfOEmaONfdmpSqYw6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p0WM9A7x; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p0WM9A7x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 245EFC32781; Wed, 21 Aug 2024 18:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724263813; bh=A1ZjBdu0p6P+IfhPi1T9QOGeX9FqrNLLWzvUxef5bSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0WM9A7xqkbJ6V3TFxkE1zg7hMdY2wf0H9wXcOs8gMzvp7Iuk1RJaGYFlEKX9cMMl oKaSRU0xlpu16fsdGn7pWF3fdq9tpzBJP6HY2YsyHJ+J7nUezAZ4RvoztGhLCd90up SlOPfEwWr7Pk0kbAoac0W+9e67Z31gHtrscgYABO/J8GJs0bYAR8JjIAzisbAZxK7e nNrRtkP1o+NVzyjbp1uq/MHDi6N7ROLxiKSo9BBMr6KzL9E/pmYcGB1qV2gXw/Hzlt So7DeRzdIHynDMUfXd5FKB0iCyMtSalpOla5cFOAgSlTtnzqNWsiC/J6DruxQewb3S V5PJ5HlxDCI/g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id BCD68CE16C1; Wed, 21 Aug 2024 11:10:12 -0700 (PDT) From: "Paul E. McKenney" To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, elver@google.com Cc: akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, arnd@arndb.de, geert@linux-m68k.org, kernel-team@meta.com, "Paul E. McKenney" , Andi Shyti , Andrzej Hajda , Palmer Dabbelt , linux-snps-arc@lists.infradead.org, Vineet Gupta Subject: [PATCH v2 cmpxchg 2/3] ARC: Emulate one-byte cmpxchg Date: Wed, 21 Aug 2024 11:10:10 -0700 Message-Id: <20240821181011.2604152-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <04a6010c-536d-4906-bf7c-b2335a2f54b0@paulmck-laptop> References: <04a6010c-536d-4906-bf7c-b2335a2f54b0@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on arc. [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] [ paulmck: Apply feedback from Naresh Kamboju. ] [ paulmck: Apply kernel test robot feedback. ] [ paulmck: Apply feedback from Vineet Gupta. ] Signed-off-by: Paul E. McKenney Cc: Andi Shyti Cc: Andrzej Hajda Cc: Arnd Bergmann Cc: Palmer Dabbelt Cc: Acked-by: Vineet Gupta --- arch/arc/Kconfig | 1 + arch/arc/include/asm/cmpxchg.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index fd0b0a0d4686a..163608fd49d18 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -13,6 +13,7 @@ config ARC select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_NEED_CMPXCHG_1_EMU select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC select ARCH_32BIT_OFF_T select BUILDTIME_TABLE_SORT diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h index e138fde067dea..58045c8983404 100644 --- a/arch/arc/include/asm/cmpxchg.h +++ b/arch/arc/include/asm/cmpxchg.h @@ -8,6 +8,7 @@ =20 #include #include +#include =20 #include #include @@ -46,6 +47,9 @@ __typeof__(*(ptr)) _prev_; \ \ switch(sizeof((_p_))) { \ + case 1: \ + _prev_ =3D (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)_p_, (uintp= tr_t)_o_, (uintptr_t)_n_); \ + break; \ case 4: \ _prev_ =3D __cmpxchg(_p_, _o_, _n_); \ break; \ @@ -65,8 +69,6 @@ __typeof__(*(ptr)) _prev_; \ unsigned long __flags; \ \ - BUILD_BUG_ON(sizeof(_p_) !=3D 4); \ - \ /* \ * spin lock/unlock provide the needed smp_mb() before/after \ */ \ --=20 2.40.1 From nobody Mon Feb 9 01:08:15 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5B3171B2EE2; Wed, 21 Aug 2024 18:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263813; cv=none; b=t82yHDDB3NFEEL/dtI+6ccQMU95TR692Jw5aCpapeaqkksjJAg4kiw9WizlATHVjuSAkhTaU/ezdBDy7jxKY/EdUyoJobLa3ZoWTYMjOQ3WaqmYO5uYh4SKmNjIfW8+QyaMV7l9l+0s2lknVhxHkVhlMssy84McFePPvQ/1GlZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724263813; c=relaxed/simple; bh=rRjox4fY0egq63DbDfR2UVfQKrpoEipdNtPZ92fJEcw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CnWXTODCUdK7uCrPqJTenh/U/OxpW1uX1ML1a/DNBQTuADKiP+WPPjnCx6pliObtY/7Dz3iPeOf3q2BviYc/WHuPogmCoBlRCfXsmffobhvocPoHLpponIpkovelwq9Knr9DudHkssp2uEMzLj0vgDFh3vrXHCxC6ClpFSlSJfw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ml6UOk07; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ml6UOk07" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 315AEC4AF0E; Wed, 21 Aug 2024 18:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724263813; bh=rRjox4fY0egq63DbDfR2UVfQKrpoEipdNtPZ92fJEcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ml6UOk07YO3enrVKQ0NNvDl9iFc3hFp4f1iRte27zuWvaJhi3eZYvzOkIXMwf2jtY keMUS1yVsT+NdB9i0aillOCvpZhd0/wbKYrOEs1TX2q6t/7Exj6ZfIf+gYF+NyWNP9 DGb3HZj3ZOkWwN1Mw8swjA3a8trSybB24Pgs4EkngRtNkvjPHi0/tARtCFE/2LF3U3 QF5FtUkk9Icwxut7BsViLwZUblDd+5qW3wP1nW9bYoOZ2ZbvUv10LBKOUjnRODkSrl 7eIzte7H+FM/aY1HJf8LjAR6Xa4bif9gk86LcblyVuRMBs9HiiWCgkYd6L+xO2GQur e63b+kYObalcg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id BFF71CE16C8; Wed, 21 Aug 2024 11:10:12 -0700 (PDT) From: "Paul E. McKenney" To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, elver@google.com Cc: akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, arnd@arndb.de, geert@linux-m68k.org, kernel-team@meta.com, "Paul E. McKenney" , Andi Shyti , Palmer Dabbelt , Masami Hiramatsu , linux-sh@vger.kernel.org, John Paul Adrian Glaubitz Subject: [PATCH v2 cmpxchg 3/3] sh: Emulate one-byte cmpxchg Date: Wed, 21 Aug 2024 11:10:11 -0700 Message-Id: <20240821181011.2604152-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <04a6010c-536d-4906-bf7c-b2335a2f54b0@paulmck-laptop> References: <04a6010c-536d-4906-bf7c-b2335a2f54b0@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the new cmpxchg_emu_u8() to emulate one-byte cmpxchg() on sh. [ paulmck: Drop two-byte support per Arnd Bergmann feedback. ] [ paulmck: Apply feedback from Naresh Kamboju. ] [ Apply Geert Uytterhoeven feedback. ] Signed-off-by: Paul E. McKenney Cc: Andi Shyti Cc: Palmer Dabbelt Cc: Masami Hiramatsu Cc: Arnd Bergmann Cc: Acked-by: John Paul Adrian Glaubitz --- arch/sh/Kconfig | 1 + arch/sh/include/asm/cmpxchg.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 1aa3c4a0c5b27..e9103998cca91 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -14,6 +14,7 @@ config SUPERH select ARCH_HIBERNATION_POSSIBLE if MMU select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_WANT_IPC_PARSE_VERSION + select ARCH_NEED_CMPXCHG_1_EMU select CPU_NO_EFFICIENT_FFS select DMA_DECLARE_COHERENT select GENERIC_ATOMIC64 diff --git a/arch/sh/include/asm/cmpxchg.h b/arch/sh/include/asm/cmpxchg.h index 5d617b3ef78f7..1e5dc5ccf7bf5 100644 --- a/arch/sh/include/asm/cmpxchg.h +++ b/arch/sh/include/asm/cmpxchg.h @@ -9,6 +9,7 @@ =20 #include #include +#include =20 #if defined(CONFIG_GUSA_RB) #include @@ -56,6 +57,8 @@ static inline unsigned long __cmpxchg(volatile void * ptr= , unsigned long old, unsigned long new, int size) { switch (size) { + case 1: + return cmpxchg_emu_u8(ptr, old, new); case 4: return __cmpxchg_u32(ptr, old, new); } --=20 2.40.1