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

MIPS: Adjust set_pte() SMP fix to handle R10000_LLSC_WAR

Update the recent changes to set_pte() that were added in 46011e6ea392
to handle R10000_LLSC_WAR, and format the assembly to match other areas
of the MIPS tree using the same WAR.

This also incorporates a patch recently sent in my Markos Chandras,
"Remove local LL/SC preprocessor variants", so that patch doesn't need
to be applied if this one is accepted.

Signed-off-by: Joshua Kinard <kumba@gentoo.org>
Fixes: 46011e6ea392 ("MIPS: Make set_pte() SMP safe.)
Cc: David Daney <david.daney@cavium.com>
Cc: Linux/MIPS <linux-mips@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/11103/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Joshua Kinard and committed by
Ralf Baechle
12863939 05490626

+32 -13
+32 -13
arch/mips/include/asm/pgtable.h
··· 190 190 unsigned long page_global = _PAGE_GLOBAL; 191 191 unsigned long tmp; 192 192 193 - __asm__ __volatile__ ( 194 - " .set push\n" 195 - " .set noreorder\n" 196 - "1: " __LL " %[tmp], %[buddy]\n" 197 - " bnez %[tmp], 2f\n" 198 - " or %[tmp], %[tmp], %[global]\n" 199 - " " __SC " %[tmp], %[buddy]\n" 200 - " beqz %[tmp], 1b\n" 201 - " nop\n" 202 - "2:\n" 203 - " .set pop" 204 - : [buddy] "+m" (buddy->pte), 205 - [tmp] "=&r" (tmp) 193 + if (kernel_uses_llsc && R10000_LLSC_WAR) { 194 + __asm__ __volatile__ ( 195 + " .set arch=r4000 \n" 196 + " .set push \n" 197 + " .set noreorder \n" 198 + "1:" __LL "%[tmp], %[buddy] \n" 199 + " bnez %[tmp], 2f \n" 200 + " or %[tmp], %[tmp], %[global] \n" 201 + __SC "%[tmp], %[buddy] \n" 202 + " beqzl %[tmp], 1b \n" 203 + " nop \n" 204 + "2: \n" 205 + " .set pop \n" 206 + " .set mips0 \n" 207 + : [buddy] "+m" (buddy->pte), [tmp] "=&r" (tmp) 206 208 : [global] "r" (page_global)); 209 + } else if (kernel_uses_llsc) { 210 + __asm__ __volatile__ ( 211 + " .set "MIPS_ISA_ARCH_LEVEL" \n" 212 + " .set push \n" 213 + " .set noreorder \n" 214 + "1:" __LL "%[tmp], %[buddy] \n" 215 + " bnez %[tmp], 2f \n" 216 + " or %[tmp], %[tmp], %[global] \n" 217 + __SC "%[tmp], %[buddy] \n" 218 + " beqz %[tmp], 1b \n" 219 + " nop \n" 220 + "2: \n" 221 + " .set pop \n" 222 + " .set mips0 \n" 223 + : [buddy] "+m" (buddy->pte), [tmp] "=&r" (tmp) 224 + : [global] "r" (page_global)); 225 + } 207 226 #else /* !CONFIG_SMP */ 208 227 if (pte_none(*buddy)) 209 228 pte_val(*buddy) = pte_val(*buddy) | _PAGE_GLOBAL;