CVS commit: src/common/lib/libc/arch/aarch64/atomic

2021-08-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  8 07:17:18 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: __aarch64_lse.S

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S
diff -u src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S:1.1 src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S:1.2
--- src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S:1.1	Tue Apr 27 09:14:24 2021
+++ src/common/lib/libc/arch/aarch64/atomic/__aarch64_lse.S	Sun Aug  8 07:17:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: __aarch64_lse.S,v 1.1 2021/04/27 09:14:24 skrll Exp $ */
+/* $NetBSD: __aarch64_lse.S,v 1.2 2021/08/08 07:17:18 skrll Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -204,4 +204,3 @@ ENTRY_NP(INSN_FUNC)
 2:	b	1b
 END(INSN_FUNC)
 #endif
-



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2021-07-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 29 10:29:05 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_add_16.S
atomic_add_32.S atomic_add_64.S atomic_add_8.S atomic_and_16.S
atomic_and_32.S atomic_and_64.S atomic_and_8.S atomic_cas_16.S
atomic_cas_32.S atomic_cas_64.S atomic_cas_8.S atomic_nand_16.S
atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S atomic_op_asm.h
atomic_or_16.S atomic_or_32.S atomic_or_64.S atomic_or_8.S
atomic_sub_16.S atomic_sub_32.S atomic_sub_64.S atomic_sub_8.S
atomic_swap_16.S atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S
atomic_xor_16.S atomic_xor_32.S atomic_xor_64.S atomic_xor_8.S

Log Message:
As we're providing the legacy gcc __sync built-in functions for atomic
memory access we might as well get the memory barriers right...
>From the gcc documentation:

In most cases, these built-in functions are considered a full barrier.
That is, no memory operand is moved across the operation, either forward
or backward. Further, instructions are issued as necessary to prevent the
processor from speculating loads across the operation and from queuing
stores after the operation.

type __sync_lock_test_and_set (type *ptr, type value, ...)

   This built-in function is not a full barrier, but rather an acquire
   barrier. This means that references after the operation cannot move to
   (or be speculated to) before the operation, but previous memory stores
   may not be globally visible yet, and previous memory loads may not yet
   be satisfied.

void __sync_lock_release (type *ptr, ...)

   This built-in function is not a full barrier, but rather a release
   barrier. This means that all previous memory stores are globally
   visible, and all previous memory loads have been satisfied, but
   following memory reads are not prevented from being speculated to
   before the barrier.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_add_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_add_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_add_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_and_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_and_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_and_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_and_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_or_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_or_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_or_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_sub_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_sub_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_sub_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_sub_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_xor_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_xor_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_xor_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_xor_8.S
cvs rdiff -u -r1.3 -r1.4 \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S
cvs rdiff -u -r1.5 -r1.6 \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h
cvs rdiff -u -r1.4 -r1.5 \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S
cvs rdiff -u -r1.2 -r1.3 \
src/common/lib/libc/arch/aarch64/atomic/atomic_or_64.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S:1.2
--- src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S:1.1	Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_add_16.S	Thu Jul 29 10:29:05 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_add_16.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */
+/* $NetBSD: atomic_add_16.S,v 1.2 2021/07/29 10:29:05 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -33,14 +33,16 @@
 
 ATOMIC_OP16(add, add)
 
+SYNC_FETCH_OP16(add, add)
+
 

CVS commit: src/common/lib/libc/arch/aarch64/atomic

2021-07-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul  6 08:31:41 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_nand_16.S

Log Message:
One more s/pte/ptr/


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.4
--- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.3	Sun Jul  4 06:55:47 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S	Tue Jul  6 08:31:41 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_16.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
+/* $NetBSD: atomic_nand_16.S,v 1.4 2021/07/06 08:31:41 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_16)
 	mov	x4, x0
 1:	ldxrh	w0, [x4]		/* load old value (*ptr) */
 	and	w3, w0, w1		/* w3 =  (*ptr & value) */
-	mvn	w3, w3			/* w3 = ~(*pte & value) */
+	mvn	w3, w3			/* w3 = ~(*ptr & value) */
 	stxrh	w2, w3, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again */
 	ret/* return old value */
@@ -58,7 +58,7 @@ ENTRY_NP(_atomic_nand_16_nv)
 	mov	x4, x0			/* need r0 for return value */
 1:	ldxrh	w0, [x4]		/* load old value (*ptr) */
 	and	w0, w0, w1		/* w0 =  (*ptr & value) */
-	mvn	w0, w0			/* w0 = ~(*pte & value), return value */
+	mvn	w0, w0			/* w0 = ~(*ptr & value), return value */
 	stxrh	w2, w0, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again? */
 	ret/* return new value */



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2021-07-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul  5 08:50:31 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_nand_32.S
atomic_nand_64.S atomic_nand_8.S

