xref: /linux/arch/powerpc/include/asm/runlatch.h (revision e7d759f31ca295d589f7420719c311870bb3166f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
4  */
5 #ifndef _ASM_POWERPC_RUNLATCH_H
6 #define _ASM_POWERPC_RUNLATCH_H
7 
8 #ifdef CONFIG_PPC64
9 
10 extern void __ppc64_runlatch_on(void);
11 extern void __ppc64_runlatch_off(void);
12 
13 /*
14  * We manually hard enable-disable, this is called
15  * in the idle loop and we don't want to mess up
16  * with soft-disable/enable & interrupt replay.
17  */
18 #define ppc64_runlatch_off()					\
19 	do {							\
20 		if (cpu_has_feature(CPU_FTR_CTRL) &&		\
21 		    test_thread_local_flags(_TLF_RUNLATCH)) {	\
22 			__hard_irq_disable();			\
23 			__ppc64_runlatch_off();			\
24 			if (!(local_paca->irq_happened & PACA_IRQ_HARD_DIS)) \
25 				__hard_irq_enable();		\
26 		}      						\
27 	} while (0)
28 
29 #define ppc64_runlatch_on()					\
30 	do {							\
31 		if (cpu_has_feature(CPU_FTR_CTRL) &&		\
32 		    !test_thread_local_flags(_TLF_RUNLATCH)) {	\
33 			__hard_irq_disable();			\
34 			__ppc64_runlatch_on();			\
35 			if (!(local_paca->irq_happened & PACA_IRQ_HARD_DIS)) \
36 				__hard_irq_enable();		\
37 		}      						\
38 	} while (0)
39 #else
40 #define ppc64_runlatch_on()
41 #define ppc64_runlatch_off()
42 #endif /* CONFIG_PPC64 */
43 
44 #endif /* _ASM_POWERPC_RUNLATCH_H */
45