Skip to contentSkip to conversation

Power10 basic energy management

PATCH In review Pratik Rajesh Sampat 5 participants 16 messages Jul 10, 2020 – Jul 24, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

v2 cover Power10 basic energy management

Changelog v1 --> v2:
1. Save-restore DAWR and DAWRX unconditionally as they are lost in shallow idle states too
2. Rename pnv_first_spr_loss_level to pnv_first_fullstate_loss_level to correct naming terminology

Pratik Rajesh Sampat (3):
powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable

 arch/powerpc/platforms/powernv/idle.c | 34 +++++++++++++++++----------
 1 file changed, 22 insertions(+), 12 deletions(-)
Signature · 1 line
2.25.4
#3 lore raw

PATCH v2 2/3 powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10

Additional registers DAWR0, DAWRX0 may be lost on Power 10 for stop levels < 4.
Therefore save the values of these SPRs before entering a "stop" state and restore their values on wakeup.

---
 arch/powerpc/platforms/powernv/idle.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/powerpc/platforms/powernv/idle.c +10 -0
index 19d94d021357..f2e2a6a4c274 100644
@@ -600,6 +600,8 @@ struct p9_sprs {
 	u64 iamr;
 	u64 amor;
 	u64 uamor;
+	u64 dawr0;
+	u64 dawrx0;
 };
 
 static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
@@ -687,6 +689,10 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
 	sprs.iamr	= mfspr(SPRN_IAMR);
 	sprs.amor	= mfspr(SPRN_AMOR);
 	sprs.uamor	= mfspr(SPRN_UAMOR);
+	if (cpu_has_feature(CPU_FTR_ARCH_31)) {
+		sprs.dawr0 = mfspr(SPRN_DAWR0);
+		sprs.dawrx0 = mfspr(SPRN_DAWRX0);
+	}
 
 	srr1 = isa300_idle_stop_mayloss(psscr);		/* go idle */
 
@@ -710,6 +716,10 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
 		mtspr(SPRN_IAMR,	sprs.iamr);
 		mtspr(SPRN_AMOR,	sprs.amor);
 		mtspr(SPRN_UAMOR,	sprs.uamor);
+		if (cpu_has_feature(CPU_FTR_ARCH_31)) {
+			mtspr(SPRN_DAWR0, sprs.dawr0);
+			mtspr(SPRN_DAWRX0, sprs.dawrx0);
+		}
 
 		/*
 		 * Workaround for POWER9 DD2.0, if we lost resources, the ERAT
Signature · 1 line
2.25.4
#9 lore raw

PATCH v2 3/3 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable

In reply to Pratik Rajesh Sampat

Replace the variable name from using "pnv_first_spr_loss_level" to "pnv_first_fullstate_loss_level".

As pnv_first_spr_loss_level is supposed to be the earliest state that has OPAL_PM_LOSE_FULL_CONTEXT set, however as shallow states too loose SPR values, render an incorrect terminology.

---
 arch/powerpc/platforms/powernv/idle.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
arch/powerpc/platforms/powernv/idle.c +9 -9
index f2e2a6a4c274..d54e7ef234e3 100644
@@ -48,7 +48,7 @@ static bool default_stop_found;
  * First stop state levels when SPR and TB loss can occur.
  */
 static u64 pnv_first_tb_loss_level = MAX_STOP_STATE + 1;
-static u64 pnv_first_spr_loss_level = MAX_STOP_STATE + 1;
+static u64 pnv_first_fullstate_loss_level = MAX_STOP_STATE + 1;
 
 /*
  * psscr value and mask of the deepest stop idle state.
@@ -659,7 +659,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
 		  */
 		mmcr0		= mfspr(SPRN_MMCR0);
 	}
