linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/tm: Fix HFSCR bit for no suspend case
@ 2018-09-11  3:07 Michael Neuling
  2018-09-16 20:21 ` Breno Leitao
  2018-09-20  4:21 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Neuling @ 2018-09-11  3:07 UTC (permalink / raw)
  To: mpe; +Cc: linuxppc-dev, Nicholas Piggin, paulus, mikey

Currently on P9N DD2.1 we end up taking infinite TM facility
unavailable exceptions on the first TM usage by userspace.

In the special case of TM no suspend (P9N DD2.1), Linux is told TM is
off via CPU dt-ftrs but told to (partially) use it via
OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED. So HFSCR[TM] will be off from
dt-ftrs but we need to turn it on for the no suspend case.

This patch fixes this by enabling HFSCR TM in this case.

Cc: stable@vger.kernel.org # 4.15+
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 arch/powerpc/kernel/setup_64.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 6a501b25dd..faf00222b3 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -243,13 +243,19 @@ static void cpu_ready_for_interrupts(void)
 	}
 
 	/*
-	 * Fixup HFSCR:TM based on CPU features. The bit is set by our
-	 * early asm init because at that point we haven't updated our
-	 * CPU features from firmware and device-tree. Here we have,
-	 * so let's do it.
+	 * Set HFSCR:TM based on CPU features:
+	 * In the special case of TM no suspend (P9N DD2.1), Linux is
+	 * told TM is off via the dt-ftrs but told to (partially) use
+	 * it via OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED. So HFSCR[TM]
+	 * will be off from dt-ftrs but we need to turn it on for the
+	 * no suspend case.
 	 */
-	if (cpu_has_feature(CPU_FTR_HVMODE) && !cpu_has_feature(CPU_FTR_TM_COMP))
-		mtspr(SPRN_HFSCR, mfspr(SPRN_HFSCR) & ~HFSCR_TM);
+	if (cpu_has_feature(CPU_FTR_HVMODE)) {
+		if (cpu_has_feature(CPU_FTR_TM_COMP))
+			mtspr(SPRN_HFSCR, mfspr(SPRN_HFSCR) | HFSCR_TM);
+		else
+			mtspr(SPRN_HFSCR, mfspr(SPRN_HFSCR) & ~HFSCR_TM);
+	}
 
 	/* Set IR and DR in PACA MSR */
 	get_paca()->kernel_msr = MSR_KERNEL;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/tm: Fix HFSCR bit for no suspend case
  2018-09-11  3:07 [PATCH] powerpc/tm: Fix HFSCR bit for no suspend case Michael Neuling
@ 2018-09-16 20:21 ` Breno Leitao
  2018-09-20  4:21 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2018-09-16 20:21 UTC (permalink / raw)
  To: linuxppc-dev, Michael Ellerman, npiggin, Michael Neuling

On 09/11/2018 12:07 AM, Michael Neuling wrote:
> Currently on P9N DD2.1 we end up taking infinite TM facility
> unavailable exceptions on the first TM usage by userspace.
> 
> In the special case of TM no suspend (P9N DD2.1), Linux is told TM is
> off via CPU dt-ftrs but told to (partially) use it via
> OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED. So HFSCR[TM] will be off from
> dt-ftrs but we need to turn it on for the no suspend case.
> 
> This patch fixes this by enabling HFSCR TM in this case.
> 
> Cc: stable@vger.kernel.org # 4.15+
> Signed-off-by: Michael Neuling <mikey@neuling.org>

Tested-by: Breno Leitao <leitao@debian.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: powerpc/tm: Fix HFSCR bit for no suspend case
  2018-09-11  3:07 [PATCH] powerpc/tm: Fix HFSCR bit for no suspend case Michael Neuling
  2018-09-16 20:21 ` Breno Leitao
@ 2018-09-20  4:21 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-09-20  4:21 UTC (permalink / raw)
  To: Michael Neuling; +Cc: mikey, linuxppc-dev, Nicholas Piggin

On Tue, 2018-09-11 at 03:07:56 UTC, Michael Neuling wrote:
> Currently on P9N DD2.1 we end up taking infinite TM facility
> unavailable exceptions on the first TM usage by userspace.
> 
> In the special case of TM no suspend (P9N DD2.1), Linux is told TM is
> off via CPU dt-ftrs but told to (partially) use it via
> OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED. So HFSCR[TM] will be off from
> dt-ftrs but we need to turn it on for the no suspend case.
> 
> This patch fixes this by enabling HFSCR TM in this case.
> 
> Cc: stable@vger.kernel.org # 4.15+
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> Tested-by: Breno Leitao <leitao@debian.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/dd9a8c5a87395b6f05552c3b44e42f

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-20  4:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11  3:07 [PATCH] powerpc/tm: Fix HFSCR bit for no suspend case Michael Neuling
2018-09-16 20:21 ` Breno Leitao
2018-09-20  4:21 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).