Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp780254lqm; Wed, 1 May 2024 16:03:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUVa8wvjWJJWsiCdKJ1eBcz++rrg/JAoNJ9Ff/mG1BO9Cz9Uv/DLtceCBYiHT/+h5RQcibwUZEhh/8CB5+a6B3OBBdtfseebSapf18U2g== X-Google-Smtp-Source: AGHT+IFNb0bQBOX0c4VzRPhDKKI24IQiBur0DyD78LF4V9QJTmzEVpq2E6Us1ITFWkGNWx0TT0VG X-Received: by 2002:a50:f613:0:b0:572:71ad:98c2 with SMTP id c19-20020a50f613000000b0057271ad98c2mr2297358edn.4.1714604586765; Wed, 01 May 2024 16:03:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714604586; cv=pass; d=google.com; s=arc-20160816; b=glAvax1AdSBCVgym3WCkCmCxBQJk82ONG+/tWSG39SU4tpfKTdIsNSkrD5CAGUdBxi wJ/WwFkctjlwydAaTqKa5KGmLfOp1FBaxBKnBGhGj0tmpvf+mPMBONCjbQzWpyfh4Mvf nXG40+PxecVTWcrJ40E2TDPo5zWrF1yBd9bGizgjSPXjvLX0tUpm0Wp57Pf1tGJkfAYo g4ZMuF9pG+DHf/C8CbcgHjj585zdeIb9hlb7BXXDEGm//+wkJJ33J//EIXXfPNVzMOCX KOM2a+OmrQ186+BYpkXteqRzXHyW9xsjDKBtWouuoYA2A+dLD/TH9h7JPYBlymcZ+/ix uRGQ== 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=GRJAFbNcr9fMJNLUAyRF/eoZR2AwOFP12VB5wZZyfFU=; fh=Zlz3/cvqYWy6KB/xg1MK1MpG72Qtzx4fhinCkH5WKpk=; b=NKwKhqad9fZSwhWzEjAQu1592AgyP+DLHcOBajSKF6NtW3cZbyKrjJYyfPJoCaK0Xl ktsb9+KPDxnOoZAy54IE7JTA2Fckq6gRu/xobNtgmfIkaNRBHXnO3HE6mBRh8F9S/CXH KHK0B2TqDGWkZspuKiBXI+8WRjYqCK9Rs8VjDOgROTntjlZZdqlswiZHK21rbMjRwsaW 5em0rWTNl6ZURGUCW7WHFBSKKoIG47H+rFbcQ9WgWuiGX6OCohomR2HiFdcckDxFO0Se lbneZ2otTb5XuNwjw1O6vgX7yuNyc1LvFmM317FplTVd3P1ATQ2l6Mk0XrGdnSNlsPPM h9xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n3zDz6zP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165804-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165804-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 n18-20020aa7d052000000b00572a7713ee7si1481082edo.686.2024.05.01.16.03.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 16:03:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165804-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=n3zDz6zP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165804-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165804-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 7E1C81F211EA for ; Wed, 1 May 2024 23:03:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B779316D9D0; Wed, 1 May 2024 23:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="n3zDz6zP" 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 D26951649A8; 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=qxJTEJhG7GFP9V0OfxhxPUaC2tdzf1dIyKwyvmGeGGLsrXxgPxa7l1euDku7YNyumttmvOttcCswS5F+YfS7Hkd44WhZOgHzbH2GSa+G39R0kr31t/wVfjJtA4Qs1arA+ufOpnfxYGzgwe5hv870iZkQO93N1Bx9dOZ1G7z7vWk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714604492; c=relaxed/simple; bh=1iPZOptm0sNwEG3zVn5V4DRrsb9XL24MUs8zOVTokRw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WFm4rzQfmQG6AewAEbk1OHpbdxjTMaah3B1MJA54jmR97T25CnZLxcp8B9EWd6azZOBInFc0ttI0kTGBW6oh/Gzh1pudqcuzGGlh4A3fGxd+7hsfwBHsIb2kY/e0PnhRSRBm/L7fMq21Z21kRTkGEGPNgW3a+WMsMm1SBrFKoBg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n3zDz6zP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85D4DC4AF50; 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=1iPZOptm0sNwEG3zVn5V4DRrsb9XL24MUs8zOVTokRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n3zDz6zPl0EBBQxLNdvQIX+Eby1w+zwffsIfLg6U+ij5N/QmU1XQwiXK8mzdUoCPR hXkYKuVJ877tCotbA3/oUlbW+zQcSkLnLU9tB2pVqDkfMKuG/XpEk8j4+UswKbWXkz Gh7m+q6FrzsmMeIHvB92ic0vQLlY19MMyFrUbthn4kHdFyKmUkuRZiKysTmvy4E6ex MEuLgxJ+FWey566gz16YatvbKvrpCW7XB+vl3xqEltWtUC9ZLHjLASvEpg0D9aYwLl WpKcCSOaSqtrfjWs/VtmOiZXEkDaeV5yW9tXEVLlWvGiS4oepBkg4BPr6IbtEwrqKX iRVW7BMQR2lBg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D06A6CE2279; 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 08/13] parisc: add u16 support to cmpxchg() Date: Wed, 1 May 2024 16:01:25 -0700 Message-Id: <20240501230130.1111603-8-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 Add (and export) __cmpxchg_u16(), teach __cmpxchg() to use it. And get rid of manual truncation down to u8, etc. in there - the only reason for those is to avoid bogus warnings about constant truncation from sparse, and those are easy to avoid by turning that switch into conditional expression. Signed-off-by: Al Viro Signed-off-by: Paul E. McKenney --- arch/parisc/include/asm/cmpxchg.h | 19 +++++++++---------- arch/parisc/kernel/parisc_ksyms.c | 1 + arch/parisc/lib/bitops.c | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/parisc/include/asm/cmpxchg.h b/arch/parisc/include/asm/cmpxchg.h index 0924ebc576d28..bf0a0f1189eb2 100644 --- a/arch/parisc/include/asm/cmpxchg.h +++ b/arch/parisc/include/asm/cmpxchg.h @@ -56,25 +56,24 @@ __arch_xchg(unsigned long x, volatile void *ptr, int size) /* bug catcher for when unsupported size is used - won't link */ extern void __cmpxchg_called_with_bad_pointer(void); -/* __cmpxchg_u32/u64 defined in arch/parisc/lib/bitops.c */ +/* __cmpxchg_u... defined in arch/parisc/lib/bitops.c */ +extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new_); +extern u16 __cmpxchg_u16(volatile u16 *ptr, u16 old, u16 new_); extern u32 __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_); extern u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new_); -extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 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) { + return #ifdef CONFIG_64BIT - case 8: return __cmpxchg_u64((u64 *)ptr, old, new_); + size == 8 ? __cmpxchg_u64(ptr, old, new_) : #endif - case 4: return __cmpxchg_u32((unsigned int *)ptr, - (unsigned int)old, (unsigned int)new_); - case 1: return __cmpxchg_u8((u8 *)ptr, old & 0xff, new_ & 0xff); - } - __cmpxchg_called_with_bad_pointer(); - return old; + size == 4 ? __cmpxchg_u32(ptr, old, new_) : + size == 2 ? __cmpxchg_u16(ptr, old, new_) : + size == 1 ? __cmpxchg_u8(ptr, old, new_) : + (__cmpxchg_called_with_bad_pointer(), old); } #define arch_cmpxchg(ptr, o, n) \ diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c index dcf61cbd31470..c1587aa35beb6 100644 --- a/arch/parisc/kernel/parisc_ksyms.c +++ b/arch/parisc/kernel/parisc_ksyms.c @@ -23,6 +23,7 @@ EXPORT_SYMBOL(memset); EXPORT_SYMBOL(__xchg8); EXPORT_SYMBOL(__xchg32); EXPORT_SYMBOL(__cmpxchg_u8); +EXPORT_SYMBOL(__cmpxchg_u16); EXPORT_SYMBOL(__cmpxchg_u32); EXPORT_SYMBOL(__cmpxchg_u64); #ifdef CONFIG_SMP diff --git a/arch/parisc/lib/bitops.c b/arch/parisc/lib/bitops.c index cae30a3eb6d9b..9df8100506427 100644 --- a/arch/parisc/lib/bitops.c +++ b/arch/parisc/lib/bitops.c @@ -71,4 +71,5 @@ unsigned long notrace __xchg8(char x, volatile char *ptr) CMPXCHG(u64) CMPXCHG(u32) +CMPXCHG(u16) CMPXCHG(u8) -- 2.40.1