Log Message:
typo in comment s/pte/ptr/


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.4
--- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.3	Sun Jul  4 06:55:47 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S	Mon Jul  5 08:50:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_32.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
+/* $NetBSD: atomic_nand_32.S,v 1.4 2021/07/05 08:50:31 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_32)
 	mov	x4, x0
 1:	ldxr	w0, [x4]		/* load old value (to be returned) */
 	and	w3, w0, w1		/* w3 =  (*ptr & value) */
-	mvn	w3, w3			/* x3 = ~(*pte & value) */
+	mvn	w3, w3			/* x3 = ~(*ptr & value) */
 	stxr	w2, w3, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again */
 	ret/* return old value */
@@ -58,7 +58,7 @@ ENTRY_NP(_atomic_nand_32_nv)
 	mov	x4, x0			/* need r0 for return value */
 1:	ldxr	w0, [x4]		/* load old value (*ptr) */
 	and	w0, w0, w1		/* x0 =  (*ptr & value) */
-	mvn	w0, w0			/* x0 = ~(*pte & value), return value */
+	mvn	w0, w0			/* x0 = ~(*ptr & value), return value */
 	stxr	w2, w0, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again? */
 	ret/* return new value */
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.4
--- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.3	Sun Jul  4 06:55:47 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S	Mon Jul  5 08:50:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_64.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
+/* $NetBSD: atomic_nand_64.S,v 1.4 2021/07/05 08:50:31 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_64)
 	mov	x4, x0
 1:	ldxr	x0, [x4]		/* load old value (*ptr) */
 	and	x2, x0, x1		/* x2 =  (*ptr & value) */
-	mvn	x2, x2			/* x2 = ~(*pte & value) */
+	mvn	x2, x2			/* x2 = ~(*ptr & value) */
 	stxr	w3, x2, [x4]		/* try to store */
 	cbnz	w3, 2f			/*   succeed? no, try again */
 	ret/* return old value */
@@ -58,7 +58,7 @@ ENTRY_NP(_atomic_nand_64_nv)
 	mov	x4, x0			/* need r0 for return value */
 1:	ldxr	x0, [x4]		/* load old value (*ptr) */
 	and	x0, x0, x1		/* x0 =  (*ptr & value) */
-	mvn	x0, x0			/* x0 = ~(*pte & value), return value */
+	mvn	x0, x0			/* x0 = ~(*ptr & value), return value */
 	stxr	w3, x0, [x4]		/* try to store */
 	cbnz	w3, 2f			/*   succeed? no, try again? */
 	ret/* return new value */
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S:1.4
--- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S:1.3	Sun Jul  4 06:55:47 2021
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S	Mon Jul  5 08:50:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_8.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
+/* $NetBSD: atomic_nand_8.S,v 1.4 2021/07/05 08:50:31 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@ ENTRY_NP(_atomic_nand_8)
 	mov	x4, x0
 1:	ldxrb	w0, [x4]		/* load old value (*ptr) */
 	and	w3, w0, w1		/* w3 =  (*ptr & value) */
-	mvn	w3, w3			/* w3 = ~(*pte & value) */
+	mvn	w3, w3			/* w3 = ~(*ptr & value) */
 	stxrb	w2, w3, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again */
 	ret/* return old value */
@@ -57,7 +57,7 @@ ENTRY_NP(_atomic_nand_8_nv)
 	mov	x4, x0			/* need r0 for return value */
 1:	ldxrb	w0, [x4]		/* load old value (*ptr) */
 	and	w0, w0, w1		/* w0 =  (*ptr & value) */
-	mvn	w0, w0			/* w0 = ~(*pte & value), return value */
+	mvn	w0, w0			/* w0 = ~(*ptr & value), return value */
 	stxrb	w2, w0, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again? */
 	ret/* return new value */



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2021-07-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul  4 06:55:47 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_nand_16.S
atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S

Log Message:
Fix the logic operation for atomic_nand_{8,16,32,64}

>From the gcc docs the operations are as follows

 { tmp = *ptr; *ptr = ~(tmp & value); return tmp; }   // nand
 { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; }   // nand

yes, this is really rather strange.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S:1.2	Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S	Sun Jul  4 06:55:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_nand_16.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,11 +31,14 @@
 
 #include "atomic_op_asm.h"
 
+/*
+ * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; }   // nand
+ */
 ENTRY_NP(_atomic_nand_16)
 	mov	x4, x0
-1:	ldxrh	w0, [x4]		/* load old value (to be returned) */
-	mvn	w3, w0			/* complement source */
-	and	w3, w3, w1		/* calculate new value */
+1:	ldxrh	w0, [x4]		/* load old value (*ptr) */
+	and	w3, w0, w1		/* w3 =  (*ptr & value) */
+	mvn	w3, w3			/* w3 = ~(*pte & value) */
 	stxrh	w2, w3, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again */
 	ret/* return old value */
