Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1510022lqe; Mon, 8 Apr 2024 10:51:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUObWXx2/xwog0S102N4lWKG7d8Vhf3XcjSfy2GEGHY3A6idgExutA7bxQ+evrDjOPVzNalyU2pbMHfcv9XF5t9VW1n2hgKpLm00/0oMQ== X-Google-Smtp-Source: AGHT+IEB7CnY1d3luU/1cywD80+Ix53SapmqckVvIcJfAPIbXQt4Ug7I68eoHvDeol2KTG3c5xwv X-Received: by 2002:a17:907:2da4:b0:a51:c332:45b5 with SMTP id gt36-20020a1709072da400b00a51c33245b5mr5578708ejc.7.1712598718848; Mon, 08 Apr 2024 10:51:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712598718; cv=pass; d=google.com; s=arc-20160816; b=jxgRhlPSa2/FfWQFNeCUYtSEYwCqHsOR0qcfsBK+AR9x2OOIvi6XEZBV5ycfy24LJP CAQ2h4uxZCamYB3swsYOF471Kd7wFU0S67CDqdG+w28R2dtFW7bN+c7JweZ/ns6JA4EE 9xEDfQ7AssJWCg7klYtG/OTZO28AqFWsarmO7nHDmBP59oYNsioyOgPDyJ9InB7WSTfJ XznuohVhVpGs4m6K5l9OxQX+dHIHdM70llOPChs8EIHW4Q+wTbla25DmP8XLsYmhf/mi kLl3S675MIvfx3segscru8ObqnC4lBvlZBkY1qdpFOv7kwE06+LU1viNKPZui+BvsmV/ VCHg== 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=w9S2XPug8Iuwyxj1huAxJ8xgXHl/EkJ/564y4G32wHQ=; b=I6sJPklQkWnjx5qaTjHb0uXPqaclSrUn/bcKw14Iu0WaX/btF+nMnr2tvXG9MMcUGC Y4JShu5BQb1sQXUtU92w1A0325zWVyfjE9ymegEGRIleMCLcC5SmA1p5Z+yp1Ifaiddw GN6I8NwF1RLAGxqI0NcT6hg5TSwXHk8mfm3mxXLl7dIHUv8pboyRXeCHO/dpSEI7sxcz CB3Jgc2C8qOVjHSS7RKwZt51FR6xrUQhW81kgCkrP+YgXF6PttzKfl7Gde9hkII6baT2 NR0h0b08ddtVIpmazaNnahikAk8lHoib4K3v/4JQsOhcDOFgG7rAeowcuX+mWoXXRGVG ph4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HeYHevdH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135776-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ku24-20020a170907789800b00a51b372579fsi3130624ejc.933.2024.04.08.10.51.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 10:51:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135776-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HeYHevdH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135776-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135776-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9132F1F223D3 for ; Mon, 8 Apr 2024 17:51:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F06BE1482F5; Mon, 8 Apr 2024 17:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HeYHevdH" 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 288261442F6; Mon, 8 Apr 2024 17:49:46 +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=1712598587; cv=none; b=JyWXVZN0ZWQDO1P7L7neLbKICLrmBYFzi/h1CVyAM/0WQ3Np8OtNj9++z4huwa0JEu+AjtxHBwmASnvBuYNJmjuHLaP11pSOPA5BgK7fjioDRHvRDO8zTLzi5X31RDrFxJTgpNBU5ETGsWyVIeEqw47ZDen3G1jcnpJjvkjO7DU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712598587; c=relaxed/simple; bh=1eMVNwHdcY4Pw0fbrq6XWtA7kyaxHrAZ9QJnM9orhXk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BKuUFGuIe11FC3PZRkA9byi1nVHJ7wXZvdUrkuvHqDBWAZH7L/XMUm3iFXWq5hrkk/KI7MfzBNtU3QN4nZyDFg7B24mTLYdf0trqWxLTedt9wxQPRfc+X+4/1CdhzHvBTM5Lr+uGYAOWGti7t0tmsmK9Rj1rXMjnw/RiXOlwsbQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HeYHevdH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4E5EC433B1; Mon, 8 Apr 2024 17:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712598586; bh=1eMVNwHdcY4Pw0fbrq6XWtA7kyaxHrAZ9QJnM9orhXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HeYHevdHb8JNXD8d+3/qaLhicozT5IGtyN9Qef0TyneWBFJ22cJV4JHfQoFh0QRcD oe+SVtnLcXDJYNdqIIUqmkjLW6TZVO7OjG2QAbgZ9lEplrJwWTxYxl3fM2+I9Kc4Ax K9LjmkGODfvg7Rla6D68L6uHrQOGk+fYzub6X0Wz2xwjPUpNJXCkmxi1YYTLYbDOxp UJMLgod3VW82wczSxpVQjO1Rr09JLyqPrRYRYcUYveWf1THGvUJ7umoBr1M5NXNV1o Nl0cVZCv9BjbP5Sp3o9riilb5X+JwdyvbeeBni+Bo10yUOVg9MZjpGw/sCGNHYHWeO 5bLbVpDfqwWDQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 444CACE1979; Mon, 8 Apr 2024 10:49:46 -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, torvalds@linux-foundation.org, Arnd Bergmann , Al Viro , "Paul E . McKenney" Subject: [PATCH cmpxchg 04/14] sparc32: add __cmpxchg_u{8,16}() and teach __cmpxchg() to handle those sizes Date: Mon, 8 Apr 2024 10:49:34 -0700 Message-Id: <20240408174944.907695-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <7b3646e0-667c-48e2-8f09-e493c43c30cb@paulmck-laptop> References: <7b3646e0-667c-48e2-8f09-e493c43c30cb@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: 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