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

ARM: 5897/1: spinlock: don't use deprecated barriers on ARMv7

On ARMv7, the use of the cp15 operations for barriers is deprecated
in favour of the isb, dsb, and dmb instructions. Change the locking
functions to use the appropriate type of dsb for the architecture
being built for.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Rabin Vincent and committed by
Russell King
c5113b61 24b44a66

+23 -13
+23 -13
arch/arm/include/asm/spinlock.h
··· 5 5 #error SMP not supported on pre-ARMv6 CPUs 6 6 #endif 7 7 8 + static inline void dsb_sev(void) 9 + { 10 + #if __LINUX_ARM_ARCH__ >= 7 11 + __asm__ __volatile__ ( 12 + "dsb\n" 13 + "sev" 14 + ); 15 + #elif defined(CONFIG_CPU_32v6K) 16 + __asm__ __volatile__ ( 17 + "mcr p15, 0, %0, c7, c10, 4\n" 18 + "sev" 19 + : : "r" (0) 20 + ); 21 + #endif 22 + } 23 + 8 24 /* 9 25 * ARMv6 Spin-locking. 10 26 * ··· 85 69 86 70 __asm__ __volatile__( 87 71 " str %1, [%0]\n" 88 - #ifdef CONFIG_CPU_32v6K 89 - " mcr p15, 0, %1, c7, c10, 4\n" /* DSB */ 90 - " sev" 91 - #endif 92 72 : 93 73 : "r" (&lock->lock), "r" (0) 94 74 : "cc"); 75 + 76 + dsb_sev(); 95 77 } 96 78 97 79 /* ··· 146 132 147 133 __asm__ __volatile__( 148 134 "str %1, [%0]\n" 149 - #ifdef CONFIG_CPU_32v6K 150 - " mcr p15, 0, %1, c7, c10, 4\n" /* DSB */ 151 - " sev\n" 152 - #endif 153 135 : 154 136 : "r" (&rw->lock), "r" (0) 155 137 : "cc"); 138 + 139 + dsb_sev(); 156 140 } 157 141 158 142 /* write_can_lock - would write_trylock() succeed? */ ··· 200 188 " strex %1, %0, [%2]\n" 201 189 " teq %1, #0\n" 202 190 " bne 1b" 203 - #ifdef CONFIG_CPU_32v6K 204 - "\n cmp %0, #0\n" 205 - " mcreq p15, 0, %0, c7, c10, 4\n" 206 - " seveq" 207 - #endif 208 191 : "=&r" (tmp), "=&r" (tmp2) 209 192 : "r" (&rw->lock) 210 193 : "cc"); 194 + 195 + if (tmp == 0) 196 + dsb_sev(); 211 197 } 212 198 213 199 static inline int arch_read_trylock(arch_rwlock_t *rw)