mirror of https://gitee.com/openkylin/linux.git
locking/atomic: xtensa: move to ARCH_ATOMIC
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
This commit is contained in:
parent
ff5b4f1ed5
commit
b9b12978a8
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -52,11 +52,11 @@
|
|||
*
|
||||
* 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 */
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue