Skip to content

Commit a67cc59

Browse files
committed
Revert "powerpc/64s/idle: POWER9 ESL=0 stop avoid save/restore overhead"
As described in that commit: When stop is executed with EC=ESL=0, it appears to execute like a normal instruction (resuming from NIP when woken by interrupt). So all the save/restore handling can be avoided completely. This is true, except in the case of an NMI interrupt (sreset or machine check) interrupting the instruction. In that case, the NMI gets an "interrupt occurred while the processor was in power-saving mode" indication. The power-save wakeup code uses that bit to decide whether to restore some registers (e.g., LR). Because these are no longer saved, this causes random register corruption. It may be possible to restore this optimisation by detecting the case of no register loss on the wakeup side, and avoid restoring in that case, but that's not a minor fix because the wakeup code itself uses some registers that would be live (e.g., LR). Fixes: b9ee31e ("powerpc/64s/idle: POWER9 ESL=0 stop avoid save/restore overhead") Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 07c3d9e commit a67cc59

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

arch/powerpc/kernel/idle_book3s.S

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,32 @@ enter_winkle:
324324
/*
325325
* r3 - PSSCR value corresponding to the requested stop state.
326326
*/
327-
power_enter_stop_esl:
327+
power_enter_stop:
328+
/*
329+
* Check if we are executing the lite variant with ESL=EC=0
330+
*/
331+
andis. r4,r3,PSSCR_EC_ESL_MASK_SHIFTED
328332
clrldi r3,r3,60 /* r3 = Bits[60:63] = Requested Level (RL) */
333+
bne .Lhandle_esl_ec_set
334+
PPC_STOP
335+
li r3,0 /* Since we didn't lose state, return 0 */
336+
std r3, PACA_REQ_PSSCR(r13)
337+
338+
/*
339+
* pnv_wakeup_noloss() expects r12 to contain the SRR1 value so
340+
* it can determine if the wakeup reason is an HMI in
341+
* CHECK_HMI_INTERRUPT.
342+
*
343+
* However, when we wakeup with ESL=0, SRR1 will not contain the wakeup
344+
* reason, so there is no point setting r12 to SRR1.
345+
*
346+
* Further, we clear r12 here, so that we don't accidentally enter the
347+
* HMI in pnv_wakeup_noloss() if the value of r12[42:45] == WAKE_HMI.
348+
*/
349+
li r12, 0
350+
b pnv_wakeup_noloss
351+
352+
.Lhandle_esl_ec_set:
329353
BEGIN_FTR_SECTION
330354
/*
331355
* POWER9 DD2.0 or earlier can incorrectly set PMAO when waking up after
@@ -417,32 +441,21 @@ _GLOBAL(power9_offline_stop)
417441
/* fall through */
418442

419443
_GLOBAL(power9_idle_stop)
420-
mtspr SPRN_PSSCR,r3
421-
/*
422-
* The ESL=EC=0 case does not wake up at 0x100, and it does not
423-
* allow SMT mode switching, so it does not require PSSCR to be
424-
* saved.
425-
*/
426-
andis. r4,r3,PSSCR_EC_ESL_MASK_SHIFTED
427-
bne 1f
428-
PPC_STOP
429-
li r3,0 /* Since we didn't lose state, return 0 */
430-
blr
431-
1:
432444
std r3, PACA_REQ_PSSCR(r13)
433445
#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
434446
BEGIN_FTR_SECTION
435447
sync
436448
lwz r5, PACA_DONT_STOP(r13)
437449
cmpwi r5, 0
438-
bne 2f
450+
bne 1f
439451
END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_XER_SO_BUG)
440452
#endif
441-
LOAD_REG_ADDR(r4,power_enter_stop_esl)
453+
mtspr SPRN_PSSCR,r3
454+
LOAD_REG_ADDR(r4,power_enter_stop)
442455
b pnv_powersave_common
443456
/* No return */
444457
#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
445-
2:
458+
1:
446459
/*
447460
* We get here when TM / thread reconfiguration bug workaround
448461
* code wants to get the CPU into SMT4 mode, and therefore

0 commit comments

Comments
 (0)