Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp13863pxt; Wed, 4 Aug 2021 14:20:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxDYXcDGyHtxV9UzGZC4un6PNFc1E4UGs9udUFttZtYAclMBGPNlbTJnYYHFSCevlIHhp2 X-Received: by 2002:a92:1e03:: with SMTP id e3mr1263034ile.89.1628112010524; Wed, 04 Aug 2021 14:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628112010; cv=none; d=google.com; s=arc-20160816; b=G6WIgUoFCkHzSw/LlZp2YtkJEVeoiIg+T9CAnDmOtj6xbRhHv3/cPoFyid2MnzDNs0 KwoMn5hs/vpAiIyLd3pUTE67sB+Wn1tb8zFrN+Dy8A2kGAhL6sdrMOJTBzD7n1FMqyp/ bKxoPK+2YE6ga4IrsL9vhMWnZsHTOkLUpt3O7ZqsGXe1wPrWlsXtT3juIW8XTMEztuws OeRgRE0pmD1qw+LQzvn5rjmDx0Fr+MtPBAlzCQQMBR8dTjVvMLPKezS/ARj3EEM+3LHy m7qj+s0CewcisnJi+JpLefbuw84/aK8q/92IRc9Fyhh0/7mav6LFXLEfyXKHtiRFsd+1 Z1ZA== 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 :dkim-signature; bh=Tz4jV4t7RC/YlPZOhshCCZUAGwuOatcWmPrCTgaxMyg=; b=cOzrW8eNNJ40Udl8ypKbzLxNfVWScMOWSz05iSVvScxZJiqQCTYPs6Ed/INgqhl+qM 5TNJzkX5vmPbNafKvqzPYtjUE/yLiqlU1u+RapfTnjADCwFJHIvWU9DsPZklO6RzbYQL iEBFAypogj4GkJnpgqUxq1DxFBL/EG3nBk6QVJWVdRGncpFABZJkZGKISFm6LxRR1LC8 +/VXhJPm/TWeZlQmUJB5MCbJMqUU/bsrFMPidnVezw6szCHkwviKo4ibUYqM2ef87uIs GVaNj2o7ggjLmeuSRfWDNmHcIM9+ykrG4JbJ51Kv5uyBt4PQSkftJpdlCPGcPJVFZRfn mw6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=c+o0MSTN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si3421415ilv.84.2021.08.04.14.19.56; Wed, 04 Aug 2021 14:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=c+o0MSTN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240705AbhHDTQn (ORCPT + 99 others); Wed, 4 Aug 2021 15:16:43 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.73.133]:58794 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240503AbhHDTQV (ORCPT ); Wed, 4 Aug 2021 15:16:21 -0400 Received: from mailhost.synopsys.com (sv1-mailhost1.synopsys.com [10.205.2.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 3F34540DBA; Wed, 4 Aug 2021 19:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1628104567; bh=ETzGMk/ObfVL8wKfDVOEoi0RM2tas4Uky7iyu8ZWips=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c+o0MSTNHiEFFu5uApAXwSL8QsJ2m0J8c8AVi+iXZVELxkY34RA6BH7mhFuF2thX1 qpPdtcyjIbLSKhUujw5prCfXP3sOhkQSLwO4cYWc8SFnEoIB1OupxNsk8ZD3pDQEer B/geApv/HiJj0ivLUNHqy+/NRm1FJsYRbNlA+o9Sb0mJl7V3TVWvgeq4xAPo+E465a olrkHURomE+z81JTeR/RuwITqKqctlHIXo/d0Go2o9Z6H6HCsQ0/rRtZXX3LG/OA2e PI6oWnrawOnpZAL/83WAWB+Nhz59mwWhaJkJUzzItURzBEz4PxTN04qFTAGbhihwMv QDlKTdbNe4hvw== Received: from vineetg-Latitude-7400.internal.synopsys.com (snps-fugpbdpduq.internal.synopsys.com [10.202.17.37]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id EB36AA0094; Wed, 4 Aug 2021 19:16:06 +0000 (UTC) X-SNPS-Relay: synopsys.com From: Vineet Gupta To: linux-snps-arc@lists.infradead.org Cc: Peter Zijlstra , Will Deacon , Arnd Bergmann , Mark Rutland , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Vladimir Isaev , Vineet Gupta Subject: [PATCH 11/11] ARC: atomic_cmpxchg/atomic_xchg: implement relaxed variants Date: Wed, 4 Aug 2021 12:15:54 -0700 Message-Id: <20210804191554.1252776-12-vgupta@synopsys.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210804191554.1252776-1-vgupta@synopsys.com> References: <20210804191554.1252776-1-vgupta@synopsys.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org And move them out of cmpxchg.h to canonical atomic.h Signed-off-by: Vineet Gupta --- arch/arc/include/asm/atomic.h | 27 +++++++++++++++++++++++++++ arch/arc/include/asm/cmpxchg.h | 23 ----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h index ee88e1dbaab5..52ee51e1ff7c 100644 --- a/arch/arc/include/asm/atomic.h +++ b/arch/arc/include/asm/atomic.h @@ -22,6 +22,33 @@ #include #endif +#define arch_atomic_cmpxchg(v, o, n) \ +({ \ + arch_cmpxchg(&((v)->counter), (o), (n)); \ +}) + +#ifdef arch_cmpxchg_relaxed +#define arch_atomic_cmpxchg_relaxed(v, o, n) \ +({ \ + arch_cmpxchg_relaxed(&((v)->counter), (o), (n)); \ +}) +#endif + +#define arch_atomic_xchg(v, n) \ +({ \ + arch_xchg(&((v)->counter), (n)); \ +}) + +#ifdef arch_xchg_relaxed +#define arch_atomic_xchg_relaxed(v, n) \ +({ \ + arch_xchg_relaxed(&((v)->counter), (n)); \ +}) +#endif + +/* + * 64-bit atomics + */ #ifdef CONFIG_GENERIC_ATOMIC64 #include #else diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h index e2ae0eb1ca07..c5b544a5fe81 100644 --- a/arch/arc/include/asm/cmpxchg.h +++ b/arch/arc/include/asm/cmpxchg.h @@ -80,14 +80,6 @@ #endif -/* - * atomic_cmpxchg is same as cmpxchg - * LLSC: only different in data-type, semantics are exactly same - * !LLSC: cmpxchg() has to use an external lock atomic_ops_lock to guarantee - * semantics, and this lock also happens to be used by atomic_*() - */ -#define arch_atomic_cmpxchg(v, o, n) ((int)arch_cmpxchg(&((v)->counter), (o), (n))) - /* * xchg */ @@ -148,19 +140,4 @@ #endif -/* - * "atomic" variant of xchg() - * REQ: It needs to follow the same serialization rules as other atomic_xxx() - * Since xchg() doesn't always do that, it would seem that following definition - * is incorrect. But here's the rationale: - * SMP : Even xchg() takes the atomic_ops_lock, so OK. - * LLSC: atomic_ops_lock are not relevant at all (even if SMP, since LLSC - * is natively "SMP safe", no serialization required). - * UP : other atomics disable IRQ, so no way a difft ctxt atomic_xchg() - * could clobber them. atomic_xchg() itself would be 1 insn, so it - * can't be clobbered by others. Thus no serialization required when - * atomic_xchg is involved. - */ -#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new)) - #endif -- 2.25.1