@@ -47,11 +50,15 @@ ATOMIC_OP_ALIAS(atomic_nand_ushort,_atom
 STRONG_ALIAS(__sync_fetch_and_nand_2,_atomic_nand_16)
 STRONG_ALIAS(_atomic_nand_ushort,_atomic_nand_16)
 
+
+/*
+ * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; }   // nand
+ */
 ENTRY_NP(_atomic_nand_16_nv)
 	mov	x4, x0			/* need r0 for return value */
-1:	ldxrh	w0, [x4]		/* load old value */
-	mvn	w0, w0			/* complement source */
-	and	w0, w0, w1		/* calculate new value (return value) */
+1:	ldxrh	w0, [x4]		/* load old value (*ptr) */
+	and	w0, w0, w1		/* w0 =  (*ptr & value) */
+	mvn	w0, w0			/* w0 = ~(*pte & value), return value */
 	stxrh	w2, w0, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again? */
 	ret/* return new value */
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S:1.2	Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S	Sun Jul  4 06:55:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_nand_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_nand_32.S,v 1.3 2021/07/04 06:55:47 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,11 +31,14 @@
 
 #include "atomic_op_asm.h"
 
+/*
+ * { tmp = *ptr; *ptr = ~(tmp & value); return tmp; }   // nand
+ */
 ENTRY_NP(_atomic_nand_32)
 	mov	x4, x0
 1:	ldxr	w0, [x4]		/* load old value (to be returned) */
-	mvn	w3, w0			/* complement source */
-	and	w3, w3, w1		/* calculate new value */
+	and	w3, w0, w1		/* w3 =  (*ptr & value) */
+	mvn	w3, w3			/* x3 = ~(*pte & value) */
 	stxr	w2, w3, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again */
 	ret/* return old value */
@@ -47,11 +50,15 @@ ATOMIC_OP_ALIAS(atomic_nand_uint,_atomic
 STRONG_ALIAS(__sync_fetch_and_nand_4,_atomic_nand_32)
 STRONG_ALIAS(_atomic_nand_uint,_atomic_nand_32)
 
+
+/*
+ * { tmp = ~(*ptr & value); *ptr = tmp; return *ptr; }   // nand
+ */
 ENTRY_NP(_atomic_nand_32_nv)
 	mov	x4, x0			/* need r0 for return value */
-1:	ldxr	w0, [x4]		/* load old value */
-	mvn	w0, w0			/* complement source */
-	and	w0, w0, w1		/* calculate new value (return value) */
+1:	ldxr	w0, [x4]		/* load old value (*ptr) */
+	and	w0, w0, w1		/* x0 =  (*ptr & value) */
+	mvn	w0, w0			/* x0 = ~(*pte & value), return value */
 	stxr	w2, w0, [x4]		/* try to store */
 	cbnz	w2, 2f			/*   succeed? no, try again? */
 	ret/* return new value */
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S:1.2	Wed Aug 12 12:59:57 2020
+++ 

CVS commit: src/common/lib/libc/arch/aarch64/atomic

2021-04-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 21 16:23:47 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: Makefile.inc atomic_swap_16.S
atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S
Added Files:
src/common/lib/libc/arch/aarch64/atomic: __aarch64_swp1_acq.S
__aarch64_swp1_acq_rel.S __aarch64_swp1_rel.S
__aarch64_swp1_relax.S __aarch64_swp2_acq.S
__aarch64_swp2_acq_rel.S __aarch64_swp2_rel.S
__aarch64_swp2_relax.S __aarch64_swp4_acq.S
__aarch64_swp4_acq_rel.S __aarch64_swp4_rel.S
__aarch64_swp4_relax.S __aarch64_swp8_acq.S
__aarch64_swp8_acq_rel.S __aarch64_swp8_rel.S
__aarch64_swp8_relax.S
Removed Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_swap_acq_16.S
atomic_swap_acq_32.S atomic_swap_acq_64.S atomic_swap_acq_8.S
atomic_swap_acq_rel_16.S atomic_swap_acq_rel_32.S
atomic_swap_acq_rel_64.S atomic_swap_acq_rel_8.S
atomic_swap_rel_16.S atomic_swap_rel_32.S atomic_swap_rel_64.S
atomic_swap_rel_8.S

Log Message:
Do previous differently as the API is different.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc
cvs rdiff -u -r0 -r1.1 \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_acq.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_acq_rel.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_rel.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp1_relax.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_acq.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_acq_rel.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_rel.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp2_relax.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_acq.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_acq_rel.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_rel.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp4_relax.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_acq.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_acq_rel.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_rel.S \
src/common/lib/libc/arch/aarch64/atomic/__aarch64_swp8_relax.S
cvs rdiff -u -r1.3 -r1.4 \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S
cvs rdiff -u -r1.1 -r0 \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_8.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/Makefile.inc
diff -u src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.2 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.3
--- src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.2	Wed Apr 21 07:31:37 2021
+++ src/common/lib/libc/arch/aarch64/atomic/Makefile.inc	Wed Apr 21 16:23:47 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.2 2021/04/21 07:31:37 skrll Exp $
+# $NetBSD: Makefile.inc,v 1.3 2021/04/21 16:23:47 skrll Exp $
 
 .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
 	|| ${LIB} == "rump")
@@ -12,10 +12,10 @@ SRCS.atomic+=	atomic_dec_32.S atomic_dec
 SRCS.atomic+=	atomic_inc_32.S atomic_inc_64.S
 SRCS.atomic+=	membar_ops.S
 #and cas nand or sub swap xor
-.for op in swap
-.for sz in 8 16 32 64
-.for ar in acq rel acq_rel
-SRCS.atomic+=	atomic_${op}_${ar}_${sz}.S
+.for op in swp
+.for sz in 1 2 4 8
+.for ar in relax acq rel acq_rel
+SRCS.atomic+=	__aarch64_${op}${sz}_${ar}.S
 .endfor
 .endfor
 .endfor

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.4
--- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.3	Wed Apr 21 07:31:37 2021

CVS commit: src/common/lib/libc/arch/aarch64/atomic

2021-04-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 21 07:31:38 UTC 2021

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: Makefile.inc atomic_swap_16.S
atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S
Added Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_swap_acq_16.S
atomic_swap_acq_32.S atomic_swap_acq_64.S atomic_swap_acq_8.S
atomic_swap_acq_rel_16.S atomic_swap_acq_rel_32.S
atomic_swap_acq_rel_64.S atomic_swap_acq_rel_8.S
atomic_swap_rel_16.S atomic_swap_rel_32.S atomic_swap_rel_64.S
atomic_swap_rel_8.S

Log Message:
Provide some more operations that are part of compiler lse.S.  This is
incomplete, but at least covers all the atomic_swap ops and allows the
aa64 kernel to link with gcc 10.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc
cvs rdiff -u -r1.2 -r1.3 \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S
cvs rdiff -u -r0 -r1.1 \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_acq_rel_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_rel_8.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/Makefile.inc
diff -u src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.1 src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.2
--- src/common/lib/libc/arch/aarch64/atomic/Makefile.inc:1.1	Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/Makefile.inc	Wed Apr 21 07:31:37 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:35 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2021/04/21 07:31:37 skrll Exp $
 
 .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
 	|| ${LIB} == "rump")
