Commit 8ac0665f authored by Vineet Gupta's avatar Vineet Gupta

ARC: refactor atomic inline asm operands with symbolic names

This reduces the diff in forth-coming patches and also helps understand
better the incremental changes to inline asm.
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
parent f5959cb0
...@@ -26,22 +26,23 @@ ...@@ -26,22 +26,23 @@
#define ATOMIC_OP(op, c_op, asm_op) \ #define ATOMIC_OP(op, c_op, asm_op) \
static inline void atomic_##op(int i, atomic_t *v) \ static inline void atomic_##op(int i, atomic_t *v) \
{ \ { \
unsigned int temp; \ unsigned int val; \
\ \
__asm__ __volatile__( \ __asm__ __volatile__( \
"1: llock %0, [%1] \n" \ "1: llock %[val], [%[ctr]] \n" \
" " #asm_op " %0, %0, %2 \n" \ " " #asm_op " %[val], %[val], %[i] \n" \
" scond %0, [%1] \n" \ " scond %[val], [%[ctr]] \n" \
" bnz 1b \n" \ " bnz 1b \n" \
: "=&r"(temp) /* Early clobber, to prevent reg reuse */ \ : [val] "=&r" (val) /* Early clobber to prevent reg reuse */ \
: "r"(&v->counter), "ir"(i) \ : [ctr] "r" (&v->counter), /* Not "m": llock only supports reg direct addr mode */ \
[i] "ir" (i) \
: "cc"); \ : "cc"); \
} \ } \
#define ATOMIC_OP_RETURN(op, c_op, asm_op) \ #define ATOMIC_OP_RETURN(op, c_op, asm_op) \
static inline int atomic_##op##_return(int i, atomic_t *v) \ static inline int atomic_##op##_return(int i, atomic_t *v) \
{ \ { \
unsigned int temp; \ unsigned int val; \
\ \
/* \ /* \
* Explicit full memory barrier needed before/after as \ * Explicit full memory barrier needed before/after as \
...@@ -50,17 +51,18 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ ...@@ -50,17 +51,18 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \
smp_mb(); \ smp_mb(); \
\ \
__asm__ __volatile__( \ __asm__ __volatile__( \
"1: llock %0, [%1] \n" \ "1: llock %[val], [%[ctr]] \n" \
" " #asm_op " %0, %0, %2 \n" \ " " #asm_op " %[val], %[val], %[i] \n" \
" scond %0, [%1] \n" \ " scond %[val], [%[ctr]] \n" \
" bnz 1b \n" \ " bnz 1b \n" \
: "=&r"(temp) \ : [val] "=&r" (val) \
: "r"(&v->counter), "ir"(i) \ : [ctr] "r" (&v->counter), \
[i] "ir" (i) \
: "cc"); \ : "cc"); \
\ \
smp_mb(); \ smp_mb(); \
\ \
return temp; \ return val; \
} }
#else /* !CONFIG_ARC_HAS_LLSC */ #else /* !CONFIG_ARC_HAS_LLSC */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment