linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: PPC: add paravirt idle loop for 64-bit book E
@ 2013-01-16 17:21 Stuart Yoder
  2013-01-16 17:44 ` Scott Wood
  0 siblings, 1 reply; 2+ messages in thread
From: Stuart Yoder @ 2013-01-16 17:21 UTC (permalink / raw)
  To: agraf; +Cc: linuxppc-dev, kvm-ppc, kvm, Stuart Yoder

From: Stuart Yoder <stuart.yoder@freescale.com>

loop was derived from book3e_idle()

Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
---
 arch/powerpc/kernel/epapr_hcalls.S |   63 ++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S
index 62c0dc2..6a46bfb 100644
--- a/arch/powerpc/kernel/epapr_hcalls.S
+++ b/arch/powerpc/kernel/epapr_hcalls.S
@@ -17,6 +17,68 @@
 #include <asm/asm-compat.h>
 #include <asm/asm-offsets.h>
 
+#ifdef CONFIG_PPC64
+/* epapr_ev_idle() was derived from book3e_idle() */
+_GLOBAL(epapr_ev_idle)
+	/* Save LR for later */
+	mflr	r0
+	std	r0,16(r1)
+
+	/* Hard disable interrupts */
+	wrteei	0
+
+	/* Now check if an interrupt came in while we were soft disabled
+	 * since we may otherwise lose it (doorbells etc...).
+	 */
+	lbz	r3,PACAIRQHAPPENED(r13)
+	cmpwi	cr0,r3,0
+	bnelr
+
+	/* Now we are going to mark ourselves as soft and hard enabled in
+	 * order to be able to take interrupts while asleep. We inform lockdep
+	 * of that. We don't actually turn interrupts on just yet tho.
+	 */
+#ifdef CONFIG_TRACE_IRQFLAGS
+	stdu    r1,-128(r1)
+	bl	.trace_hardirqs_on
+	addi    r1,r1,128
+#endif
+	li	r0,1
+	stb	r0,PACASOFTIRQEN(r13)
+	
+	/* Interrupts will make use return to LR, so get something we want
+	 * in there
+	 */
+	bl	1f
+
+	/* And return (interrupts are on) */
+	ld	r0,16(r1)
+	mtlr	r0
+	blr
+
+1:	/* Let's set the _TLF_NAPPING flag so interrupts make us return
+	 * to the right spot
+	*/
+	CURRENT_THREAD_INFO(r11, r1)
+	ld	r10,TI_LOCAL_FLAGS(r11)
+	ori	r10,r10,_TLF_NAPPING
+	std	r10,TI_LOCAL_FLAGS(r11)
+
+	/* We can now re-enable hard interrupts and go to sleep */
+	wrteei	1
+idle_loop:
+	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
+
+.global epapr_ev_idle_start
+epapr_ev_idle_start:
+	li	r3, -1
+	nop
+	nop
+	nop
+	b	idle_loop
+
+#else /* CONFIG_PPC64 */
+
 /* epapr_ev_idle() was derived from e500_idle() */
 _GLOBAL(epapr_ev_idle)
 	CURRENT_THREAD_INFO(r3, r1)
@@ -42,6 +104,7 @@ epapr_ev_idle_start:
 	 * _TLF_NAPPING.
 	 */
 	b	idle_loop
+#endif
 
 /* Hypercall entry point. Will be patched with device tree instructions. */
 .global epapr_hypercall_start
-- 
1.7.9.7

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

* Re: [PATCH] KVM: PPC: add paravirt idle loop for 64-bit book E
  2013-01-16 17:21 [PATCH] KVM: PPC: add paravirt idle loop for 64-bit book E Stuart Yoder
@ 2013-01-16 17:44 ` Scott Wood
  0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2013-01-16 17:44 UTC (permalink / raw)
  To: Stuart Yoder; +Cc: kvm-ppc, linuxppc-dev, agraf, kvm, Stuart Yoder

On 01/16/2013 11:21:24 AM, Stuart Yoder wrote:
> From: Stuart Yoder <stuart.yoder@freescale.com>
>=20
> loop was derived from book3e_idle()
>=20
> Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
> ---
>  arch/powerpc/kernel/epapr_hcalls.S |   63 =20
> ++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
>=20
> diff --git a/arch/powerpc/kernel/epapr_hcalls.S =20
> b/arch/powerpc/kernel/epapr_hcalls.S
> index 62c0dc2..6a46bfb 100644
> --- a/arch/powerpc/kernel/epapr_hcalls.S
> +++ b/arch/powerpc/kernel/epapr_hcalls.S
> @@ -17,6 +17,68 @@
>  #include <asm/asm-compat.h>
>  #include <asm/asm-offsets.h>
>=20
> +#ifdef CONFIG_PPC64
> +/* epapr_ev_idle() was derived from book3e_idle() */
> +_GLOBAL(epapr_ev_idle)
> +	/* Save LR for later */
> +	mflr	r0
> +	std	r0,16(r1)
> +
> +	/* Hard disable interrupts */
> +	wrteei	0
> +
> +	/* Now check if an interrupt came in while we were soft disabled
> +	 * since we may otherwise lose it (doorbells etc...).
> +	 */
> +	lbz	r3,PACAIRQHAPPENED(r13)
> +	cmpwi	cr0,r3,0
> +	bnelr
> +
> +	/* Now we are going to mark ourselves as soft and hard enabled =20
> in
> +	 * order to be able to take interrupts while asleep. We inform =20
> lockdep
> +	 * of that. We don't actually turn interrupts on just yet tho.
> +	 */
> +#ifdef CONFIG_TRACE_IRQFLAGS
> +	stdu    r1,-128(r1)
> +	bl	.trace_hardirqs_on
> +	addi    r1,r1,128
> +#endif
> +	li	r0,1
> +	stb	r0,PACASOFTIRQEN(r13)
> +=09
> +	/* Interrupts will make use return to LR, so get something we =20
> want
> +	 * in there
> +	 */
> +	bl	1f
> +
> +	/* And return (interrupts are on) */
> +	ld	r0,16(r1)
> +	mtlr	r0
> +	blr
> +
> +1:	/* Let's set the _TLF_NAPPING flag so interrupts make us return
> +	 * to the right spot
> +	*/
> +	CURRENT_THREAD_INFO(r11, r1)
> +	ld	r10,TI_LOCAL_FLAGS(r11)
> +	ori	r10,r10,_TLF_NAPPING
> +	std	r10,TI_LOCAL_FLAGS(r11)
> +
> +	/* We can now re-enable hard interrupts and go to sleep */
> +	wrteei	1
> +idle_loop:
> +	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
> +
> +.global epapr_ev_idle_start
> +epapr_ev_idle_start:
> +	li	r3, -1
> +	nop
> +	nop
> +	nop
> +	b	idle_loop
> +

We should probably do this as an assembler macro, so we can have one =20
instance of it that gets instantiated for both "wait" and "ev_idle".

-Scott=

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

end of thread, other threads:[~2013-01-16 17:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-16 17:21 [PATCH] KVM: PPC: add paravirt idle loop for 64-bit book E Stuart Yoder
2013-01-16 17:44 ` Scott Wood

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).