powerpc: Move idle_loop_prolog()/epilog() functions to header file
Currently prior to entering an idle state on a Linux Guest, the pseries cpuidle driver implement an idle_loop_prolog() and idle_loop_epilog() functions which ensure that idle_purr is correctly computed, and the hypervisor is informed that the CPU cycles have been donated. These prolog and epilog functions are also required in the default idle call, i.e pseries_lpar_idle(). Hence move these accessor functions to a common header file and call them from pseries_lpar_idle(). Since the existing header files such as asm/processor.h have enough clutter, create a new header file asm/idle.h. Finally rename idle_loop_prolog() and idle_loop_epilog() to pseries_idle_prolog() and pseries_idle_epilog() as they are only relavent for on pseries guests. Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/1586249263-14048-2-git-send-email-ego@linux.vnet.ibm.com
This commit is contained in:

committed by
Michael Ellerman

parent
45591da765
commit
e4a884cc28
31
arch/powerpc/include/asm/idle.h
Normal file
31
arch/powerpc/include/asm/idle.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#ifndef _ASM_POWERPC_IDLE_H
|
||||
#define _ASM_POWERPC_IDLE_H
|
||||
#include <asm/runlatch.h>
|
||||
#include <asm/paca.h>
|
||||
|
||||
#ifdef CONFIG_PPC_PSERIES
|
||||
static inline void pseries_idle_prolog(unsigned long *in_purr)
|
||||
{
|
||||
ppc64_runlatch_off();
|
||||
*in_purr = mfspr(SPRN_PURR);
|
||||
/*
|
||||
* Indicate to the HV that we are idle. Now would be
|
||||
* a good time to find other work to dispatch.
|
||||
*/
|
||||
get_lppaca()->idle = 1;
|
||||
}
|
||||
|
||||
static inline void pseries_idle_epilog(unsigned long in_purr)
|
||||
{
|
||||
u64 wait_cycles;
|
||||
|
||||
wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles);
|
||||
wait_cycles += mfspr(SPRN_PURR) - in_purr;
|
||||
get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles);
|
||||
get_lppaca()->idle = 0;
|
||||
|
||||
ppc64_runlatch_on();
|
||||
}
|
||||
#endif /* CONFIG_PPC_PSERIES */
|
||||
#endif
|
Reference in New Issue
Block a user