@@ -11,6 +11,14 @@ SRCS.atomic+=	atomic_${op}_${sz}.S
 SRCS.atomic+=	atomic_dec_32.S atomic_dec_64.S
 SRCS.atomic+=	atomic_inc_32.S atomic_inc_64.S
 SRCS.atomic+=	membar_ops.S
+#and cas nand or sub swap xor
+.for op in swap
+.for sz in 8 16 32 64
+.for ar in acq rel acq_rel
+SRCS.atomic+=	atomic_${op}_${ar}_${sz}.S
+.endfor
+.endfor
+.endfor
 #.for op in add and nand or sub xor
 #SRCS.atomic+=	sync_fetch_and_${op}_8.S
 #.endfor

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S:1.2	Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S	Wed Apr 21 07:31:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_swap_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_swap_16.S,v 1.3 2021/04/21 07:31:37 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -43,6 +43,7 @@ END(_atomic_swap_16)
 ATOMIC_OP_ALIAS(atomic_swap_16,_atomic_swap_16)
 ATOMIC_OP_ALIAS(atomic_swap_short,_atomic_swap_16)
 ATOMIC_OP_ALIAS(atomic_swap_ushort,_atomic_swap_16)
+ATOMIC_OP_ALIAS(__aarch64_swp2_relax,_atomic_swap_16)
 STRONG_ALIAS(__sync_lock_test_and_set_2,_atomic_swap_16)
 STRONG_ALIAS(_atomic_swap_short,_atomic_swap_16)
 STRONG_ALIAS(_atomic_swap_ushort,_atomic_swap_16)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S:1.2	Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S	Wed Apr 21 07:31:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_swap_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_swap_32.S,v 1.3 2021/04/21 07:31:37 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -42,6 +42,7 @@ END(_atomic_swap_32)
 
 ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
 ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32)
+ATOMIC_OP_ALIAS(__aarch64_swp4_relax,_atomic_swap_32)
 

CVS commit: src/common/lib/libc/arch/aarch64/atomic

2020-10-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Oct 13 21:22:12 UTC 2020

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: membar_ops.S

Log Message:
Use the correct barriers - all of membar_{sync,producer,consumer} have
less scope than before.

