1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 #ifndef _ASM_POWERPC_IDLE_H 3 #define _ASM_POWERPC_IDLE_H 4 #include <asm/runlatch.h> 5 #include <asm/paca.h> 6 7 #ifdef CONFIG_PPC_PSERIES 8 static inline void pseries_idle_prolog(unsigned long *in_purr) 9 { 10 ppc64_runlatch_off(); 11 *in_purr = mfspr(SPRN_PURR); 12 /* 13 * Indicate to the HV that we are idle. Now would be 14 * a good time to find other work to dispatch. 15 */ 16 get_lppaca()->idle = 1; 17 } 18 19 static inline void pseries_idle_epilog(unsigned long in_purr) 20 { 21 u64 wait_cycles; 22 23 wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles); 24 wait_cycles += mfspr(SPRN_PURR) - in_purr; 25 get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles); 26 get_lppaca()->idle = 0; 27 28 ppc64_runlatch_on(); 29 } 30 #endif /* CONFIG_PPC_PSERIES */ 31 #endif 32