cpuidle : Move saving and restoring of sprs to opal
RFC 1/1 cpuidle : Move saving and restoring of sprs to opal
This patch moves the saving and restoring of sprs for P9 cpuidle from kernel to opal. This patch still uses existing code to detect first thread in core.
In an attempt to make the powernv idle code backward compatible, and to some extent forward compatible, add support for pre-stop entry and post-stop exit actions in OPAL. If a kernel knows about this opal call, then just a firmware supporting newer hardware is required, instead of waiting for kernel updates.
Signed-off-by Abhishek Goel <[email protected]>
---
Link to the Skiboot patch corresponding to this patch:
http://patchwork.ozlabs.org/patch/947568/
arch/powerpc/include/asm/cpuidle.h | 10 -- arch/powerpc/include/asm/opal-api.h | 4 +- arch/powerpc/include/asm/opal.h | 3 + arch/powerpc/include/asm/paca.h | 5 +- arch/powerpc/kernel/asm-offsets.c | 10 +- arch/powerpc/kernel/idle_book3s.S | 130 ++++++------------ arch/powerpc/platforms/powernv/idle.c | 4 + .../powerpc/platforms/powernv/opal-wrappers.S | 2 + arch/powerpc/xmon/xmon.c | 12 +- 9 files changed, 61 insertions(+), 119 deletions(-)
arch/powerpc/include/asm/cpuidle.h +0 -10
@@ -68,16 +68,6 @@#define ERR_DEEP_STATE_ESL_MISMATCH -2#ifndef __ASSEMBLY__ -/* Additional SPRs that need to be saved/restored during stop */ -struct stop_sprs { -u64 pid; -u64 ldbar; -u64 fscr; -u64 hfscr; -u64 mmcr1; -u64 mmcr2; -u64 mmcra; -};extern u32 pnv_fastsleep_workaround_at_entry[];extern u32 pnv_fastsleep_workaround_at_exit[];
arch/powerpc/include/asm/opal-api.h +3 -1
@@ -208,7 +208,9 @@#define OPAL_SENSOR_READ_U64 162#define OPAL_PCI_GET_PBCQ_TUNNEL_BAR 164#define OPAL_PCI_SET_PBCQ_TUNNEL_BAR 165 -#define OPAL_LAST 165 +#define OPAL_IDLE_SAVE 168 +#define OPAL_IDLE_RESTORE 169 +#define OPAL_LAST 169#define QUIESCE_HOLD 1/* Spin all calls at entry */ #define QUIESCE_REJECT 2/* Fail all calls with OPAL_BUSY */
arch/powerpc/include/asm/opal.h +3 -0
@@ -356,6 +356,9 @@ extern void opal_kmsg_init(void);extern int opal_event_request (unsigned int opal_event_nr); +extern int opal_cpuidle_save (u64 *stop_sprs,int scope,u64 psscr); +extern int opal_cpuidle_restore (u64 *stop_sprs,int scope,u64 psscr,u64 srr1); +struct opal_sg_list *opal_vmalloc_to_sg_list (void *vmalloc_addr,unsigned long vmalloc_size);void opal_free_sg_list (struct opal_sg_list *sg);
arch/powerpc/include/asm/paca.h +3 -2
@@ -195,11 +195,12 @@ struct paca_struct {/* The PSSCR value that the kernel requested before going to stop */ u64 requested_psscr; +u64 wakeup_psscr;/* -* Save area for additional SPRs that need to be +* Save area for SPRs that need to be * saved/restored during cpuidle stop. */ -struct stop_sprs stop_sprs; +u64 *opal_stop_sprs;#endif #ifdef CONFIG_PPC_BOOK3S_64
arch/powerpc/kernel/asm-offsets.c +2 -8
@@ -769,14 +769,8 @@ int main(void)OFFSET (PACA_SIBLING_PACA_PTRS , paca_struct, thread_sibling_pacas);OFFSET (PACA_REQ_PSSCR , paca_struct, requested_psscr);OFFSET (PACA_DONT_STOP , paca_struct, dont_stop); -#define STOP_SPR (x, f) OFFSET(x, paca_struct, stop_sprs.f) -STOP_SPR (STOP_PID , pid); -STOP_SPR (STOP_LDBAR , ldbar); -STOP_SPR (STOP_FSCR , fscr); -STOP_SPR (STOP_HFSCR , hfscr); -STOP_SPR (STOP_MMCR1 , mmcr1); -STOP_SPR (STOP_MMCR2 , mmcr2); -STOP_SPR (STOP_MMCRA , mmcra); +OFFSET (PACA_WAKEUP_PSSCR , paca_struct, wakeup_psscr); +OFFSET (STOP_SPRS , paca_struct, opal_stop_sprs);#endif DEFINE (PPC_DBELL_SERVER ,PPC_DBELL_SERVER );
arch/powerpc/kernel/idle_book3s.S +39 -91
192 lines not on this page · raw message
arch/powerpc/platforms/powernv/idle.c +4 -0
@@ -135,6 +135,7 @@ static int pnv_save_sprs_for_deep_states(void)return 0 ; } +#define MAX_STOP_SPRS_COUNT 25static void pnv_alloc_idle_core_states (void ) {int i, j;
@@ -174,6 +175,9 @@ static void pnv_alloc_idle_core_states(void)for (j =0 ; j < threads_per_core; j++) {int cpu = first_cpu + j; + paca_ptrs[cpu]->opal_stop_sprs =kmalloc_node ( +MAX_STOP_SPRS_COUNT *sizeof (u64), +GFP_KERNEL , node); paca_ptrs[cpu]->core_idle_state_ptr = core_idle_state; paca_ptrs[cpu]->thread_idle_state =PNV_THREAD_RUNNING ; paca_ptrs[cpu]->thread_mask =1 << j;
arch/powerpc/platforms/powernv/opal-wrappers.S +2 -0
@@ -327,3 +327,5 @@ OPAL_CALL(opal_npu_tl_set, OPAL_NPU_TL_SET); OPAL_CALL(opal_pci_get_pbcq_tunnel_bar, OPAL_PCI_GET_PBCQ_TUNNEL_BAR); OPAL_CALL(opal_pci_set_pbcq_tunnel_bar, OPAL_PCI_SET_PBCQ_TUNNEL_BAR); OPAL_CALL(opal_sensor_read_u64, OPAL_SENSOR_READ_U64); +OPAL_CALL(opal_cpuidle_save, OPAL_IDLE_SAVE); +OPAL_CALL(opal_cpuidle_restore, OPAL_IDLE_RESTORE);
arch/powerpc/xmon/xmon.c +5 -7
@@ -2431,14 +2431,12 @@ static void dump_one_paca(int cpu)DUMP (p, subcore_sibling_mask,"%#-*x" );DUMP (p, thread_sibling_pacas,"%-*px" );DUMP (p, requested_psscr,"%#-*llx" ); -DUMP (p, stop_sprs.pid,"%#-*llx" ); -DUMP (p, stop_sprs.ldbar,"%#-*llx" ); -DUMP (p, stop_sprs.fscr,"%#-*llx" ); -DUMP (p, stop_sprs.hfscr,"%#-*llx" ); -DUMP (p, stop_sprs.mmcr1,"%#-*llx" ); -DUMP (p, stop_sprs.mmcr2,"%#-*llx" ); -DUMP (p, stop_sprs.mmcra,"%#-*llx" );DUMP (p, dont_stop.counter,"%#-*x" ); + +/* TODO paca still has sprs stored, but only opal knows the index for +* each spr. We can find a way to make the indices available to kernel. +*/ +#endif DUMP (p, accounting.utime,"%#-*lx" );
Signature · 1 line
2.17.0