forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/arc/include/asm/cmpxchg.h
....@@ -1,9 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 */
85
96 #ifndef __ASM_ARC_CMPXCHG_H
....@@ -23,7 +20,7 @@
2320
2421 /*
2522 * Explicit full memory barrier needed before/after as
26
- * LLOCK/SCOND thmeselves don't provide any such semantics
23
+ * LLOCK/SCOND themselves don't provide any such semantics
2724 */
2825 smp_mb();
2926
....@@ -44,7 +41,7 @@
4441 return prev;
4542 }
4643
47
-#elif !defined(CONFIG_ARC_PLAT_EZNPS)
44
+#else /* !CONFIG_ARC_HAS_LLSC */
4845
4946 static inline unsigned long
5047 __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new)
....@@ -64,33 +61,7 @@
6461 return prev;
6562 }
6663
67
-#else /* CONFIG_ARC_PLAT_EZNPS */
68
-
69
-static inline unsigned long
70
-__cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new)
71
-{
72
- /*
73
- * Explicit full memory barrier needed before/after
74
- */
75
- smp_mb();
76
-
77
- write_aux_reg(CTOP_AUX_GPA1, expected);
78
-
79
- __asm__ __volatile__(
80
- " mov r2, %0\n"
81
- " mov r3, %1\n"
82
- " .word %2\n"
83
- " mov %0, r2"
84
- : "+r"(new)
85
- : "r"(ptr), "i"(CTOP_INST_EXC_DI_R2_R2_R3)
86
- : "r2", "r3", "memory");
87
-
88
- smp_mb();
89
-
90
- return new;
91
-}
92
-
93
-#endif /* CONFIG_ARC_HAS_LLSC */
64
+#endif
9465
9566 #define cmpxchg(ptr, o, n) ({ \
9667 (typeof(*(ptr)))__cmpxchg((ptr), \
....@@ -106,8 +77,6 @@
10677 */
10778 #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
10879
109
-
110
-#ifndef CONFIG_ARC_PLAT_EZNPS
11180
11281 /*
11382 * xchg (reg with memory) based on "Native atomic" EX insn
....@@ -170,44 +139,6 @@
170139 #define xchg(ptr, with) _xchg(ptr, with)
171140
172141 #endif
173
-
174
-#else /* CONFIG_ARC_PLAT_EZNPS */
175
-
176
-static inline unsigned long __xchg(unsigned long val, volatile void *ptr,
177
- int size)
178
-{
179
- extern unsigned long __xchg_bad_pointer(void);
180
-
181
- switch (size) {
182
- case 4:
183
- /*
184
- * Explicit full memory barrier needed before/after
185
- */
186
- smp_mb();
187
-
188
- __asm__ __volatile__(
189
- " mov r2, %0\n"
190
- " mov r3, %1\n"
191
- " .word %2\n"
192
- " mov %0, r2\n"
193
- : "+r"(val)
194
- : "r"(ptr), "i"(CTOP_INST_XEX_DI_R2_R2_R3)
195
- : "r2", "r3", "memory");
196
-
197
- smp_mb();
198
-
199
- return val;
200
- }
201
- return __xchg_bad_pointer();
202
-}
203
-
204
-#define xchg(ptr, with) ({ \
205
- (typeof(*(ptr)))__xchg((unsigned long)(with), \
206
- (ptr), \
207
- sizeof(*(ptr))); \
208
-})
209
-
210
-#endif /* CONFIG_ARC_PLAT_EZNPS */
211142
212143 /*
213144 * "atomic" variant of xchg()