Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp780613lqm; Wed, 1 May 2024 16:03:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLDBeo7piV/6bbtagfNNIFKCRZByTXEf0eSyUIOBlOGig54mhcm8ic0Srh99II2nEhHBqgaI09Xsu682/QT8/+wnrphM4/hKmxHcJGYQ== X-Google-Smtp-Source: AGHT+IGqELX+WVzQYmEpAPGos+FS5kXMdzqYdZgMXTAkIsw9LsehnFM17BZ2k1PQ+/4amT4KFdEZ X-Received: by 2002:a17:902:b948:b0:1e3:cfc5:589c with SMTP id h8-20020a170902b94800b001e3cfc5589cmr4028094pls.28.1714604625391; Wed, 01 May 2024 16:03:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714604625; cv=pass; d=google.com; s=arc-20160816; b=laJ/TOlM1yEutVfaXudnAINcIjUQIiH5lO4uEzEDtYolAbYGcpROhGLyBC9baMQKa1 cyAywt1LlzUkKZw9zfq1KzbX2H128rDkm5WPMnfLKtt6oVgs/ZnYa0jboPJ+GApyjzv4 wZ3nVBZUKMDThk9KXGKLdv31+6FETCG2qvl6i/tHURMnzptt0ogZlr28jXdOGKE7ep72 ThmiTNI4C0vqJOMHOqrqUGRrIyo4rOrJkgKVEGIVrIErKCBdzkQrDrUpPHXW9+5qKs+J +dDiUpqFWpXsYgMLc0F57VGgFTEhVS4Gmhi1aKV6JV+ZV5rdt7SJejPlKhc3Jqr7HPWv ZLDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ATtWqWfgexqeSyCTJxUTsxhyKyvd1n0d0dzu8LDoTXs=; fh=Zlz3/cvqYWy6KB/xg1MK1MpG72Qtzx4fhinCkH5WKpk=; b=FoutmPb8AdNOvinv059XrcwLVd0DRD0kQ7oTEza5MULlkTLJQWIU2sK3643W5N57uE 3QGwWL5QJBE36Ub26vuAxHiZNh5z995ZXBVe8fy2KfvTSNKhMo/urIBXdkR1welJRP3I XHeccPEG2801fKaFIFi7gohMj1PrH5IFda0tGKeDEV/WHCPxwf3N5NraF4M3+Pv5TzEh DS5Qpz9Plxw+GIPkD3HKENjScjjmL1ETMXDOOqq9hlm0cP9JQu26EvF1YL4WxSxIDAGH hoe1YW7DgDjzfHgvBSmXR9ib3sleqRgRCsxDqMe0yrjzKPZrGnIS2udECzdgfqsxOzPl QiTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KOCq4831; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165803-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165803-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i17-20020a170902c95100b001eb53e073e3si9167414pla.638.2024.05.01.16.03.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 16:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165803-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KOCq4831; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165803-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165803-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F064AB220A1 for ; Wed, 1 May 2024 23:02:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A45EE16C436; Wed, 1 May 2024 23:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KOCq4831" 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 A65131311AF; Wed, 1 May 2024 23:01:32 +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=1714604492; cv=none; b=AGaaf7GVNsylR8V7G6XGHc8aH/bPlic6uGeFoeUDUmgKUd69vbAqV1bMkwHdxe4K4tUz9PK49Msu9INwXSTKB0HGuexi/2qaSn9fX99a2GOonMQJzpHOkHPBb2oLAh8AZeWMaLmZwta+VmNXVGVoOAGvtWmBNCLNYKjdbeqXccA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714604492; c=relaxed/simple; bh=1eMVNwHdcY4Pw0fbrq6XWtA7kyaxHrAZ9QJnM9orhXk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=abVhbpS4X9HeCwsF1U9Tje6cjyv+YM3JzFOqMzpPrrFnh+EWJX9+lnuZr+VTpv07VyDsbA5u8DLoHhbOAaAiu9KsnRXPADsLP2gyHbfTi7kCOvOpDPbXVp3X+pzPUcddFzumYrM2By83Lg30XqsUgTjoQB4s71Yw34u9m3Z9J98= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KOCq4831; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43539C4AF1A; Wed, 1 May 2024 23:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714604492; bh=1eMVNwHdcY4Pw0fbrq6XWtA7kyaxHrAZ9QJnM9orhXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KOCq48315zRPrdn1r25G/IMDaQzgd0easvBHNTxqNBDfhGlmbsJ9UxFy5y1b3HL9U HvSZVQHcLlFVA0CzChIcKrwP+ITv6sRLIYTBgpWdXAb4ONejc4fWbOaKmpz7cXDAJt 2fXdLNZwu4Px9MQYRwkuBPiJcqynJWHcn3GUR+Cyf5t572bfAGGIPxAAvZTjJwVSZp B45IgUsdi79yniaLQ1loLvUftAUiCPAcuTPQ7gnUy2JpdJY1K20SP8p/3dGyFxfRjl aVgwo0tuKQ3Dnm8h64piBeE/ODHpIslauoHwyROCMo+dpOfz2htLaoijr9/ijtRdW9 9pl0BvHvvFnuA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C5295CE1A05; Wed, 1 May 2024 16:01:31 -0700 (PDT) From: "Paul E. McKenney" To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Cc: elver@google.com, akpm@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, dianders@chromium.org, pmladek@suse.com, arnd@arndb.de, torvalds@linux-foundation.org, kernel-team@meta.com, Al Viro , "Paul E . McKenney" Subject: [PATCH v2 cmpxchg 04/13] sparc32: add __cmpxchg_u{8,16}() and teach __cmpxchg() to handle those sizes Date: Wed, 1 May 2024 16:01:21 -0700 Message-Id: <20240501230130.1111603-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Al Viro trivial now Signed-off-by: Al Viro Signed-off-by: Paul E. McKenney --- arch/sparc/include/asm/cmpxchg_32.h | 16 +++++++--------- arch/sparc/lib/atomic32.c | 4 ++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h index 05d5f86a56dc2..8c1a3ca34eeb7 100644 --- a/arch/sparc/include/asm/cmpxchg_32.h +++ b/arch/sparc/include/asm/cmpxchg_32.h @@ -38,21 +38,19 @@ static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ v /* bug catcher for when unsupported size is used - won't link */ void __cmpxchg_called_with_bad_pointer(void); -/* we only need to support cmpxchg of a u32 on sparc */ +u8 __cmpxchg_u8(volatile u8 *m, u8 old, u8 new_); +u16 __cmpxchg_u16(volatile u16 *m, u16 old, u16 new_); u32 __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_); /* don't worry...optimizer will get rid of most of this */ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) { - switch (size) { - case 4: - return __cmpxchg_u32(ptr, old, new_); - default: - __cmpxchg_called_with_bad_pointer(); - break; - } - return old; + return + size == 1 ? __cmpxchg_u8(ptr, old, new_) : + size == 2 ? __cmpxchg_u16(ptr, old, new_) : + size == 4 ? __cmpxchg_u32(ptr, old, new_) : + (__cmpxchg_called_with_bad_pointer(), old); } #define arch_cmpxchg(ptr, o, n) \ diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c index 0d215a772428e..8ae880ebf07aa 100644 --- a/arch/sparc/lib/atomic32.c +++ b/arch/sparc/lib/atomic32.c @@ -173,8 +173,12 @@ EXPORT_SYMBOL(sp32___change_bit); return prev; \ } +CMPXCHG(u8) +CMPXCHG(u16) CMPXCHG(u32) CMPXCHG(u64) +EXPORT_SYMBOL(__cmpxchg_u8); +EXPORT_SYMBOL(__cmpxchg_u16); EXPORT_SYMBOL(__cmpxchg_u32); EXPORT_SYMBOL(__cmpxchg_u64); -- 2.40.1