Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1198701

[PATCH 2/6] ARC: refactor atomic inline asm operands with symbolic names

From Vineet Gupta <Vineet.Gupta1@synopsys.com>
Newsgroups linux.kernel
Subject [PATCH 2/6] ARC: refactor atomic inline asm operands with symbolic names
Date 2015-08-03 12:10 +0200
Message-ID <pTkQX-8kh-29@gated-at.bofh.it> (permalink)
References <pTkQW-8kh-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This reduces the diff in forth-coming patches and also helps understand
better the incremental changes to inline asm.

Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 arch/arc/include/asm/atomic.h | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h
index 20b7dc17979e..3dd36c1efee1 100644
--- a/arch/arc/include/asm/atomic.h
+++ b/arch/arc/include/asm/atomic.h
@@ -26,22 +26,23 @@
 #define ATOMIC_OP(op, c_op, asm_op)					\
 static inline void atomic_##op(int i, atomic_t *v)			\
 {									\
-	unsigned int temp;						\
+	unsigned int val;						\
 									\
 	__asm__ __volatile__(						\
-	"1:	llock   %0, [%1]	\n"				\
-	"	" #asm_op " %0, %0, %2	\n"				\
-	"	scond   %0, [%1]	\n"				\
-	"	bnz     1b		\n"				\
-	: "=&r"(temp)	/* Early clobber, to prevent reg reuse */	\
-	: "r"(&v->counter), "ir"(i)					\
+	"1:	llock   %[val], [%[ctr]]		\n"		\
+	"	" #asm_op " %[val], %[val], %[i]	\n"		\
+	"	scond   %[val], [%[ctr]]		\n"		\
+	"	bnz     1b				\n"		\
+	: [val]	"=&r"	(val) /* Early clobber to prevent reg reuse */	\
+	: [ctr]	"r"	(&v->counter), /* Not "m": llock only supports reg direct addr mode */	\
+	  [i]	"ir"	(i)						\
 	: "cc");							\
 }									\
 
 #define ATOMIC_OP_RETURN(op, c_op, asm_op)				\
 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		\
@@ -50,17 +51,18 @@ static inline int atomic_##op##_return(int i, atomic_t *v)		\
 	smp_mb();							\
 									\
 	__asm__ __volatile__(						\
-	"1:	llock   %0, [%1]	\n"				\
-	"	" #asm_op " %0, %0, %2	\n"				\
-	"	scond   %0, [%1]	\n"				\
-	"	bnz     1b		\n"				\
-	: "=&r"(temp)							\
-	: "r"(&v->counter), "ir"(i)					\
+	"1:	llock   %[val], [%[ctr]]		\n"		\
+	"	" #asm_op " %[val], %[val], %[i]	\n"		\
+	"	scond   %[val], [%[ctr]]		\n"		\
+	"	bnz     1b				\n"		\
+	: [val]	"=&r"	(val)						\
+	: [ctr]	"r"	(&v->counter),					\
+	  [i]	"ir"	(i)						\
 	: "cc");							\
 									\
 	smp_mb();							\
 									\
-	return temp;							\
+	return val;							\
 }
 
 #else	/* !CONFIG_ARC_HAS_LLSC */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/6] ARC: spinlocks/atomics rework Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 12:10 +0200
  [PATCH 4/6] ARC: LLOCK/SCOND based rwlock Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 12:10 +0200
    Re: [PATCH 4/6] ARC: LLOCK/SCOND based rwlock Peter Zijlstra <peterz@infradead.org> - 2015-08-03 13:40 +0200
      Re: [PATCH 4/6] ARC: LLOCK/SCOND based rwlock Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 14:00 +0200
  [PATCH 6/6] ARCv2: spinlock/rwlock: Reset retry delay when starting a new spin-wait cycle Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 12:10 +0200
    Re: [PATCH 6/6] ARCv2: spinlock/rwlock: Reset retry delay when  starting a new spin-wait cycle Peter Zijlstra <peterz@infradead.org> - 2015-08-03 13:50 +0200
      Re: [PATCH 6/6] ARCv2: spinlock/rwlock: Reset retry delay when  starting a new spin-wait cycle Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 16:50 +0200
        Re: [PATCH 6/6] ARCv2: spinlock/rwlock: Reset retry delay when  starting a new spin-wait cycle Peter Zijlstra <peterz@infradead.org> - 2015-08-03 16:50 +0200
  [PATCH 5/6] ARCv2: spinlock/rwlock/atomics: Delayed retry of failed SCOND with exponential backoff Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 12:10 +0200
    Re: [PATCH 5/6] ARCv2: spinlock/rwlock/atomics: Delayed retry of  failed SCOND with exponential backoff Peter Zijlstra <peterz@infradead.org> - 2015-08-03 13:50 +0200
      Re: [PATCH 5/6] ARCv2: spinlock/rwlock/atomics: Delayed retry of  failed SCOND with exponential backoff Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 15:10 +0200
        Re: [PATCH 5/6] ARCv2: spinlock/rwlock/atomics: Delayed retry of  failed SCOND with exponential backoff Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 16:00 +0200
          Re: [PATCH 5/6] ARCv2: spinlock/rwlock/atomics: Delayed retry of  failed SCOND with exponential backoff Peter Zijlstra <peterz@infradead.org> - 2015-08-03 16:10 +0200
    Re: [PATCH 5/6] ARCv2: spinlock/rwlock/atomics: Delayed retry of  failed SCOND with exponential backoff Peter Zijlstra <peterz@infradead.org> - 2015-08-03 14:00 +0200
      Re: [PATCH 5/6] ARCv2: spinlock/rwlock/atomics: Delayed retry of  failed SCOND with exponential backoff Peter Zijlstra <peterz@infradead.org> - 2015-08-03 15:10 +0200
      Re: [PATCH 5/6] ARCv2: spinlock/rwlock/atomics: Delayed retry of  failed SCOND with exponential backoff Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 15:10 +0200
  [PATCH 3/6] ARC: LLOCK/SCOND based spin_lock Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 12:10 +0200
    Re: [PATCH 3/6] ARC: LLOCK/SCOND based spin_lock Peter Zijlstra <peterz@infradead.org> - 2015-08-03 13:30 +0200
      Re: [PATCH 3/6] ARC: LLOCK/SCOND based spin_lock Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 13:50 +0200
  [PATCH 1/6] Revert "ARCv2: STAR 9000837815 workaround hardware exclusive transactions livelock" Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 12:10 +0200
  [PATCH 2/6] ARC: refactor atomic inline asm operands with symbolic names Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-08-03 12:10 +0200

csiph-web