locking/atomic: xtensa: move to ARCH_ATOMIC
authorMark Rutland <mark.rutland@arm.com>
Tue, 25 May 2021 14:02:30 +0000 (15:02 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 26 May 2021 11:20:52 +0000 (13:20 +0200)
We'd like all architectures to convert to ARCH_ATOMIC, as once all
architectures are converted it will be possible to make significant
cleanups to the atomics headers, and this will make it much easier to
generically enable atomic functionality (e.g. debug logic in the
instrumented wrappers).

As a step towards that, this patch migrates xtensa to ARCH_ATOMIC. The
arch code provides arch_{atomic,atomic64,xchg,cmpxchg}*(), and common
code wraps these with optional instrumentation to provide the regular
functions.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210525140232.53872-32-mark.rutland@arm.com
arch/xtensa/Kconfig
arch/xtensa/include/asm/atomic.h
arch/xtensa/include/asm/cmpxchg.h

index 2332b21569938cee49c4681a8e37ae2188d10908..39bb9bdae6b13d34401650294cbaedde628447c7 100644 (file)
@@ -2,6 +2,7 @@
 config XTENSA
        def_bool y
        select ARCH_32BIT_OFF_T
+       select ARCH_ATOMIC
        select ARCH_HAS_BINFMT_FLAT if !MMU
        select ARCH_HAS_DMA_PREP_COHERENT if MMU
        select ARCH_HAS_SYNC_DMA_FOR_CPU if MMU
index 744c2f463845d5c3fb1676b420fb3aded367bafe..4361fe4247e30c255ee92f1cc6468467250b0f6b 100644 (file)
@@ -43,7 +43,7 @@
  *
  * Atomically reads the value of @v.
  */
-#define atomic_read(v)         READ_ONCE((v)->counter)
+#define arch_atomic_read(v)            READ_ONCE((v)->counter)
 
 /**
  * atomic_set - set atomic variable
  *
  * Atomically sets the value of @v to @i.
  */
-#define atomic_set(v,i)                WRITE_ONCE((v)->counter, (i))
+#define arch_atomic_set(v,i)           WRITE_ONCE((v)->counter, (i))
 
 #if XCHAL_HAVE_EXCLUSIVE
 #define ATOMIC_OP(op)                                                  \
-static inline void atomic_##op(int i, atomic_t *v)                     \
+static inline void arch_atomic_##op(int i, atomic_t *v)                        \
 {                                                                      \
        unsigned long tmp;                                              \
        int result;                                                     \
@@ -74,7 +74,7 @@ static inline void atomic_##op(int i, atomic_t *v)                    \
 }                                                                      \
 
 #define ATOMIC_OP_RETURN(op)                                           \
-static inline int atomic_##op##_return(int i, atomic_t *v)             \
+static inline int arch_atomic_##op##_return(int i, atomic_t *v)                \
 {                                                                      \
        unsigned long tmp;                                              \
        int result;                                                     \
@@ -95,7 +95,7 @@ static inline int atomic_##op##_return(int i, atomic_t *v)            \
 }
 
 #define ATOMIC_FETCH_OP(op)                                            \
-static inline int atomic_fetch_##op(int i, atomic_t *v)                        \
+static inline int arch_atomic_fetch_##op(int i, atomic_t *v)           \
 {                                                                      \
        unsigned long tmp;                                              \
        int result;                                                     \
@@ -116,7 +116,7 @@ static inline int atomic_fetch_##op(int i, atomic_t *v)                     \
 
 #elif XCHAL_HAVE_S32C1I
 #define ATOMIC_OP(op)                                                  \
-static inline void atomic_##op(int i, atomic_t * v)                    \
+static inline void arch_atomic_##op(int i, atomic_t * v)               \
 {                                                                      \
        unsigned long tmp;                                              \
        int result;                                                     \
@@ -135,7 +135,7 @@ static inline void atomic_##op(int i, atomic_t * v)                 \
 }                                                                      \
 
 #define ATOMIC_OP_RETURN(op)                                           \
-static inline int atomic_##op##_return(int i, atomic_t * v)            \
+static inline int arch_atomic_##op##_return(int i, atomic_t * v)       \
 {                                                                      \
        unsigned long tmp;                                              \
        int result;                                                     \
@@ -157,7 +157,7 @@ static inline int atomic_##op##_return(int i, atomic_t * v)         \
 }
 
 #define ATOMIC_FETCH_OP(op)                                            \
-static inline int atomic_fetch_##op(int i, atomic_t * v)               \
+static inline int arch_atomic_fetch_##op(int i, atomic_t * v)          \
 {                                                                      \
        unsigned long tmp;                                              \
        int result;                                                     \
@@ -180,7 +180,7 @@ static inline int atomic_fetch_##op(int i, atomic_t * v)            \
 #else /* XCHAL_HAVE_S32C1I */
 
 #define ATOMIC_OP(op)                                                  \
-static inline void atomic_##op(int i, atomic_t * v)                    \
+static inline void arch_atomic_##op(int i, atomic_t * v)               \
 {                                                                      \
        unsigned int vval;                                              \
                                                                        \
@@ -198,7 +198,7 @@ static inline void atomic_##op(int i, atomic_t * v)                 \
 }                                                                      \
 
 #define ATOMIC_OP_RETURN(op)                                           \
-static inline int atomic_##op##_return(int i, atomic_t * v)            \
+static inline int arch_atomic_##op##_return(int i, atomic_t * v)       \
 {                                                                      \
        unsigned int vval;                                              \
                                                                        \
@@ -218,7 +218,7 @@ static inline int atomic_##op##_return(int i, atomic_t * v)         \
 }
 
 #define ATOMIC_FETCH_OP(op)                                            \
-static inline int atomic_fetch_##op(int i, atomic_t * v)               \
+static inline int arch_atomic_fetch_##op(int i, atomic_t * v)          \
 {                                                                      \
        unsigned int tmp, vval;                                         \
                                                                        \
@@ -257,7 +257,7 @@ ATOMIC_OPS(xor)
 #undef ATOMIC_OP_RETURN
 #undef ATOMIC_OP
 
-#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
-#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
+#define arch_atomic_cmpxchg(v, o, n) ((int)arch_cmpxchg(&((v)->counter), (o), (n)))
+#define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new))
 
 #endif /* _XTENSA_ATOMIC_H */
index 9c4d6e5316cee558674f5ab6815f95eb96168a2d..3699e2818efb79360baa902ca628eeeadacfd953 100644 (file)
@@ -80,7 +80,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
        }
 }
 
-#define cmpxchg(ptr,o,n)                                                     \
+#define arch_cmpxchg(ptr,o,n)                                                \
        ({ __typeof__(*(ptr)) _o_ = (o);                                      \
           __typeof__(*(ptr)) _n_ = (n);                                      \
           (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_,          \
@@ -107,11 +107,11 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
  * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
  * them available.
  */
-#define cmpxchg_local(ptr, o, n)                                              \
+#define arch_cmpxchg_local(ptr, o, n)                                         \
        ((__typeof__(*(ptr)))__generic_cmpxchg_local((ptr), (unsigned long)(o),\
                        (unsigned long)(n), sizeof(*(ptr))))
-#define cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n))
-#define cmpxchg64(ptr, o, n)    cmpxchg64_local((ptr), (o), (n))
+#define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n))
+#define arch_cmpxchg64(ptr, o, n)    arch_cmpxchg64_local((ptr), (o), (n))
 
 /*
  * xchg_u32
@@ -169,7 +169,7 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
 #endif
 }
 
-#define xchg(ptr,x) \
+#define arch_xchg(ptr,x) \
        ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
 
 static inline u32 xchg_small(volatile void *ptr, u32 x, int size)