Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5248472rwd; Mon, 5 Jun 2023 00:11:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GkZ3m72tyE04WZdJJ5jowRlRJzhMJowUs4w/ab04t+oPjkTk4p4Kqam5C6NZv8I9DdciY X-Received: by 2002:a05:6a20:440c:b0:103:ef39:a832 with SMTP id ce12-20020a056a20440c00b00103ef39a832mr3214439pzb.23.1685949111226; Mon, 05 Jun 2023 00:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685949111; cv=none; d=google.com; s=arc-20160816; b=l95lvlX/UraNPa3w446qJbKJoxlLYvPGGK/Xb+LY9hEIS18FVS6XAEKZ/DHlZhnXUT +xkedEj0psFwOTLe90s6UljxI3HUjCAGPXSoeuI27Dq659FrJ4gLS2lBr60U3SWYcU4t TBI17/dMJpfpKhocRdu6a1wylD9Si1b/w0iA/EA9Mvv5L047IYzfjnJyrKRVPb58f50i CIMvUeCKvlw5/BvgHZKfQIS8GJ1ikzVXrT+1eGIgHKOkLaAYdyX2d85C2dgvYM7aBA7n UrA9RHH70Z/q2qdv0S5YwcqM0c9Tzs+4SeigZ33AcQKvLSZW4a4PPWhDc6TIc8TU+3JE 6VdA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a170902c40700b001afd4fceea5si5255908plk.617.2023.06.05.00.11.39; Mon, 05 Jun 2023 00:11:51 -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 S230183AbjFEHBy (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 Content-Transfer-Encoding: 8bit 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 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) \ -- 2.30.2