Received: by 10.192.165.148 with SMTP id m20csp2023546imm; Sun, 6 May 2018 05:15:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZosCoUODmPwmTuFigzWMKiRJ9GXB3c5FFkQKhT1DDoLOowbjuV4nFZs/+5k1AaLdjSwPAVd X-Received: by 10.98.237.18 with SMTP id u18mr26799722pfh.127.1525608902723; Sun, 06 May 2018 05:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525608902; cv=none; d=google.com; s=arc-20160816; b=E6ZlFD6Qs+B7ayXRLtn7RoX+ppW7E7PY5CMLLSO+4Fdk/ty2OytRizIuox+BWVGhR1 sggGlRsTk/h5BjBS+tENBPbTGbnmcSsmuioZYCiorvZKBaHYc5gLK5lHUO+0lwo+zjwq CHvzEKJBz5hrxG0K8m9kRtpfbvcuyh7+PmLpZKHZ8fR1p8zVC5bfsQf+YDq4TzE5eVeT YZfvkjeMFsI9pikwJMGItJUldh5BeGOmaNV65BjTIctHUyOLcqvPHuZgCeCyfxFcw34t uRdVprfdhP0lwxhZgviH34DU1TVt5LjBF6M4OVEgszULgJPik0zRy+aXYDcQL3fe9wQp dHpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=TnquArn/VGO11vITxteiz5xmHTeI9E5pX19vDPDUA6o=; b=xJY5iLMo5HUeY6yGyecbta3Lk1xIW9y3f7FVb+Qe4PRh6JQvGlQSW+tTvFbMPaVSa1 b6SE5hQMUPGzhVqTO4U4JLJv0eN9xgN8pYvxe39sRqPoTNfDOsGpcNBK64gb5Rs4wy2M 5AwrmKds/RYJrjabbLfFebJTS68/7dGucEfWrtkhSg0KIsms7pcAPENWe0crYHTIH9v7 BmsXYu7ay6DhV1Z9R5QE8emTx+bqFXwOJ4qETxfEnZhb7/ueDIvx7RyA2ksbeMebjaBl HkyeUtMLoRwGvSQA061bZSy/2MgbSdDSg1pAkTYc+8gbMbFBGGBS91czzMLeQSLE9TtE uXNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h90-v6si19255667plb.377.2018.05.06.05.14.48; Sun, 06 May 2018 05:15:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751711AbeEFMOF (ORCPT + 99 others); Sun, 6 May 2018 08:14:05 -0400 Received: from terminus.zytor.com ([198.137.202.136]:40741 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751200AbeEFMOC (ORCPT ); Sun, 6 May 2018 08:14:02 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w46CDdWa1765828 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 6 May 2018 05:13:39 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w46CDdoJ1765825; Sun, 6 May 2018 05:13:39 -0700 Date: Sun, 6 May 2018 05:13:39 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Boqun Feng Message-ID: Cc: tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, mark.rutland@arm.com, boqun.feng@gmail.com, peterz@infradead.org, mingo@kernel.org, torvalds@linux-foundation.org Reply-To: hpa@zytor.com, tglx@linutronix.de, boqun.feng@gmail.com, mark.rutland@arm.com, linux-kernel@vger.kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, mingo@kernel.org In-Reply-To: <20180505112817.ihrb726i37bwm4cj@tardis> References: <20180505112817.ihrb726i37bwm4cj@tardis> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/atomics/powerpc: Move cmpxchg helpers to asm/cmpxchg.h and define the full set of cmpxchg APIs Git-Commit-ID: 0476a632cb3aa88c03cefc294050a9a86760e88d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_48_96 autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0476a632cb3aa88c03cefc294050a9a86760e88d Gitweb: https://git.kernel.org/tip/0476a632cb3aa88c03cefc294050a9a86760e88d Author: Boqun Feng AuthorDate: Sat, 5 May 2018 19:28:17 +0800 Committer: Ingo Molnar CommitDate: Sat, 5 May 2018 15:22:20 +0200 locking/atomics/powerpc: Move cmpxchg helpers to asm/cmpxchg.h and define the full set of cmpxchg APIs Move PowerPC's __op_{acqurie,release}() from atomic.h to cmpxchg.h (in arch/powerpc/include/asm), plus use them to define these two methods: #define cmpxchg_release __op_release(cmpxchg, __VA_ARGS__); #define cmpxchg64_release __op_release(cmpxchg64, __VA_ARGS__); ... the idea is to generate all these methods in cmpxchg.h and to define the full array of atomic primitives, including the cmpxchg_release() methods which were defined by the generic code before. Also define the atomic[64]_() variants explicitly. This ensures that all these low level cmpxchg APIs are defined in PowerPC headers, with no generic header fallbacks. No change in functionality or code generation. Signed-off-by: Boqun Feng Cc: Linus Torvalds Cc: Mark Rutland Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: aryabinin@virtuozzo.com Cc: catalin.marinas@arm.com Cc: dvyukov@google.com Cc: linux-arm-kernel@lists.infradead.org Cc: will.deacon@arm.com Link: http://lkml.kernel.org/r/20180505112817.ihrb726i37bwm4cj@tardis Signed-off-by: Ingo Molnar --- arch/powerpc/include/asm/atomic.h | 22 ++++------------------ arch/powerpc/include/asm/cmpxchg.h | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h index 682b3e6a1e21..4e06955ec10f 100644 --- a/arch/powerpc/include/asm/atomic.h +++ b/arch/powerpc/include/asm/atomic.h @@ -13,24 +13,6 @@ #define ATOMIC_INIT(i) { (i) } -/* - * Since *_return_relaxed and {cmp}xchg_relaxed are implemented with - * a "bne-" instruction at the end, so an isync is enough as a acquire barrier - * on the platform without lwsync. - */ -#define __atomic_op_acquire(op, args...) \ -({ \ - typeof(op##_relaxed(args)) __ret = op##_relaxed(args); \ - __asm__ __volatile__(PPC_ACQUIRE_BARRIER "" : : : "memory"); \ - __ret; \ -}) - -#define __atomic_op_release(op, args...) \ -({ \ - __asm__ __volatile__(PPC_RELEASE_BARRIER "" : : : "memory"); \ - op##_relaxed(args); \ -}) - static __inline__ int atomic_read(const atomic_t *v) { int t; @@ -213,6 +195,8 @@ static __inline__ int atomic_dec_return_relaxed(atomic_t *v) cmpxchg_relaxed(&((v)->counter), (o), (n)) #define atomic_cmpxchg_acquire(v, o, n) \ cmpxchg_acquire(&((v)->counter), (o), (n)) +#define atomic_cmpxchg_release(v, o, n) \ + cmpxchg_release(&((v)->counter), (o), (n)) #define atomic_xchg(v, new) (xchg(&((v)->counter), new)) #define atomic_xchg_relaxed(v, new) xchg_relaxed(&((v)->counter), (new)) @@ -519,6 +503,8 @@ static __inline__ long atomic64_dec_if_positive(atomic64_t *v) cmpxchg_relaxed(&((v)->counter), (o), (n)) #define atomic64_cmpxchg_acquire(v, o, n) \ cmpxchg_acquire(&((v)->counter), (o), (n)) +#define atomic64_cmpxchg_release(v, o, n) \ + cmpxchg_release(&((v)->counter), (o), (n)) #define atomic64_xchg(v, new) (xchg(&((v)->counter), new)) #define atomic64_xchg_relaxed(v, new) xchg_relaxed(&((v)->counter), (new)) diff --git a/arch/powerpc/include/asm/cmpxchg.h b/arch/powerpc/include/asm/cmpxchg.h index 9b001f1f6b32..e27a612b957f 100644 --- a/arch/powerpc/include/asm/cmpxchg.h +++ b/arch/powerpc/include/asm/cmpxchg.h @@ -8,6 +8,24 @@ #include #include +/* + * Since *_return_relaxed and {cmp}xchg_relaxed are implemented with + * a "bne-" instruction at the end, so an isync is enough as a acquire barrier + * on the platform without lwsync. + */ +#define __atomic_op_acquire(op, args...) \ +({ \ + typeof(op##_relaxed(args)) __ret = op##_relaxed(args); \ + __asm__ __volatile__(PPC_ACQUIRE_BARRIER "" : : : "memory"); \ + __ret; \ +}) + +#define __atomic_op_release(op, args...) \ +({ \ + __asm__ __volatile__(PPC_RELEASE_BARRIER "" : : : "memory"); \ + op##_relaxed(args); \ +}) + #ifdef __BIG_ENDIAN #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE) #else @@ -512,6 +530,9 @@ __cmpxchg_acquire(void *ptr, unsigned long old, unsigned long new, (unsigned long)_o_, (unsigned long)_n_, \ sizeof(*(ptr))); \ }) + +#define cmpxchg_release(...) __atomic_op_release(cmpxchg, __VA_ARGS__) + #ifdef CONFIG_PPC64 #define cmpxchg64(ptr, o, n) \ ({ \ @@ -533,6 +554,9 @@ __cmpxchg_acquire(void *ptr, unsigned long old, unsigned long new, BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ cmpxchg_acquire((ptr), (o), (n)); \ }) + +#define cmpxchg64_release(...) __atomic_op_release(cmpxchg64, __VA_ARGS__) + #else #include #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))