-	if ((psscr & PSSCR_RL_MASK) >= pnv_first_spr_loss_level) {
+	if ((psscr & PSSCR_RL_MASK) >= pnv_first_fullstate_loss_level) {
 		sprs.lpcr	= mfspr(SPRN_LPCR);
 		sprs.hfscr	= mfspr(SPRN_HFSCR);
 		sprs.fscr	= mfspr(SPRN_FSCR);
@@ -751,7 +751,7 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
 	 * just always test PSSCR for SPR/TB state loss.
 	 */
 	pls = (psscr & PSSCR_PLS) >> PSSCR_PLS_SHIFT;
-	if (likely(pls < pnv_first_spr_loss_level)) {
+	if (likely(pls < pnv_first_fullstate_loss_level)) {
 		if (sprs_saved)
 			atomic_stop_thread_idle();
 		goto out;
@@ -1098,7 +1098,7 @@ static void __init pnv_power9_idle_init(void)
 	 * the deepest loss-less (OPAL_PM_STOP_INST_FAST) stop state.
 	 */
 	pnv_first_tb_loss_level = MAX_STOP_STATE + 1;
-	pnv_first_spr_loss_level = MAX_STOP_STATE + 1;
+	pnv_first_fullstate_loss_level = MAX_STOP_STATE + 1;
 	for (i = 0; i < nr_pnv_idle_states; i++) {
 		int err;
 		struct pnv_idle_states_t *state = &pnv_idle_states[i];
@@ -1109,8 +1109,8 @@ static void __init pnv_power9_idle_init(void)
 			pnv_first_tb_loss_level = psscr_rl;
 
 		if ((state->flags & OPAL_PM_LOSE_FULL_CONTEXT) &&
-		     (pnv_first_spr_loss_level > psscr_rl))
-			pnv_first_spr_loss_level = psscr_rl;
+		     (pnv_first_fullstate_loss_level > psscr_rl))
+			pnv_first_fullstate_loss_level = psscr_rl;
 
 		/*
 		 * The idle code does not deal with TB loss occurring
@@ -1121,8 +1121,8 @@ static void __init pnv_power9_idle_init(void)
 		 * compatibility.
 		 */
 		if ((state->flags & OPAL_PM_TIMEBASE_STOP) &&
-		     (pnv_first_spr_loss_level > psscr_rl))
-			pnv_first_spr_loss_level = psscr_rl;
+		     (pnv_first_fullstate_loss_level > psscr_rl))
+			pnv_first_fullstate_loss_level = psscr_rl;
 
 		err = validate_psscr_val_mask(&state->psscr_val,
 					      &state->psscr_mask,
@@ -1168,7 +1168,7 @@ static void __init pnv_power9_idle_init(void)
 	}
 
 	pr_info("cpuidle-powernv: First stop level that may lose SPRs = 0x%llx\n",
-		pnv_first_spr_loss_level);
+		pnv_first_fullstate_loss_level);
 
 	pr_info("cpuidle-powernv: First stop level that may lose timebase = 0x%llx\n",
 		pnv_first_tb_loss_level);
Signature · 1 line
2.25.4
#1 lore raw

PATCH v2 1/3 powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above

In reply to Pratik Rajesh Sampat

POWER9 onwards the support for the registers HID1, HID4, HID5 has been receded.
Although mfspr on the above registers worked in Power9, In Power10 simulator is unrecognized. Moving their assignment under the check for machines lower than Power9

---
 arch/powerpc/platforms/powernv/idle.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/powernv/idle.c +3 -3
index 2dd467383a88..19d94d021357 100644
@@ -73,9 +73,6 @@ static int pnv_save_sprs_for_deep_states(void)
 	 */
 	uint64_t lpcr_val	= mfspr(SPRN_LPCR);
 	uint64_t hid0_val	= mfspr(SPRN_HID0);
-	uint64_t hid1_val	= mfspr(SPRN_HID1);
-	uint64_t hid4_val	= mfspr(SPRN_HID4);
-	uint64_t hid5_val	= mfspr(SPRN_HID5);
 	uint64_t hmeer_val	= mfspr(SPRN_HMEER);
 	uint64_t msr_val = MSR_IDLE;
 	uint64_t psscr_val = pnv_deepest_stop_psscr_val;
@@ -117,6 +114,9 @@ static int pnv_save_sprs_for_deep_states(void)
 
 			/* Only p8 needs to set extra HID regiters */
 			if (!cpu_has_feature(CPU_FTR_ARCH_300)) {
+				uint64_t hid1_val = mfspr(SPRN_HID1);
+				uint64_t hid4_val = mfspr(SPRN_HID4);
+				uint64_t hid5_val = mfspr(SPRN_HID5);
 
 				rc = opal_slw_set_reg(pir, SPRN_HID1, hid1_val);
 				if (rc != 0)
Signature · 1 line
2.25.4
#10 lore raw
In reply to Pratik Rajesh Sampat

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 6 lines

Changelog v1 --> v2:
1. Save-restore DAWR and DAWRX unconditionally as they are lost in shallow idle states too
2. Rename pnv_first_spr_loss_level to pnv_first_fullstate_loss_level to correct naming terminology

Quoted 7 lines

Pratik Rajesh Sampat (3):
powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable

 arch/powerpc/platforms/powernv/idle.c | 34 +++++++++++++++++----------
 1 file changed, 22 insertions(+), 12 deletions(-)

These look okay to me, but the CPU_FTR_ARCH_300 test for pnv_power9_idle_init() is actually wrong, it should be a PVR test because idle is not completely architected (not even shallow stop states, unfortunately).

It doesn't look like we support POWER10 idle correctly yet, and on older kernels it wouldn't work even if we fixed newer, so ideally the PVR check would be backported as a fix in the front of the series.

Sadly, we have no OPAL idle driver yet. Hopefully we will before the next processor shows up :P

Thanks,
Nick

#4 lore raw

Re: [PATCH v2 2/3] powerpc/powernv/idle: save-restore DAWR0, DAWRX0 for P10

In reply to Pratik Rajesh Sampat

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 4 lines

Additional registers DAWR0, DAWRX0 may be lost on Power 10 for stop levels < 4.
Therefore save the values of these SPRs before entering a "stop" state and restore their values on wakeup.

Hmm, where do you get this from? Documentation I see says DAWR is lost on POWER9 but not P10.

Does idle thread even need to save DAWR, or does it get switched when going to a thread that has a watchpoint set?

Thanks,
Nick

Quoted 45 lines
---
 arch/powerpc/platforms/powernv/idle.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/powerpc/platforms/powernv/idle.c +10 -0
index 19d94d021357..f2e2a6a4c274 100644
@@ -600,6 +600,8 @@ struct p9_sprs {
 	u64 iamr;
 	u64 amor;
 	u64 uamor;
+	u64 dawr0;
+	u64 dawrx0;
 };
 
 static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
@@ -687,6 +689,10 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
 	sprs.iamr	= mfspr(SPRN_IAMR);
 	sprs.amor	= mfspr(SPRN_AMOR);
 	sprs.uamor	= mfspr(SPRN_UAMOR);
+	if (cpu_has_feature(CPU_FTR_ARCH_31)) {
+		sprs.dawr0 = mfspr(SPRN_DAWR0);
+		sprs.dawrx0 = mfspr(SPRN_DAWRX0);
+	}
 
 	srr1 = isa300_idle_stop_mayloss(psscr);		/* go idle */
 
@@ -710,6 +716,10 @@ static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
 		mtspr(SPRN_IAMR,	sprs.iamr);
 		mtspr(SPRN_AMOR,	sprs.amor);
 		mtspr(SPRN_UAMOR,	sprs.uamor);
+		if (cpu_has_feature(CPU_FTR_ARCH_31)) {
+			mtspr(SPRN_DAWR0, sprs.dawr0);
+			mtspr(SPRN_DAWRX0, sprs.dawrx0);
+		}
 
 		/*
 		 * Workaround for POWER9 DD2.0, if we lost resources, the ERAT
Signature · 1 line
2.25.4
#2 lore raw

Re: [PATCH v2 1/3] powerpc/powernv/idle: Exclude mfspr on HID1, 4, 5 on P9 and above

In reply to Pratik Rajesh Sampat

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 5 lines

POWER9 onwards the support for the registers HID1, HID4, HID5 has been receded.
Although mfspr on the above registers worked in Power9, In Power10 simulator is unrecognized. Moving their assignment under the check for machines lower than Power9

Seems like a good fix.

Thanks,
Nick

Quoted 35 lines
---
 arch/powerpc/platforms/powernv/idle.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/powernv/idle.c +3 -3
index 2dd467383a88..19d94d021357 100644
@@ -73,9 +73,6 @@ static int pnv_save_sprs_for_deep_states(void)
 	 */
 	uint64_t lpcr_val	= mfspr(SPRN_LPCR);
 	uint64_t hid0_val	= mfspr(SPRN_HID0);
-	uint64_t hid1_val	= mfspr(SPRN_HID1);
-	uint64_t hid4_val	= mfspr(SPRN_HID4);
-	uint64_t hid5_val	= mfspr(SPRN_HID5);
 	uint64_t hmeer_val	= mfspr(SPRN_HMEER);
 	uint64_t msr_val = MSR_IDLE;
 	uint64_t psscr_val = pnv_deepest_stop_psscr_val;
@@ -117,6 +114,9 @@ static int pnv_save_sprs_for_deep_states(void)
 
 			/* Only p8 needs to set extra HID regiters */
 			if (!cpu_has_feature(CPU_FTR_ARCH_300)) {
+				uint64_t hid1_val = mfspr(SPRN_HID1);
+				uint64_t hid4_val = mfspr(SPRN_HID4);
+				uint64_t hid5_val = mfspr(SPRN_HID5);
 
 				rc = opal_slw_set_reg(pir, SPRN_HID1, hid1_val);
 				if (rc != 0)
Signature · 1 line
2.25.4
#11 lore raw
In reply to Nicholas Piggin

Thank you for your comments,

Quoted 23 lines · Nicholas Piggin

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 6 lines

Changelog v1 --> v2:
1. Save-restore DAWR and DAWRX unconditionally as they are lost in shallow idle states too
2. Rename pnv_first_spr_loss_level to pnv_first_fullstate_loss_level to correct naming terminology

Quoted 7 lines

Pratik Rajesh Sampat (3):
powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable

  arch/powerpc/platforms/powernv/idle.c | 34 +++++++++++++++++----------
  1 file changed, 22 insertions(+), 12 deletions(-)

These look okay to me, but the CPU_FTR_ARCH_300 test for pnv_power9_idle_init() is actually wrong, it should be a PVR test because idle is not completely architected (not even shallow stop states, unfortunately).

It doesn't look like we support POWER10 idle correctly yet, and on older kernels it wouldn't work even if we fixed newer, so ideally the PVR check would be backported as a fix in the front of the series.

Quoted 5 lines

Sadly, we have no OPAL idle driver yet. Hopefully we will before the next processor shows up :P

Thanks,
Nick

So if I understand this correctly, in powernv/idle.c where we check for CPU_FTR_ARCH_300, we should rather be making a pvr_version_is(PVR_POWER9) check instead?

Of course, the P10 PVR and its relevant checks will have to be added then too.

Thanks
Pratik

#14 lore raw
In reply to Nicholas Piggin
Quoted 20 lines · Nicholas Piggin

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 6 lines

Changelog v1 --> v2:
1. Save-restore DAWR and DAWRX unconditionally as they are lost in shallow idle states too
2. Rename pnv_first_spr_loss_level to pnv_first_fullstate_loss_level to correct naming terminology

Quoted 7 lines

Pratik Rajesh Sampat (3):
powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable

 arch/powerpc/platforms/powernv/idle.c | 34 +++++++++++++++++----------
 1 file changed, 22 insertions(+), 12 deletions(-)

These look okay to me, but the CPU_FTR_ARCH_300 test for pnv_power9_idle_init() is actually wrong, it should be a PVR test because idle is not completely architected (not even shallow stop states, unfortunately).

Quoted 6 lines

It doesn't look like we support POWER10 idle correctly yet, and on older kernels it wouldn't work even if we fixed newer, so ideally the PVR check would be backported as a fix in the front of the series.

Sadly, we have no OPAL idle driver yet. Hopefully we will before the next processor shows up :P

Abhishek posted a version recently :
https://patchwork.ozlabs.org/project/skiboot/patch/[email protected]/

Quoted 3 lines

Thanks,
Nick

--
Thanks and Regards
gautham.

#12 lore raw
In reply to Pratik Sampat

Excerpts from Pratik Sampat's message of July 13, 2020 8:02 pm:

Quoted 29 lines

Thank you for your comments,

Quoted 26 lines · Nicholas Piggin

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 6 lines

Changelog v1 --> v2:
1. Save-restore DAWR and DAWRX unconditionally as they are lost in shallow idle states too
2. Rename pnv_first_spr_loss_level to pnv_first_fullstate_loss_level to correct naming terminology

Quoted 7 lines

Pratik Rajesh Sampat (3):
powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable

  arch/powerpc/platforms/powernv/idle.c | 34 +++++++++++++++++----------
  1 file changed, 22 insertions(+), 12 deletions(-)

These look okay to me, but the CPU_FTR_ARCH_300 test for pnv_power9_idle_init() is actually wrong, it should be a PVR test because idle is not completely architected (not even shallow stop states, unfortunately).

It doesn't look like we support POWER10 idle correctly yet, and on older kernels it wouldn't work even if we fixed newer, so ideally the PVR check would be backported as a fix in the front of the series.

Sadly, we have no OPAL idle driver yet. Hopefully we will before the next processor shows up :P

Quoted 8 lines
Quoted 2 lines

Thanks,
Nick

So if I understand this correctly, in powernv/idle.c where we check for CPU_FTR_ARCH_300, we should rather be making a pvr_version_is(PVR_POWER9) check instead?

Of course, the P10 PVR and its relevant checks will have to be added then too.

Yes I think so, unfortunately.

Thanks,
Nick

#15 lore raw
In reply to Gautham R Shenoy

Excerpts from Gautham R Shenoy's message of July 13, 2020 8:48 pm:

Quoted 25 lines · Nicholas Piggin
Quoted 24 lines

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 6 lines

Changelog v1 --> v2:
1. Save-restore DAWR and DAWRX unconditionally as they are lost in shallow idle states too
2. Rename pnv_first_spr_loss_level to pnv_first_fullstate_loss_level to correct naming terminology

Quoted 7 lines

Pratik Rajesh Sampat (3):
powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable

 arch/powerpc/platforms/powernv/idle.c | 34 +++++++++++++++++----------
 1 file changed, 22 insertions(+), 12 deletions(-)

These look okay to me, but the CPU_FTR_ARCH_300 test for pnv_power9_idle_init() is actually wrong, it should be a PVR test because idle is not completely architected (not even shallow stop states, unfortunately).

It doesn't look like we support POWER10 idle correctly yet, and on older kernels it wouldn't work even if we fixed newer, so ideally the PVR check would be backported as a fix in the front of the series.

Quoted 5 lines
Quoted 2 lines

Sadly, we have no OPAL idle driver yet. Hopefully we will before the next processor shows up :P

Abhishek posted a version recently :
https://patchwork.ozlabs.org/project/skiboot/patch/[email protected]/

Yep, I saw that. Still keen to get it working, just had other priorities in the short term. We'll need to do this OPAL v4 thing for it.

Thanks,
Nick

#13 lore raw
In reply to Nicholas Piggin
Quoted 36 lines · Nicholas Piggin

Excerpts from Pratik Sampat's message of July 13, 2020 8:02 pm:

Quoted 35 lines

Thank you for your comments,

Quoted 23 lines · Nicholas Piggin

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 6 lines

Changelog v1 --> v2:
1. Save-restore DAWR and DAWRX unconditionally as they are lost in shallow idle states too
2. Rename pnv_first_spr_loss_level to pnv_first_fullstate_loss_level to correct naming terminology

Quoted 7 lines

Pratik Rajesh Sampat (3):
powerpc/powernv/idle: Exclude mfspr on HID1,4,5 on P9 and above powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10 powerpc/powernv/idle: Rename pnv_first_spr_loss_level variable

   arch/powerpc/platforms/powernv/idle.c | 34 +++++++++++++++++----------
   1 file changed, 22 insertions(+), 12 deletions(-)

These look okay to me, but the CPU_FTR_ARCH_300 test for pnv_power9_idle_init() is actually wrong, it should be a PVR test because idle is not completely architected (not even shallow stop states, unfortunately).

It doesn't look like we support POWER10 idle correctly yet, and on older kernels it wouldn't work even if we fixed newer, so ideally the PVR check would be backported as a fix in the front of the series.

Quoted 5 lines

Sadly, we have no OPAL idle driver yet. Hopefully we will before the next processor shows up :P

Thanks,
Nick

So if I understand this correctly, in powernv/idle.c where we check for CPU_FTR_ARCH_300, we should rather be making a pvr_version_is(PVR_POWER9) check instead?

Quoted 5 lines
Quoted 1 line

Of course, the P10 PVR and its relevant checks will have to be added then too.

Yes I think so, unfortunately.

Thanks,
Nick

Sure, I'll add these checks in.

Thanks,
Pratik

#6 lore raw

Re: [PATCH v2 2/3] powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10

In reply to Pratik Rajesh Sampat

Hi Pratik,

Quoted 2 lines · Pratik Rajesh Sampat

Additional registers DAWR0, DAWRX0 may be lost on Power 10 for stop levels < 4.

p10 has one more pair DAWR1/DAWRX1. Please include that as well.

Ravi

#5 lore raw

Re: [PATCH v2 2/3] powerpc/powernv/idle: save-restore DAWR0, DAWRX0 for P10

In reply to Nicholas Piggin

Hi Nick,

Quoted 11 lines · Nicholas Piggin

Excerpts from Pratik Rajesh Sampat's message of July 10, 2020 3:22 pm:

Quoted 4 lines

Additional registers DAWR0, DAWRX0 may be lost on Power 10 for stop levels < 4.
Therefore save the values of these SPRs before entering a "stop" state and restore their values on wakeup.

Hmm, where do you get this from? Documentation I see says DAWR is lost on POWER9 but not P10.

Does idle thread even need to save DAWR, or does it get switched when going to a thread that has a watchpoint set?

I don't know how idle states works internally but IIUC, we need to save/restore DAWRs. This is needed when user creates per-cpu watchpoint event.

Ravi

#7 lore raw

Re: [PATCH v2 2/3] powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10

In reply to Pratik Rajesh Sampat
Quoted 25 lines · Pratik Rajesh Sampat

Additional registers DAWR0, DAWRX0 may be lost on Power 10 for stop levels < 4.
Therefore save the values of these SPRs before entering a "stop" state and restore their values on wakeup.

---
 arch/powerpc/platforms/powernv/idle.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/powerpc/platforms/powernv/idle.c +2 -0
index 19d94d021357..f2e2a6a4c274 100644
@@ -600,6 +600,8 @@ struct p9_sprs {
 	u64 iamr;
 	u64 amor;
 	u64 uamor;
+	u64 dawr0;
+	u64 dawrx0;
 };
 
 static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)

arch/powerpc/platforms/powernv/idle.c static unsigned long power9_idle_stop(unsigned long · line 693

Quoted 5 lines
arch/powerpc/platforms/powernv/idle.c +1 -0
@@ -687,6 +689,10 @@ static unsigned long power9_idle_stop(unsigned long
 psscr, bool mmu_on)
 	sprs.iamr	= mfspr(SPRN_IAMR);
 	sprs.amor	= mfspr(SPRN_AMOR);
 	sprs.uamor	= mfspr(SPRN_UAMOR);
+	if (cpu_has_feature(CPU_FTR_ARCH_31)) {

Can you add a comment here saying even though DAWR0 is ARCH_30, it's only required to be saved on 31. Otherwise this looks pretty odd.

Quoted 18 lines
arch/powerpc/platforms/powernv/idle.c +7 -0
+		sprs.dawr0 = mfspr(SPRN_DAWR0);
+		sprs.dawrx0 = mfspr(SPRN_DAWRX0);
+	}
 
 	srr1 = isa300_idle_stop_mayloss(psscr);		/* go idle */
@@ -710,6 +716,10 @@ static unsigned long power9_idle_stop(unsigned long
 psscr, bool mmu_on)
 		mtspr(SPRN_IAMR,	sprs.iamr);
 		mtspr(SPRN_AMOR,	sprs.amor);
 		mtspr(SPRN_UAMOR,	sprs.uamor);
+		if (cpu_has_feature(CPU_FTR_ARCH_31)) {
+			mtspr(SPRN_DAWR0, sprs.dawr0);
+			mtspr(SPRN_DAWRX0, sprs.dawrx0);
+		}
 
 		/*

* Workaround for POWER9 DD2.0, if we lost resources, the ERAT

#8 lore raw

Re: [PATCH v2 2/3] powerpc/powernv/idle: save-restore DAWR0,DAWRX0 for P10

Quoted 24 lines · Michael Neuling
Quoted 23 lines · Pratik Rajesh Sampat

Additional registers DAWR0, DAWRX0 may be lost on Power 10 for stop levels < 4.
Therefore save the values of these SPRs before entering a "stop" state and restore their values on wakeup.

---
  arch/powerpc/platforms/powernv/idle.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
arch/powerpc/platforms/powernv/idle.c +2 -0
index 19d94d021357..f2e2a6a4c274 100644
@@ -600,6 +600,8 @@ struct p9_sprs {
  	u64 iamr;
  	u64 amor;
  	u64 uamor;
+	u64 dawr0;
+	u64 dawrx0;
  };
 
Quoted 7 lines

arch/powerpc/platforms/powernv/idle.c static unsigned long power9_idle_stop(unsigned long · line 693

Quoted 7 lines
arch/powerpc/platforms/powernv/idle.c +1 -0
  static unsigned long power9_idle_stop(unsigned long psscr, bool mmu_on)
@@ -687,6 +689,10 @@ static unsigned long power9_idle_stop(unsigned long
 psscr, bool mmu_on)
  	sprs.iamr	= mfspr(SPRN_IAMR);
  	sprs.amor	= mfspr(SPRN_AMOR);
  	sprs.uamor	= mfspr(SPRN_UAMOR);
+	if (cpu_has_feature(CPU_FTR_ARCH_31)) {

You are actually viewing an old version of the patches The main point of change were based on comments from Nick Piggin, I have changed the top level function check from ARCH_300 to a P9 PVR check instead.

A similar thing needs to be done for P10, however as the P10 PVR isn't exposed yet, I've shelved this particular patch.

Nick's comment to check based on PVR:https://lkml.org/lkml/2020/7/13/1018 v4 of the series:https://lkml.org/lkml/2020/7/21/784

Thanks for your review,
Pratik

Quoted 21 lines

Can you add a comment here saying even though DAWR0 is ARCH_30, it's only required to be saved on 31. Otherwise this looks pretty odd.

Quoted 18 lines
arch/powerpc/platforms/powernv/idle.c +7 -0
+		sprs.dawr0 = mfspr(SPRN_DAWR0);
+		sprs.dawrx0 = mfspr(SPRN_DAWRX0);
+	}
 
  	srr1 = isa300_idle_stop_mayloss(psscr);		/* go idle */
@@ -710,6 +716,10 @@ static unsigned long power9_idle_stop(unsigned long
 psscr, bool mmu_on)
  		mtspr(SPRN_IAMR,	sprs.iamr);
  		mtspr(SPRN_AMOR,	sprs.amor);
  		mtspr(SPRN_UAMOR,	sprs.uamor);
+		if (cpu_has_feature(CPU_FTR_ARCH_31)) {
+			mtspr(SPRN_DAWR0, sprs.dawr0);
+			mtspr(SPRN_DAWRX0, sprs.dawrx0);
+		}
 
  		/*

* Workaround for POWER9 DD2.0, if we lost resources, the ERAT