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