.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * PowerPC atomic bit operations. |
---|
3 | 4 | * |
---|
.. | .. |
---|
26 | 27 | * The main difference is that bit 3-5 (64b) or 3-4 (32b) in the bit |
---|
27 | 28 | * number field needs to be reversed compared to the big-endian bit |
---|
28 | 29 | * fields. This can be achieved by XOR with 0x38 (64b) or 0x18 (32b). |
---|
29 | | - * |
---|
30 | | - * This program is free software; you can redistribute it and/or |
---|
31 | | - * modify it under the terms of the GNU General Public License |
---|
32 | | - * as published by the Free Software Foundation; either version |
---|
33 | | - * 2 of the License, or (at your option) any later version. |
---|
34 | 30 | */ |
---|
35 | 31 | |
---|
36 | 32 | #ifndef _ASM_POWERPC_BITOPS_H |
---|
.. | .. |
---|
45 | 41 | #include <linux/compiler.h> |
---|
46 | 42 | #include <asm/asm-compat.h> |
---|
47 | 43 | #include <asm/synch.h> |
---|
48 | | -#include <asm/asm-405.h> |
---|
49 | 44 | |
---|
50 | 45 | /* PPC bit number conversion */ |
---|
51 | 46 | #define PPC_BITLSHIFT(be) (BITS_PER_LONG - 1 - (be)) |
---|
.. | .. |
---|
68 | 63 | |
---|
69 | 64 | /* Macro for generating the ***_bits() functions */ |
---|
70 | 65 | #define DEFINE_BITOP(fn, op, prefix) \ |
---|
71 | | -static __inline__ void fn(unsigned long mask, \ |
---|
| 66 | +static inline void fn(unsigned long mask, \ |
---|
72 | 67 | volatile unsigned long *_p) \ |
---|
73 | 68 | { \ |
---|
74 | 69 | unsigned long old; \ |
---|
.. | .. |
---|
77 | 72 | prefix \ |
---|
78 | 73 | "1:" PPC_LLARX(%0,0,%3,0) "\n" \ |
---|
79 | 74 | stringify_in_c(op) "%0,%0,%2\n" \ |
---|
80 | | - PPC405_ERR77(0,%3) \ |
---|
81 | 75 | PPC_STLCX "%0,0,%3\n" \ |
---|
82 | 76 | "bne- 1b\n" \ |
---|
83 | 77 | : "=&r" (old), "+m" (*p) \ |
---|
.. | .. |
---|
90 | 84 | DEFINE_BITOP(clear_bits_unlock, andc, PPC_RELEASE_BARRIER) |
---|
91 | 85 | DEFINE_BITOP(change_bits, xor, "") |
---|
92 | 86 | |
---|
93 | | -static __inline__ void set_bit(int nr, volatile unsigned long *addr) |
---|
| 87 | +static inline void arch_set_bit(int nr, volatile unsigned long *addr) |
---|
94 | 88 | { |
---|
95 | 89 | set_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); |
---|
96 | 90 | } |
---|
97 | 91 | |
---|
98 | | -static __inline__ void clear_bit(int nr, volatile unsigned long *addr) |
---|
| 92 | +static inline void arch_clear_bit(int nr, volatile unsigned long *addr) |
---|
99 | 93 | { |
---|
100 | 94 | clear_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); |
---|
101 | 95 | } |
---|
102 | 96 | |
---|
103 | | -static __inline__ void clear_bit_unlock(int nr, volatile unsigned long *addr) |
---|
| 97 | +static inline void arch_clear_bit_unlock(int nr, volatile unsigned long *addr) |
---|
104 | 98 | { |
---|
105 | 99 | clear_bits_unlock(BIT_MASK(nr), addr + BIT_WORD(nr)); |
---|
106 | 100 | } |
---|
107 | 101 | |
---|
108 | | -static __inline__ void change_bit(int nr, volatile unsigned long *addr) |
---|
| 102 | +static inline void arch_change_bit(int nr, volatile unsigned long *addr) |
---|
109 | 103 | { |
---|
110 | 104 | change_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); |
---|
111 | 105 | } |
---|
.. | .. |
---|
113 | 107 | /* Like DEFINE_BITOP(), with changes to the arguments to 'op' and the output |
---|
114 | 108 | * operands. */ |
---|
115 | 109 | #define DEFINE_TESTOP(fn, op, prefix, postfix, eh) \ |
---|
116 | | -static __inline__ unsigned long fn( \ |
---|
| 110 | +static inline unsigned long fn( \ |
---|
117 | 111 | unsigned long mask, \ |
---|
118 | 112 | volatile unsigned long *_p) \ |
---|
119 | 113 | { \ |
---|
.. | .. |
---|
123 | 117 | prefix \ |
---|
124 | 118 | "1:" PPC_LLARX(%0,0,%3,eh) "\n" \ |
---|
125 | 119 | stringify_in_c(op) "%1,%0,%2\n" \ |
---|
126 | | - PPC405_ERR77(0,%3) \ |
---|
127 | 120 | PPC_STLCX "%1,0,%3\n" \ |
---|
128 | 121 | "bne- 1b\n" \ |
---|
129 | 122 | postfix \ |
---|
.. | .. |
---|
142 | 135 | DEFINE_TESTOP(test_and_change_bits, xor, PPC_ATOMIC_ENTRY_BARRIER, |
---|
143 | 136 | PPC_ATOMIC_EXIT_BARRIER, 0) |
---|
144 | 137 | |
---|
145 | | -static __inline__ int test_and_set_bit(unsigned long nr, |
---|
146 | | - volatile unsigned long *addr) |
---|
| 138 | +static inline int arch_test_and_set_bit(unsigned long nr, |
---|
| 139 | + volatile unsigned long *addr) |
---|
147 | 140 | { |
---|
148 | 141 | return test_and_set_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0; |
---|
149 | 142 | } |
---|
150 | 143 | |
---|
151 | | -static __inline__ int test_and_set_bit_lock(unsigned long nr, |
---|
152 | | - volatile unsigned long *addr) |
---|
| 144 | +static inline int arch_test_and_set_bit_lock(unsigned long nr, |
---|
| 145 | + volatile unsigned long *addr) |
---|
153 | 146 | { |
---|
154 | 147 | return test_and_set_bits_lock(BIT_MASK(nr), |
---|
155 | 148 | addr + BIT_WORD(nr)) != 0; |
---|
156 | 149 | } |
---|
157 | 150 | |
---|
158 | | -static __inline__ int test_and_clear_bit(unsigned long nr, |
---|
159 | | - volatile unsigned long *addr) |
---|
| 151 | +static inline int arch_test_and_clear_bit(unsigned long nr, |
---|
| 152 | + volatile unsigned long *addr) |
---|
160 | 153 | { |
---|
161 | 154 | return test_and_clear_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0; |
---|
162 | 155 | } |
---|
163 | 156 | |
---|
164 | | -static __inline__ int test_and_change_bit(unsigned long nr, |
---|
165 | | - volatile unsigned long *addr) |
---|
| 157 | +static inline int arch_test_and_change_bit(unsigned long nr, |
---|
| 158 | + volatile unsigned long *addr) |
---|
166 | 159 | { |
---|
167 | 160 | return test_and_change_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0; |
---|
168 | 161 | } |
---|
169 | 162 | |
---|
170 | 163 | #ifdef CONFIG_PPC64 |
---|
171 | | -static __inline__ unsigned long clear_bit_unlock_return_word(int nr, |
---|
172 | | - volatile unsigned long *addr) |
---|
| 164 | +static inline unsigned long |
---|
| 165 | +clear_bit_unlock_return_word(int nr, volatile unsigned long *addr) |
---|
173 | 166 | { |
---|
174 | 167 | unsigned long old, t; |
---|
175 | 168 | unsigned long *p = (unsigned long *)addr + BIT_WORD(nr); |
---|
.. | .. |
---|
179 | 172 | PPC_RELEASE_BARRIER |
---|
180 | 173 | "1:" PPC_LLARX(%0,0,%3,0) "\n" |
---|
181 | 174 | "andc %1,%0,%2\n" |
---|
182 | | - PPC405_ERR77(0,%3) |
---|
183 | 175 | PPC_STLCX "%1,0,%3\n" |
---|
184 | 176 | "bne- 1b\n" |
---|
185 | 177 | : "=&r" (old), "=&r" (t) |
---|
.. | .. |
---|
189 | 181 | return old; |
---|
190 | 182 | } |
---|
191 | 183 | |
---|
192 | | -/* This is a special function for mm/filemap.c */ |
---|
193 | | -#define clear_bit_unlock_is_negative_byte(nr, addr) \ |
---|
194 | | - (clear_bit_unlock_return_word(nr, addr) & BIT_MASK(PG_waiters)) |
---|
| 184 | +/* |
---|
| 185 | + * This is a special function for mm/filemap.c |
---|
| 186 | + * Bit 7 corresponds to PG_waiters. |
---|
| 187 | + */ |
---|
| 188 | +#define arch_clear_bit_unlock_is_negative_byte(nr, addr) \ |
---|
| 189 | + (clear_bit_unlock_return_word(nr, addr) & BIT_MASK(7)) |
---|
195 | 190 | |
---|
196 | 191 | #endif /* CONFIG_PPC64 */ |
---|
197 | 192 | |
---|
198 | 193 | #include <asm-generic/bitops/non-atomic.h> |
---|
199 | 194 | |
---|
200 | | -static __inline__ void __clear_bit_unlock(int nr, volatile unsigned long *addr) |
---|
| 195 | +static inline void arch___clear_bit_unlock(int nr, volatile unsigned long *addr) |
---|
201 | 196 | { |
---|
202 | 197 | __asm__ __volatile__(PPC_RELEASE_BARRIER "" ::: "memory"); |
---|
203 | 198 | __clear_bit(nr, addr); |
---|
.. | .. |
---|
219 | 214 | * fls: find last (most-significant) bit set. |
---|
220 | 215 | * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. |
---|
221 | 216 | */ |
---|
222 | | -static __inline__ int fls(unsigned int x) |
---|
| 217 | +static inline int fls(unsigned int x) |
---|
223 | 218 | { |
---|
224 | 219 | int lz; |
---|
225 | 220 | |
---|
.. | .. |
---|
237 | 232 | * 32-bit fls calls. |
---|
238 | 233 | */ |
---|
239 | 234 | #ifdef CONFIG_PPC64 |
---|
240 | | -static __inline__ int fls64(__u64 x) |
---|
| 235 | +static inline int fls64(__u64 x) |
---|
241 | 236 | { |
---|
242 | 237 | int lz; |
---|
243 | 238 | |
---|
.. | .. |
---|
262 | 257 | |
---|
263 | 258 | #include <asm-generic/bitops/find.h> |
---|
264 | 259 | |
---|
| 260 | +/* wrappers that deal with KASAN instrumentation */ |
---|
| 261 | +#include <asm-generic/bitops/instrumented-atomic.h> |
---|
| 262 | +#include <asm-generic/bitops/instrumented-lock.h> |
---|
| 263 | + |
---|
265 | 264 | /* Little-endian versions */ |
---|
266 | 265 | #include <asm-generic/bitops/le.h> |
---|
267 | 266 | |
---|