xref: /linux/arch/sparc/include/asm/vdso/processor.h (revision f21f7b5162e9dbde6d3d5ce727d4ca2552d76ce9)
1*e13e3059SThomas Weißschuh /* SPDX-License-Identifier: GPL-2.0 */
2*e13e3059SThomas Weißschuh 
3*e13e3059SThomas Weißschuh #ifndef _ASM_SPARC_VDSO_PROCESSOR_H
4*e13e3059SThomas Weißschuh #define _ASM_SPARC_VDSO_PROCESSOR_H
5*e13e3059SThomas Weißschuh 
6*e13e3059SThomas Weißschuh #include <linux/compiler.h>
7*e13e3059SThomas Weißschuh 
8*e13e3059SThomas Weißschuh #if defined(__arch64__)
9*e13e3059SThomas Weißschuh 
10*e13e3059SThomas Weißschuh /* Please see the commentary in asm/backoff.h for a description of
11*e13e3059SThomas Weißschuh  * what these instructions are doing and how they have been chosen.
12*e13e3059SThomas Weißschuh  * To make a long story short, we are trying to yield the current cpu
13*e13e3059SThomas Weißschuh  * strand during busy loops.
14*e13e3059SThomas Weißschuh  */
15*e13e3059SThomas Weißschuh #ifdef	BUILD_VDSO
16*e13e3059SThomas Weißschuh #define	cpu_relax()	asm volatile("\n99:\n\t"			\
17*e13e3059SThomas Weißschuh 				     "rd	%%ccr, %%g0\n\t"	\
18*e13e3059SThomas Weißschuh 				     "rd	%%ccr, %%g0\n\t"	\
19*e13e3059SThomas Weißschuh 				     "rd	%%ccr, %%g0\n\t"	\
20*e13e3059SThomas Weißschuh 				     ::: "memory")
21*e13e3059SThomas Weißschuh #else /* ! BUILD_VDSO */
22*e13e3059SThomas Weißschuh #define cpu_relax()	asm volatile("\n99:\n\t"			\
23*e13e3059SThomas Weißschuh 				     "rd	%%ccr, %%g0\n\t"	\
24*e13e3059SThomas Weißschuh 				     "rd	%%ccr, %%g0\n\t"	\
25*e13e3059SThomas Weißschuh 				     "rd	%%ccr, %%g0\n\t"	\
26*e13e3059SThomas Weißschuh 				     ".section	.pause_3insn_patch,\"ax\"\n\t"\
27*e13e3059SThomas Weißschuh 				     ".word	99b\n\t"		\
28*e13e3059SThomas Weißschuh 				     "wr	%%g0, 128, %%asr27\n\t"	\
29*e13e3059SThomas Weißschuh 				     "nop\n\t"				\
30*e13e3059SThomas Weißschuh 				     "nop\n\t"				\
31*e13e3059SThomas Weißschuh 				     ".previous"			\
32*e13e3059SThomas Weißschuh 				     ::: "memory")
33*e13e3059SThomas Weißschuh #endif /* BUILD_VDSO */
34*e13e3059SThomas Weißschuh 
35*e13e3059SThomas Weißschuh #else /* ! __arch64__ */
36*e13e3059SThomas Weißschuh 
37*e13e3059SThomas Weißschuh #define cpu_relax()	barrier()
38*e13e3059SThomas Weißschuh 
39*e13e3059SThomas Weißschuh #endif /* __arch64__ */
40*e13e3059SThomas Weißschuh 
41*e13e3059SThomas Weißschuh #endif /* _ASM_SPARC_VDSO_PROCESSOR_H */
42