aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2018-06-19 08:53:13 -0400
committerIngo Molnar <mingo@kernel.org>2018-06-21 06:52:12 -0400
commit7c8fc35dfc32dfa97d8a1dc25dbd064cf83936db (patch)
tree0ba317c82a0968d5db1441ba8e82ed1ddafe94f1
parent84c6591103dbeaf393a092a3fc7b09510825f6b9 (diff)
locking/atomics/arm64: Replace our atomic/lock bitop implementations with asm-generic
The <asm-generic/bitops/{atomic,lock}.h> implementations are built around the atomic-fetch ops, which we implement efficiently for both LSE and LL/SC systems. Use that instead of our hand-rolled, out-of-line bitops.S. Signed-off-by: Will Deacon <will.deacon@arm.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-arm-kernel@lists.infradead.org Cc: yamada.masahiro@socionext.com Link: https://lore.kernel.org/lkml/1529412794-17720-9-git-send-email-will.deacon@arm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/arm64/include/asm/bitops.h14
-rw-r--r--arch/arm64/lib/Makefile2
-rw-r--r--arch/arm64/lib/bitops.S76
3 files changed, 3 insertions, 89 deletions
diff --git a/arch/arm64/include/asm/bitops.h b/arch/arm64/include/asm/bitops.h
index 9c19594ce7cb..13501460be6b 100644
--- a/arch/arm64/include/asm/bitops.h
+++ b/arch/arm64/include/asm/bitops.h
@@ -17,22 +17,11 @@
17#define __ASM_BITOPS_H 17#define __ASM_BITOPS_H
18 18
19#include <linux/compiler.h> 19#include <linux/compiler.h>
20#include <asm/barrier.h>
21 20
22#ifndef _LINUX_BITOPS_H 21#ifndef _LINUX_BITOPS_H
23#error only <linux/bitops.h> can be included directly 22#error only <linux/bitops.h> can be included directly
24#endif 23#endif
25 24
26/*
27 * Little endian assembly atomic bitops.
28 */
29extern void set_bit(int nr, volatile unsigned long *p);
30extern void clear_bit(int nr, volatile unsigned long *p);
31extern void change_bit(int nr, volatile unsigned long *p);
32extern int test_and_set_bit(int nr, volatile unsigned long *p);
33extern int test_and_clear_bit(int nr, volatile unsigned long *p);
34extern int test_and_change_bit(int nr, volatile unsigned long *p);
35
36#include <asm-generic/bitops/builtin-__ffs.h> 25#include <asm-generic/bitops/builtin-__ffs.h>
37#include <asm-generic/bitops/builtin-ffs.h> 26#include <asm-generic/bitops/builtin-ffs.h>
38#include <asm-generic/bitops/builtin-__fls.h> 27#include <asm-generic/bitops/builtin-__fls.h>
@@ -44,8 +33,9 @@ extern int test_and_change_bit(int nr, volatile unsigned long *p);
44 33
45#include <asm-generic/bitops/sched.h> 34#include <asm-generic/bitops/sched.h>
46#include <asm-generic/bitops/hweight.h> 35#include <asm-generic/bitops/hweight.h>
47#include <asm-generic/bitops/lock.h>
48 36
37#include <asm-generic/bitops/atomic.h>
38#include <asm-generic/bitops/lock.h>
49#include <asm-generic/bitops/non-atomic.h> 39#include <asm-generic/bitops/non-atomic.h>
50#include <asm-generic/bitops/le.h> 40#include <asm-generic/bitops/le.h>
51 41
diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile
index 137710f4dac3..68755fd70dcf 100644
--- a/arch/arm64/lib/Makefile
+++ b/arch/arm64/lib/Makefile
@@ -1,5 +1,5 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2lib-y := bitops.o clear_user.o delay.o copy_from_user.o \ 2lib-y := clear_user.o delay.o copy_from_user.o \
3 copy_to_user.o copy_in_user.o copy_page.o \ 3 copy_to_user.o copy_in_user.o copy_page.o \
4 clear_page.o memchr.o memcpy.o memmove.o memset.o \ 4 clear_page.o memchr.o memcpy.o memmove.o memset.o \
5 memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \ 5 memcmp.o strcmp.o strncmp.o strlen.o strnlen.o \
diff --git a/arch/arm64/lib/bitops.S b/arch/arm64/lib/bitops.S
deleted file mode 100644
index 43ac736baa5b..000000000000
--- a/arch/arm64/lib/bitops.S
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * Based on arch/arm/lib/bitops.h
3 *
4 * Copyright (C) 2013 ARM Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/linkage.h>
20#include <asm/assembler.h>
21#include <asm/lse.h>
22
23/*
24 * x0: bits 5:0 bit offset
25 * bits 31:6 word offset
26 * x1: address
27 */
28 .macro bitop, name, llsc, lse
29ENTRY( \name )
30 and w3, w0, #63 // Get bit offset
31 eor w0, w0, w3 // Clear low bits
32 mov x2, #1
33 add x1, x1, x0, lsr #3 // Get word offset
34alt_lse " prfm pstl1strm, [x1]", "nop"
35 lsl x3, x2, x3 // Create mask
36
37alt_lse "1: ldxr x2, [x1]", "\lse x3, [x1]"
38alt_lse " \llsc x2, x2, x3", "nop"
39alt_lse " stxr w0, x2, [x1]", "nop"
40alt_lse " cbnz w0, 1b", "nop"
41
42 ret
43ENDPROC(\name )
44 .endm
45
46 .macro testop, name, llsc, lse
47ENTRY( \name )
48 and w3, w0, #63 // Get bit offset
49 eor w0, w0, w3 // Clear low bits
50 mov x2, #1
51 add x1, x1, x0, lsr #3 // Get word offset
52alt_lse " prfm pstl1strm, [x1]", "nop"
53 lsl x4, x2, x3 // Create mask
54
55alt_lse "1: ldxr x2, [x1]", "\lse x4, x2, [x1]"
56 lsr x0, x2, x3
57alt_lse " \llsc x2, x2, x4", "nop"
58alt_lse " stlxr w5, x2, [x1]", "nop"
59alt_lse " cbnz w5, 1b", "nop"
60alt_lse " dmb ish", "nop"
61
62 and x0, x0, #1
63 ret
64ENDPROC(\name )
65 .endm
66
67/*
68 * Atomic bit operations.
69 */
70 bitop change_bit, eor, steor
71 bitop clear_bit, bic, stclr
72 bitop set_bit, orr, stset
73
74 testop test_and_change_bit, eor, ldeoral
75 testop test_and_clear_bit, bic, ldclral
76 testop test_and_set_bit, orr, ldsetal