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

powerpc: use spin loop primitives in some functions

Use the different spin loop primitives in some simple powerpc
spin loops, including those which will spin as a common case.

This will help to test the spin loop primitives before more
conversions are done.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Add some includes of <linux/processor.h>]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Nicholas Piggin and committed by
Michael Ellerman
4e287e65 ede8e2bb

+23 -10
+12 -4
arch/powerpc/include/asm/delay.h
··· 2 2 #define _ASM_POWERPC_DELAY_H 3 3 #ifdef __KERNEL__ 4 4 5 + #include <linux/processor.h> 5 6 #include <asm/time.h> 6 7 7 8 /* ··· 59 58 typeof(condition) __ret; \ 60 59 unsigned long __loops = tb_ticks_per_usec * timeout; \ 61 60 unsigned long __start = get_tbl(); \ 62 - while (!(__ret = (condition)) && (tb_ticks_since(__start) <= __loops)) \ 63 - if (delay) \ 61 + \ 62 + if (delay) { \ 63 + while (!(__ret = (condition)) && \ 64 + (tb_ticks_since(__start) <= __loops)) \ 64 65 udelay(delay); \ 65 - else \ 66 - cpu_relax(); \ 66 + } else { \ 67 + spin_begin(); \ 68 + while (!(__ret = (condition)) && \ 69 + (tb_ticks_since(__start) <= __loops)) \ 70 + spin_cpu_relax(); \ 71 + spin_end(); \ 72 + } \ 67 73 if (!__ret) \ 68 74 __ret = (condition); \ 69 75 __ret; \
+2 -2
arch/powerpc/kernel/smp.c
··· 33 33 #include <linux/notifier.h> 34 34 #include <linux/topology.h> 35 35 #include <linux/profile.h> 36 + #include <linux/processor.h> 36 37 37 38 #include <asm/ptrace.h> 38 39 #include <linux/atomic.h> ··· 768 767 smp_ops->give_timebase(); 769 768 770 769 /* Wait until cpu puts itself in the online & active maps */ 771 - while (!cpu_online(cpu)) 772 - cpu_relax(); 770 + spin_until_cond(cpu_online(cpu)); 773 771 774 772 return 0; 775 773 }
+5 -3
arch/powerpc/kernel/time.c
··· 59 59 #include <linux/suspend.h> 60 60 #include <linux/rtc.h> 61 61 #include <linux/sched/cputime.h> 62 + #include <linux/processor.h> 62 63 #include <asm/trace.h> 63 64 64 65 #include <asm/io.h> 65 - #include <asm/processor.h> 66 66 #include <asm/nvram.h> 67 67 #include <asm/cache.h> 68 68 #include <asm/machdep.h> ··· 442 442 unsigned long start; 443 443 int diff; 444 444 445 + spin_begin(); 445 446 if (__USE_RTC()) { 446 447 start = get_rtcl(); 447 448 do { ··· 450 449 diff = get_rtcl() - start; 451 450 if (diff < 0) 452 451 diff += 1000000000; 452 + spin_cpu_relax(); 453 453 } while (diff < loops); 454 454 } else { 455 455 start = get_tbl(); 456 456 while (get_tbl() - start < loops) 457 - HMT_low(); 458 - HMT_medium(); 457 + spin_cpu_relax(); 459 458 } 459 + spin_end(); 460 460 } 461 461 EXPORT_SYMBOL(__delay); 462 462
+4 -1
arch/powerpc/mm/hash_native_64.c
··· 15 15 #include <linux/spinlock.h> 16 16 #include <linux/bitops.h> 17 17 #include <linux/of.h> 18 + #include <linux/processor.h> 18 19 #include <linux/threads.h> 19 20 #include <linux/smp.h> 20 21 ··· 185 184 while (1) { 186 185 if (!test_and_set_bit_lock(HPTE_LOCK_BIT, word)) 187 186 break; 187 + spin_begin(); 188 188 while(test_bit(HPTE_LOCK_BIT, word)) 189 - cpu_relax(); 189 + spin_cpu_relax(); 190 + spin_end(); 190 191 } 191 192 } 192 193