LGTM from riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/atomic/membar_ops.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/membar_ops.S
diff -u src/common/lib/libc/arch/aarch64/atomic/membar_ops.S:1.1 src/common/lib/libc/arch/aarch64/atomic/membar_ops.S:1.2
--- src/common/lib/libc/arch/aarch64/atomic/membar_ops.S:1.1	Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/membar_ops.S	Tue Oct 13 21:22:12 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: membar_ops.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */
+/* $NetBSD: membar_ops.S,v 1.2 2020/10/13 21:22:12 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,24 +32,28 @@
 #include "atomic_op_asm.h"
 
 ENTRY_NP(_membar_producer)
-	dsb	sy
+	dmb	ishst
 	ret
 END(_membar_producer)
 ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
 ATOMIC_OP_ALIAS(membar_write,_membar_producer)
 STRONG_ALIAS(_membar_write,_membar_producer)
 
+ENTRY_NP(_membar_consumer)
+	dmb	ishld
+	ret
+END(_membar_producer)
+ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer)
+ATOMIC_OP_ALIAS(membar_read,_membar_consumer)
+STRONG_ALIAS(_membar_read,_membar_consumer)
+
 ENTRY_NP(_membar_sync)
-	dmb	sy
+	dmb	ish
 	ret
 END(_membar_sync)
 ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
 ATOMIC_OP_ALIAS(membar_enter,_membar_sync)
 ATOMIC_OP_ALIAS(membar_exit,_membar_sync)
-ATOMIC_OP_ALIAS(membar_consumer,_membar_sync)
-ATOMIC_OP_ALIAS(membar_read,_membar_sync)
 STRONG_ALIAS(__sync_synchronize,_membar_sync)
 STRONG_ALIAS(_membar_enter,_membar_sync)
 STRONG_ALIAS(_membar_exit,_membar_sync)
-STRONG_ALIAS(_membar_consumer,_membar_sync)
-STRONG_ALIAS(_membar_read,_membar_sync)



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2020-10-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Oct 13 21:17:35 UTC 2020

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_op_asm.h

Log Message:
Remove memory barriers from the atomic ops macros in the same way as was
done for the other atomic ops earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.4 src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.5
--- src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.4	Wed Oct  7 07:34:29 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h	Tue Oct 13 21:17:35 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_op_asm.h,v 1.4 2020/10/07 07:34:29 skrll Exp $ */
+/* $NetBSD: atomic_op_asm.h,v 1.5 2020/10/13 21:17:35 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,6 @@ ENTRY_NP(_atomic_##OP##_8)		;\
 	INSN	w2, w0, w1		/* calculate new value */	;\
 	stxrb	w3, w2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
