Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

provide arch_test_bit_acquire for architectures that define test_bit

Some architectures define their own arch_test_bit and they also need
arch_test_bit_acquire, otherwise they won't compile. We also clean up
the code by using the generic test_bit if that is equivalent to the
arch-specific version.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Fixes: 8238b4579866 ("wait_on_bit: add an acquire memory barrier")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mikulas Patocka and committed by
Linus Torvalds
d6ffe606 e022620b

+25 -33
+2 -5
arch/alpha/include/asm/bitops.h
··· 283 283 return (old & mask) != 0; 284 284 } 285 285 286 - static __always_inline bool 287 - arch_test_bit(unsigned long nr, const volatile unsigned long *addr) 288 - { 289 - return (1UL & (((const int *) addr)[nr >> 5] >> (nr & 31))) != 0UL; 290 - } 286 + #define arch_test_bit generic_test_bit 287 + #define arch_test_bit_acquire generic_test_bit_acquire 291 288 292 289 /* 293 290 * ffz = Find First Zero in word. Undefined if no zero exists,
+15
arch/hexagon/include/asm/bitops.h
··· 179 179 return retval; 180 180 } 181 181 182 + static __always_inline bool 183 + arch_test_bit_acquire(unsigned long nr, const volatile unsigned long *addr) 184 + { 185 + int retval; 186 + 187 + asm volatile( 188 + "{P0 = tstbit(%1,%2); if (P0.new) %0 = #1; if (!P0.new) %0 = #0;}\n" 189 + : "=&r" (retval) 190 + : "r" (addr[BIT_WORD(nr)]), "r" (nr % BITS_PER_LONG) 191 + : "p0", "memory" 192 + ); 193 + 194 + return retval; 195 + } 196 + 182 197 /* 183 198 * ffz - find first zero in word. 184 199 * @word: The word to search
+2 -5
arch/ia64/include/asm/bitops.h
··· 331 331 return (old & bit) != 0; 332 332 } 333 333 334 - static __always_inline bool 335 - arch_test_bit(unsigned long nr, const volatile unsigned long *addr) 336 - { 337 - return 1 & (((const volatile __u32 *) addr)[nr >> 5] >> (nr & 31)); 338 - } 334 + #define arch_test_bit generic_test_bit 335 + #define arch_test_bit_acquire generic_test_bit_acquire 339 336 340 337 /** 341 338 * ffz - find the first zero bit in a long word
+2 -5
arch/m68k/include/asm/bitops.h
··· 157 157 change_bit(nr, addr); 158 158 } 159 159 160 - static __always_inline bool 161 - arch_test_bit(unsigned long nr, const volatile unsigned long *addr) 162 - { 163 - return (addr[nr >> 5] & (1UL << (nr & 31))) != 0; 164 - } 160 + #define arch_test_bit generic_test_bit 161 + #define arch_test_bit_acquire generic_test_bit_acquire 165 162 166 163 static inline int bset_reg_test_and_set_bit(int nr, 167 164 volatile unsigned long *vaddr)
+2 -8
arch/s390/include/asm/bitops.h
··· 176 176 return old & mask; 177 177 } 178 178 179 - static __always_inline bool 180 - arch_test_bit(unsigned long nr, const volatile unsigned long *addr) 181 - { 182 - const volatile unsigned long *p = __bitops_word(nr, addr); 183 - unsigned long mask = __bitops_mask(nr); 184 - 185 - return *p & mask; 186 - } 179 + #define arch_test_bit generic_test_bit 180 + #define arch_test_bit_acquire generic_test_bit_acquire 187 181 188 182 static inline bool arch_test_and_set_bit_lock(unsigned long nr, 189 183 volatile unsigned long *ptr)
+2 -10
arch/sh/include/asm/bitops-op32.h
··· 135 135 return (old & mask) != 0; 136 136 } 137 137 138 - /** 139 - * arch_test_bit - Determine whether a bit is set 140 - * @nr: bit number to test 141 - * @addr: Address to start counting from 142 - */ 143 - static __always_inline bool 144 - arch_test_bit(unsigned long nr, const volatile unsigned long *addr) 145 - { 146 - return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); 147 - } 138 + #define arch_test_bit generic_test_bit 139 + #define arch_test_bit_acquire generic_test_bit_acquire 148 140 149 141 #include <asm-generic/bitops/non-instrumented-non-atomic.h> 150 142