From patchwork Mon Jun 5 07:01:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 103127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2501140vqr; Mon, 5 Jun 2023 00:12:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ALK1RQgTx7LijiuCAUNunKd2xUU/zFxASHuvpOF8JSmJkGCGToUdHd8P3CZou1AVg8QUJ X-Received: by 2002:a17:902:a9c6:b0:1a6:4a64:4d27 with SMTP id b6-20020a170902a9c600b001a64a644d27mr3028652plr.40.1685949125368; Mon, 05 Jun 2023 00:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685949125; cv=none; d=google.com; s=arc-20160816; b=iRPO82s7p24C7yneUCQPUI/mnF5UgV0fHrKWbkM8JCqHVa2KuqkjGCDuTuL4/UVOcp 5R97z34/Ddv8OgpGGwK4LFZo937/uRpVxbuJZbw22xvTCgOCWTAycnXWir7fBflRPwnz l2xwmE55fp0ovc2nJqj4KBl/KDDV0/9J/ofHxnj+sUZF9TR3hEu+Q80aTwJGve6fbQRs Z1TIC5sgWXCdiEfYT+IYNyteaGzfP46Z/IM31yZfY55v7leWXd2bcbKWm3GJHC2j5awn 27X66kQouA1dDLYvz73KHW5ahq409F4uMYNl+Ov+p0tEDZ/Or1D47KxzuvuTMnNaaBft U3Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1BkVbnQZF2zefeq5gO1cba1/ZPxFNjg0VV6FmzuUNPo=; b=UyMg3amEBqzwgyUE0K2oX1xyuXooXwa8RtxDHsTobrfRqCse2R5oKJ7gelG5XsKxR0 SzPa3Ux/BPCXIhcmlBOp2abw9ppwqYGEmVGEvA/7KVy/yVfcbtraL3VKg4XGXHrOoCXG J/mJ0fqlOrwUixc+BzbcYP+yKhLKnEDwWFryjPIWaDe/2LwBl6pdlR0wDYcRL5qmrTzY 1t7bW7IBN3XEpB+OQGM4VKCwPgUHx38D7ohZGxm8ieNlnVrj9fHm1JBo6epzC7SnTtTX Dbu7YcT6ghHCeTSwgTnDaGTV05lbkDcMEq6WNtXNeWR9+HKSIHvq8p4QLpT0XZ1yy3Ho +5rg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p14-20020a170902e74e00b001ab0727a2c0si5225093plf.424.2023.06.05.00.11.53; Mon, 05 Jun 2023 00:12:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbjFEHBy (ORCPT + 99 others); Mon, 5 Jun 2023 03:01:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbjFEHBk (ORCPT ); Mon, 5 Jun 2023 03:01:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED8BC9F; Mon, 5 Jun 2023 00:01:38 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 459C615A1; Mon, 5 Jun 2023 00:02:24 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0103D3F793; Mon, 5 Jun 2023 00:01:36 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: akiyks@gmail.com, boqun.feng@gmail.com, corbet@lwn.net, keescook@chromium.org, linux@armlinux.org.uk, linux-doc@vger.kernel.org, mark.rutland@arm.com, mchehab@kernel.org, paulmck@kernel.org, peterz@infradead.org, rdunlap@infradead.org, sstabellini@kernel.org, will@kernel.org Subject: [PATCH v2 03/27] locking/atomic: hexagon: remove redundant arch_atomic_cmpxchg Date: Mon, 5 Jun 2023 08:01:00 +0100 Message-Id: <20230605070124.3741859-4-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230605070124.3741859-1-mark.rutland@arm.com> References: <20230605070124.3741859-1-mark.rutland@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767845790356446217?= X-GMAIL-MSGID: =?utf-8?q?1767845790356446217?= Hexagon's implementation of arch_atomic_cmpxchg() is identical to its implementation of arch_cmpxchg(). Have it define arch_atomic_cmpxchg() in terms of arch_cmpxchg(), matching what it does for arch_atomic_xchg() and arch_xchg(). At the same time, remove the kerneldoc comments for hexagon's arch_atomic_xchg() and arch_atomic_cmpxchg(). The arch_atomic_*() namespace is shared by all architectures and the API should be documented centrally, and the comments aren't all that helpful as-is. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Reviewed-by: Kees Cook Cc: Boqun Feng Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Will Deacon --- arch/hexagon/include/asm/atomic.h | 46 +++---------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/arch/hexagon/include/asm/atomic.h b/arch/hexagon/include/asm/atomic.h index 6e94f8d04146f..738857e10d6ec 100644 --- a/arch/hexagon/include/asm/atomic.h +++ b/arch/hexagon/include/asm/atomic.h @@ -36,49 +36,11 @@ static inline void arch_atomic_set(atomic_t *v, int new) */ #define arch_atomic_read(v) READ_ONCE((v)->counter) -/** - * arch_atomic_xchg - atomic - * @v: pointer to memory to change - * @new: new value (technically passed in a register -- see xchg) - */ -#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), (new))) - - -/** - * arch_atomic_cmpxchg - atomic compare-and-exchange values - * @v: pointer to value to change - * @old: desired old value to match - * @new: new value to put in - * - * Parameters are then pointer, value-in-register, value-in-register, - * and the output is the old value. - * - * Apparently this is complicated for archs that don't support - * the memw_locked like we do (or it's broken or whatever). - * - * Kind of the lynchpin of the rest of the generically defined routines. - * Remember V2 had that bug with dotnew predicate set by memw_locked. - * - * "old" is "expected" old val, __oldval is actual old value - */ -static inline int arch_atomic_cmpxchg(atomic_t *v, int old, int new) -{ - int __oldval; +#define arch_atomic_xchg(v, new) \ + (arch_xchg(&((v)->counter), (new))) - asm volatile( - "1: %0 = memw_locked(%1);\n" - " { P0 = cmp.eq(%0,%2);\n" - " if (!P0.new) jump:nt 2f; }\n" - " memw_locked(%1,P0) = %3;\n" - " if (!P0) jump 1b;\n" - "2:\n" - : "=&r" (__oldval) - : "r" (&v->counter), "r" (old), "r" (new) - : "memory", "p0" - ); - - return __oldval; -} +#define arch_atomic_cmpxchg(v, old, new) \ + (arch_cmpxchg(&((v)->counter), (old), (new))) #define ATOMIC_OP(op) \ static inline void arch_atomic_##op(int i, atomic_t *v) \