-	dmb	st			;\
 	ret/* return old value */		;\
 END(_atomic_##OP##_8)
 
@@ -52,7 +51,6 @@ ENTRY_NP(_atomic_##OP##_8_nv)		;\
 	INSN	w0, w0, w1		/* calc new (return) value */	;\
 	stxrb	w3, w0, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
-	dmb	sy			;\
 	ret/* return new value */		;\
 END(_atomic_##OP##_8_nv)
 
@@ -63,7 +61,6 @@ ENTRY_NP(_atomic_##OP##_16)		;\
 	INSN	w2, w0, w1		/* calculate new value */	;\
 	stxrh	w3, w2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
-	dmb	st			;\
 	ret/* return old value */		;\
 END(_atomic_##OP##_16)
 
@@ -74,7 +71,6 @@ ENTRY_NP(_atomic_##OP##_16_nv)		;\
 	INSN	w0, w0, w1		/* calc new (return) value */	;\
 	stxrh	w3, w0, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
-	dmb	sy			;\
 	ret/* return new value */		;\
 END(_atomic_##OP##_16_nv)
 
@@ -85,7 +81,6 @@ ENTRY_NP(_atomic_##OP##_32)		;\
 	INSN	w2, w0, w1		/* calculate new value */	;\
 	stxr	w3, w2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
-	dmb	st			;\
 	ret/* return old value */		;\
 END(_atomic_##OP##_32)
 
@@ -96,7 +91,6 @@ ENTRY_NP(_atomic_##OP##_32_nv)		;\
 	INSN	w0, w0, w1		/* calc new (return) value */	;\
 	stxr	w3, w0, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again? */	;\
-	dmb	sy			;\
 	ret/* return new value */		;\
 END(_atomic_##OP##_32_nv)
 
@@ -107,7 +101,6 @@ ENTRY_NP(_atomic_##OP##_64)		;\
 	INSN	x2, x0, x1		/* calculate new value */	;\
 	stxr	w3, x2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
-	dmb	st			;\
 	ret/* return old value */		;\
 END(_atomic_##OP##_64)
 
@@ -118,7 +111,6 @@ ENTRY_NP(_atomic_##OP##_64_nv)		;\
 	INSN	x0, x0, x1		/* calc new (return) value */	;\
 	stxr	w3, x0, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again? */	;\
-	dmb	sy			;\
 	ret/* return new value */		;\
 END(_atomic_##OP##_64_nv)
 



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2020-10-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Oct  7 07:34:30 UTC 2020

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_op_asm.h

Log Message:
Comment nit


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.3 src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.4
--- src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.3	Fri Feb  8 06:56:56 2019
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h	Wed Oct  7 07:34:29 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_op_asm.h,v 1.3 2019/02/08 06:56:56 ryo Exp $ */
+/* $NetBSD: atomic_op_asm.h,v 1.4 2020/10/07 07:34:29 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@ END(_atomic_##OP##_8)
 
 #define	ATOMIC_OP8_NV(OP, INSN)		\
 ENTRY_NP(_atomic_##OP##_8_nv)		;\
-	mov	x4, x0			/* need r0 for return value */	;\
+	mov	x4, x0			/* need x0 for return value */	;\
 1:	ldxrb	w0, [x4]		/* load old value */		;\
 	INSN	w0, w0, w1		/* calc new (return) value */	;\
 	stxrb	w3, w0, [x4]		/* try to store */		;\
@@ -69,7 +69,7 @@ END(_atomic_##OP##_16)
 
 #define	ATOMIC_OP16_NV(OP, INSN)	\
 ENTRY_NP(_atomic_##OP##_16_nv)		;\
-	mov	x4, x0			/* need r0 for return value */	;\
+	mov	x4, x0			/* need x0 for return value */	;\
 1:	ldxrh	w0, [x4]		/* load old value */		;\
 	INSN	w0, w0, w1		/* calc new (return) value */	;\
 	stxrh	w3, w0, [x4]		/* try to store */		;\
@@ -91,7 +91,7 @@ END(_atomic_##OP##_32)
 
 #define	ATOMIC_OP32_NV(OP, INSN)	\
 ENTRY_NP(_atomic_##OP##_32_nv)		;\
-	mov	x4, x0			/* need r0 for return value */	;\
+	mov	x4, x0			/* need x0 for return value */	;\
 1:	ldxr	w0, [x4]		/* load old value */		;\
 	INSN	w0, w0, w1		/* calc new (return) value */	;\
 	stxr	w3, w0, [x4]		/* try to store */		;\
@@ -113,7 +113,7 @@ END(_atomic_##OP##_64)
 
 #define	ATOMIC_OP64_NV(OP, INSN)	\
 ENTRY_NP(_atomic_##OP##_64_nv)		;\
-	mov	x4, x0			/* need r0 for return value */	;\
+	mov	x4, x0			/* need x0 for return value */	;\
 1:	ldxr	x0, [x4]		/* load old value */		;\
 	INSN	x0, x0, x1		/* calc new (return) value */	;\
 	stxr	w3, x0, [x4]		/* try to store */		;\



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2020-10-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Oct  7 07:31:47 UTC 2020

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_cas_16.S
atomic_cas_32.S atomic_cas_64.S atomic_cas_8.S

Log Message:
Comment nit


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S
cvs rdiff -u -r1.4 -r1.5 \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.2	Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S	Wed Oct  7 07:31:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_cas_16.S,v 1.3 2020/10/07 07:31:47 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "atomic_op_asm.h"
 
 ENTRY_NP(_atomic_cas_16)
-	mov	x4, x0			/* we need r0 for return value */
+	mov	x4, x0			/* we need x0 for return value */
 1:	ldxrh	w0, [x4]		/* load old value */
 	cmp	w0, w1			/*   compare? */
 	b.ne	2f
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.2	Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S	Wed Oct  7 07:31:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_cas_32.S,v 1.3 2020/10/07 07:31:47 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "atomic_op_asm.h"
 
 ENTRY_NP(_atomic_cas_32)
-	mov	x4, x0			/* we need r0 for return value */
+	mov	x4, x0			/* we need x0 for return value */
 1:	ldxr	w0, [x4]		/* load old value */
 	cmp	w0, w1			/*   compare? */
 	b.ne	2f			/* return if different */
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.2	Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S	Wed Oct  7 07:31:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_8.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_cas_8.S,v 1.3 2020/10/07 07:31:47 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "atomic_op_asm.h"
 
 ENTRY_NP(_atomic_cas_8)
-	mov	x4, x0			/* we need r0 for return value */
+	mov	x4, x0			/* we need x0 for return value */
 1:	ldxrb	w0, [x4]		/* load old value */
 	cmp	w0, w1			/*   compare? */
 	b.ne	2f

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.4 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.5
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.4	Wed Aug 12 12:59:57 2020
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S	Wed Oct  7 07:31:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_64.S,v 1.4 2020/08/12 12:59:57 skrll Exp $ */
+/* $NetBSD: atomic_cas_64.S,v 1.5 2020/10/07 07:31:47 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "atomic_op_asm.h"
 
 ENTRY_NP(_atomic_cas_64)
-	mov	x4, x0			/* we need r0 for return value */
+	mov	x4, x0			/* we need x0 for return value */
 1:	ldxr	x0, [x4]		/* load old value */
 	cmp	x0, x1			/*   compare? */
 	b.ne	2f			/* return if different */



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2020-08-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug 12 12:59:57 UTC 2020

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_cas_16.S
atomic_cas_32.S atomic_cas_64.S atomic_cas_8.S atomic_dec_32.S
atomic_dec_64.S atomic_inc_32.S atomic_inc_64.S atomic_nand_16.S
atomic_nand_32.S atomic_nand_64.S atomic_nand_8.S atomic_swap_16.S
atomic_swap_32.S atomic_swap_64.S atomic_swap_8.S

Log Message:
Part I of ad@'s performance improvements for aarch64

- Remove memory barriers from the atomic ops.  I don't understand why those
  are there.  Is it some architectural thing, or for a CPU bug, or just
  over-caution maybe?  They're not needed for correctness.

- Have unlikely conditional branches go forwards to help the static branch
  predictor.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_dec_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_dec_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_inc_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_inc_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_nand_8.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_16.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_32.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_64.S \
src/common/lib/libc/arch/aarch64/atomic/atomic_swap_8.S
cvs rdiff -u -r1.3 -r1.4 \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.2
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S:1.1	Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_16.S	Wed Aug 12 12:59:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_16.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */
+/* $NetBSD: atomic_cas_16.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -37,9 +37,9 @@ ENTRY_NP(_atomic_cas_16)
 	cmp	w0, w1			/*   compare? */
 	b.ne	2f
 	stxrh	w3, w2, [x4]		/* store new value */
-	cbnz	w3, 1b			/*   succeed? nope, try again. */
-	dmb	st			/* data memory barrier */
+	cbnz	w3, 3f			/*   succeed? nope, try again. */
 2:	ret/* return. */
+3:	b	1b
 END(_atomic_cas_16)
 
 ATOMIC_OP_ALIAS(atomic_cas_16,_atomic_cas_16)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.2
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S:1.1	Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_32.S	Wed Aug 12 12:59:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_32.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */
+/* $NetBSD: atomic_cas_32.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -37,9 +37,9 @@ ENTRY_NP(_atomic_cas_32)
 	cmp	w0, w1			/*   compare? */
 	b.ne	2f			/* return if different */
 	stxr	w3, w2, [x4]		/* store new value */
-	cbnz	w3, 1b			/*   succeed? nope, try again. */
-	dmb	st
+	cbnz	w3, 3f			/*   succeed? nope, try again. */
 2:	ret/* return. */
+3:	b	1b
 END(_atomic_cas_32)
 
 ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.2
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S:1.1	Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_8.S	Wed Aug 12 12:59:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_8.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */
+/* $NetBSD: atomic_cas_8.S,v 1.2 2020/08/12 12:59:57 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -37,9 +37,9 @@ ENTRY_NP(_atomic_cas_8)
 	cmp	w0, w1			/*   compare? */
 	b.ne	2f
 	stxrb	w3, w2, [x4]		/* store new value */
-	cbnz	w3, 1b			/*   succeed? nope, try again. */
-	dmb	st			/* data memory barrier */
+	cbnz	w3, 3f			/*   succeed? nope, try again. */
 2:	ret/* return. */
+3:	b	1b
 END(_atomic_cas_8)
 
 ATOMIC_OP_ALIAS(atomic_cas_8,_atomic_cas_8)
Index: src/common/lib/libc/arch/aarch64/atomic/atomic_dec_32.S
diff -u 

CVS commit: src/common/lib/libc/arch/aarch64/atomic

2019-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 19 12:51:44 UTC 2019

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_cas_64.S

Log Message:
Sort STRONG_ALIAS's in the same manner as ATOMIC_OP_ALIAS's.
No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.2	Tue Feb 19 12:47:36 2019
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S	Tue Feb 19 12:51:44 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_64.S,v 1.2 2019/02/19 12:47:36 rin Exp $ */
+/* $NetBSD: atomic_cas_64.S,v 1.3 2019/02/19 12:51:44 rin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@ ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_ato
 ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64)
 STRONG_ALIAS(__sync_val_compare_and_swap_8,_atomic_cas_64)
 STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64)
+STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64)
 STRONG_ALIAS(_atomic_cas_64_ni,_atomic_cas_64)
-STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64)
 STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64)
-STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64)
+STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64)



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2019-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 19 12:47:36 UTC 2019

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_cas_64.S

Log Message:
Export _atomic_cas_64 as atomic_cas_64_ni.

Note that _atomic_cas_64 is already exported as atomic_cas_{ulong,prt}_ni.

Fix build error of test/lib/atomic/t_atomic_cas, which is successfully
passed on RPI3B+ now.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.2
--- src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S:1.1	Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_cas_64.S	Tue Feb 19 12:47:36 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_cas_64.S,v 1.1 2014/08/10 05:47:35 matt Exp $ */
+/* $NetBSD: atomic_cas_64.S,v 1.2 2019/02/19 12:47:36 rin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@ END(_atomic_cas_64)
 ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64)
 ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64)
 ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64)
+ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64)
 ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_64)
 ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64)
 STRONG_ALIAS(__sync_val_compare_and_swap_8,_atomic_cas_64)



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2019-02-07 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Feb  8 06:56:56 UTC 2019

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_op_asm.h

Log Message:
- atomic_*_{8,16}_nv() must return a new value, not an old value.
- use "dmb sy" for atomic_*{8,16}_nv() in the same way as atomic_*{32,64}_nv().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.2 src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.3
--- src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.2	Wed Feb  6 05:33:14 2019
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h	Fri Feb  8 06:56:56 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_op_asm.h,v 1.2 2019/02/06 05:33:14 ryo Exp $ */
+/* $NetBSD: atomic_op_asm.h,v 1.3 2019/02/08 06:56:56 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -49,10 +49,10 @@ END(_atomic_##OP##_8)
 ENTRY_NP(_atomic_##OP##_8_nv)		;\
 	mov	x4, x0			/* need r0 for return value */	;\
 1:	ldxrb	w0, [x4]		/* load old value */		;\
-	INSN	w2, w0, w1		/* calc new (return) value */	;\
-	stxrb	w3, w2, [x4]		/* try to store */		;\
+	INSN	w0, w0, w1		/* calc new (return) value */	;\
+	stxrb	w3, w0, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
-	dmb	st			;\
+	dmb	sy			;\
 	ret/* return new value */		;\
 END(_atomic_##OP##_8_nv)
 
@@ -71,10 +71,10 @@ END(_atomic_##OP##_16)
 ENTRY_NP(_atomic_##OP##_16_nv)		;\
 	mov	x4, x0			/* need r0 for return value */	;\
 1:	ldxrh	w0, [x4]		/* load old value */		;\
-	INSN	w2, w0, w1		/* calc new (return) value */	;\
-	stxrh	w3, w2, [x4]		/* try to store */		;\
+	INSN	w0, w0, w1		/* calc new (return) value */	;\
+	stxrh	w3, w0, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
-	dmb	st			;\
+	dmb	sy			;\
 	ret/* return new value */		;\
 END(_atomic_##OP##_16_nv)
 



CVS commit: src/common/lib/libc/arch/aarch64/atomic

2019-02-05 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Feb  6 05:33:14 UTC 2019

Modified Files:
src/common/lib/libc/arch/aarch64/atomic: atomic_op_asm.h

Log Message:
fix atomic_sub_*(). it was (delta - *ptr), should be (*ptr - delta).
changing shared macro doesn't effect other atomic_ops because
(*ptr [+|^] delta) and (delta [+|^] *ptr) have same result.

atomic_sub_*() haven't used because non standard API?


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h
diff -u src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.1 src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.2
--- src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h:1.1	Sun Aug 10 05:47:35 2014
+++ src/common/lib/libc/arch/aarch64/atomic/atomic_op_asm.h	Wed Feb  6 05:33:14 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_op_asm.h,v 1.1 2014/08/10 05:47:35 matt Exp $ */
+/* $NetBSD: atomic_op_asm.h,v 1.2 2019/02/06 05:33:14 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 ENTRY_NP(_atomic_##OP##_8)		;\
 	mov	x4, x0			;\
 1:	ldxrb	w0, [x4]		/* load old value */		;\
-	INSN	w2, w1, w0		/* calculate new value */	;\
+	INSN	w2, w0, w1		/* calculate new value */	;\
 	stxrb	w3, w2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
 	dmb	st			;\
@@ -49,7 +49,7 @@ END(_atomic_##OP##_8)
 ENTRY_NP(_atomic_##OP##_8_nv)		;\
 	mov	x4, x0			/* need r0 for return value */	;\
 1:	ldxrb	w0, [x4]		/* load old value */		;\
-	INSN	w2, w1, w0		/* calc new (return) value */	;\
+	INSN	w2, w0, w1		/* calc new (return) value */	;\
 	stxrb	w3, w2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
 	dmb	st			;\
@@ -60,7 +60,7 @@ END(_atomic_##OP##_8_nv)
 ENTRY_NP(_atomic_##OP##_16)		;\
 	mov	x4, x0			;\
 1:	ldxrh	w0, [x4]		/* load old value */		;\
-	INSN	w2, w1, w0		/* calculate new value */	;\
+	INSN	w2, w0, w1		/* calculate new value */	;\
 	stxrh	w3, w2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
 	dmb	st			;\
@@ -71,7 +71,7 @@ END(_atomic_##OP##_16)
 ENTRY_NP(_atomic_##OP##_16_nv)		;\
 	mov	x4, x0			/* need r0 for return value */	;\
 1:	ldxrh	w0, [x4]		/* load old value */		;\
-	INSN	w2, w1, w0		/* calc new (return) value */	;\
+	INSN	w2, w0, w1		/* calc new (return) value */	;\
 	stxrh	w3, w2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
 	dmb	st			;\
@@ -82,7 +82,7 @@ END(_atomic_##OP##_16_nv)
 ENTRY_NP(_atomic_##OP##_32)		;\
 	mov	x4, x0			;\
 1:	ldxr	w0, [x4]		/* load old value */		;\
-	INSN	w2, w1, w0		/* calculate new value */	;\
+	INSN	w2, w0, w1		/* calculate new value */	;\
 	stxr	w3, w2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
 	dmb	st			;\
@@ -104,7 +104,7 @@ END(_atomic_##OP##_32_nv)
 ENTRY_NP(_atomic_##OP##_64)		;\
 	mov	x4, x0			;\
 1:	ldxr	x0, [x4]		/* load old value */		;\
-	INSN	x2, x1, x0		/* calculate new value */	;\
+	INSN	x2, x0, x1		/* calculate new value */	;\
 	stxr	w3, x2, [x4]		/* try to store */		;\
 	cbnz	w3, 1b			/*   succeed? no, try again */	;\
 	dmb	st			;\