From patchwork Mon May 22 12:24:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 97423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1429028vqo; Mon, 22 May 2023 06:01:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4WlzSc4c/RNe+P4gNxv5I9C7Ler/9Rz10c0rlTARPQnL1qFMQiq4u9TQmEgibXbOmTlLua X-Received: by 2002:a17:902:da88:b0:1ae:4562:14f1 with SMTP id j8-20020a170902da8800b001ae456214f1mr13869503plx.9.1684760483536; Mon, 22 May 2023 06:01:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684760483; cv=none; d=google.com; s=arc-20160816; b=N0VEXLdjuzDJAU7PJYC4RSnJWTKr8T0QolH5AVY5HldMY827zXww+7hwL7PITFaCAv b3QflWmM1QCStpkS53y5P/gJCM95amC/zBZJXwIcFG+RGItjMBmeCc4+Chl6E5RuvkpM KFsR+dHbirA/Qw5oh3j6jj6+VP5Cup7kmTcPNqFYVaFmq3RhH+hXyPPi7iS9lr1g3fIG AYA6tGbdGlsr8GIrFZ/VL/Xo9ef2bRzerhWO2e4nuK2U2XBH/K9vl2rMxwl3KY8Rz3zv raf5j7jjaKhfooVpJJe83m3dmgaWqCAPLOGEmSsJ5KmnxrNAPgxoPFS9tmvQMnLMhd+E qB3A== 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=gJBcBCXE3nLfyLrQAfJhQjvLFFIMjBp8NOey+c9Ffmw=; b=g9vUZiVQvLI9qtf/TtShF3KP2nRByotFWn09eGJ8gq29B7PUuf17zFda1fkqoJY0zc 7UTyhDIo/PCsPatwnWfnE/igtoukCTh/pSWbUjc7tvtKnrlCsWrCz2m3+dAi2bnbXOB8 +vGh22L3Hsys/NXMsoNOWKWkfY2DlXHhKNwyIu41rUA2mlHp5VAcVsQ4AK3K+l+52vWu jALUYrAugcQQeCof3nxQq97R2N7Nm0dLcfwCnYffqdHP+V2KVynOgFJCQw92EHjio/g9 GdrZ8s3cefepdh/QqiYYaJi6vISKQWk9FLNggiUAVYlElVJMdr8riUDlF+l/4bCydqV2 l63w== 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 e21-20020a170902d39500b001ac84f55591si1354804pld.293.2023.05.22.06.01.10; Mon, 22 May 2023 06:01:23 -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 S233585AbjEVM1L (ORCPT + 99 others); Mon, 22 May 2023 08:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234019AbjEVM0g (ORCPT ); Mon, 22 May 2023 08:26:36 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 600B21FCA; Mon, 22 May 2023 05:24:50 -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 57F9F150C; Mon, 22 May 2023 05:25:30 -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 ADA8B3F59C; Mon, 22 May 2023 05:24:43 -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-arch@vger.kernel.org, linux@armlinux.org.uk, linux-doc@vger.kernel.org, mark.rutland@arm.com, paulmck@kernel.org, peterz@infradead.org, sstabellini@kernel.org, will@kernel.org Subject: [PATCH 03/26] locking/atomic: hexagon: remove redundant arch_atomic_cmpxchg Date: Mon, 22 May 2023 13:24:06 +0100 Message-Id: <20230522122429.1915021-4-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230522122429.1915021-1-mark.rutland@arm.com> References: <20230522122429.1915021-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?1766599409043853320?= X-GMAIL-MSGID: =?utf-8?q?1766599409043853320?= 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 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) \