summaryrefslogtreecommitdiff
path: root/arch/csky/kernel/atomic.S
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-11-21 17:22:21 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-11-21 17:22:21 -0800
commit4843f6873f7c4835e62f2c73ba0fd538e57a2f22 (patch)
treeee620501a1ffbad9a83141e3a70154e1fe641040 /arch/csky/kernel/atomic.S
downloadlinux-master.tar.gz
linux-master.zip
Merge tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctlgraftedHEADmaster
Pull sysctl fix from Joel Granados: "Fix sysctl jiffy / milliseconds conversion: - Writing a previously read value "X" shall keep the same "X" value - Remove truncation that was causing incorrect saturation of valid timeouts" * tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl: sysctl: Do jiffy / ms conversion in ulong space
Diffstat (limited to 'arch/csky/kernel/atomic.S')
-rw-r--r--arch/csky/kernel/atomic.S61
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/csky/kernel/atomic.S b/arch/csky/kernel/atomic.S
new file mode 100644
index 000000000..e73e548f7
--- /dev/null
+++ b/arch/csky/kernel/atomic.S
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#include <linux/linkage.h>
+#include <abi/entry.h>
+
+.text
+
+/*
+ * int csky_cmpxchg(int oldval, int newval, int *ptr)
+ *
+ * If *ptr != oldval && return 1,
+ * else *ptr = newval return 0.
+ */
+ENTRY(csky_cmpxchg)
+ USPTOKSP
+
+ RD_MEH a3
+ WR_MEH a3
+
+ mfcr a3, epc
+ addi a3, TRAP0_SIZE
+
+ subi sp, 16
+ stw a3, (sp, 0)
+ mfcr a3, epsr
+ stw a3, (sp, 4)
+ mfcr a3, usp
+ stw a3, (sp, 8)
+
+ psrset ee
+#ifdef CONFIG_CPU_HAS_LDSTEX
+1:
+ ldex a3, (a2)
+ cmpne a0, a3
+ bt16 2f
+ mov a3, a1
+ stex a3, (a2)
+ bez a3, 1b
+2:
+ sync.is
+#else
+GLOBAL(csky_cmpxchg_ldw)
+ ldw a3, (a2)
+ cmpne a0, a3
+ bt16 3f
+GLOBAL(csky_cmpxchg_stw)
+ stw a1, (a2)
+3:
+#endif
+ mvc a0
+ ldw a3, (sp, 0)
+ mtcr a3, epc
+ ldw a3, (sp, 4)
+ mtcr a3, epsr
+ ldw a3, (sp, 8)
+ mtcr a3, usp
+ addi sp, 16
+ KSPTOUSP
+ rte
+END(csky_cmpxchg)