linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Defer processing of interrupts when the CPU wakes from sleep mode
@ 2008-05-14  4:30 Paul Mackerras
  2008-05-14 12:03 ` [PATCH] Defer processing of interrupts when the CPU wakes from sleepmode Liu Dave
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Mackerras @ 2008-05-14  4:30 UTC (permalink / raw)
  To: linuxppc-dev

This provides a way to defer processing of an interrupt that wakes the
processor out of sleep mode.  On 32-bit platforms that use an
interrupt to wake the processor, we have to have interrupts enabled in
hardware at the point where we go to sleep, otherwise the processor
will never wake up.  However, because interrupts are logically
disabled at this point, we don't want to process the interrupt
straight away.

This is handled by setting the _TLF_SLEEPING flag.  When we get an
interrupt and _TLF_SLEEPING is set, we firstly clear the MSR_EE
(external interrupt enable) bit in the saved MSR value, and secondly
we then return to the address in the link register, like we do for
_TLF_NAPPING, but without actually handling the interrupt.

Note that this is handled somewhat differently on powerbooks, so this
new code will only be used on non-Apple machines.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 84c8686..162500f 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -146,6 +146,7 @@ transfer_to_handler:
 	lwz	r12,TI_LOCAL_FLAGS(r9)
 	mtcrf	0x01,r12
 	bt-	31-TLF_NAPPING,4f
+	bt-	31-TLF_SLEEPING,7f
 #endif /* CONFIG_6xx */
 	.globl transfer_to_handler_cont
 transfer_to_handler_cont:
@@ -163,6 +164,13 @@ transfer_to_handler_cont:
 4:	rlwinm	r12,r12,0,~_TLF_NAPPING
 	stw	r12,TI_LOCAL_FLAGS(r9)
 	b	power_save_6xx_restore
+
+7:	rlwinm	r12,r12,0,~_TLF_SLEEPING
+	stw	r12,TI_LOCAL_FLAGS(r9)
+	lwz	r9,_MSR(r11)		/* if sleeping, clear MSR.EE */
+	rlwinm	r9,r9,0,~MSR_EE
+	lwz	r12,_LINK(r11)		/* and return to address in LR */
+	b	fast_exception_return
 #endif
 
 /*
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index d030f5c..1cd8c8f 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -147,8 +147,10 @@ static inline struct thread_info *current_thread_info(void)
 /* Bits in local_flags */
 /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
 #define TLF_NAPPING		0	/* idle thread enabled NAP mode */
+#define TLF_SLEEPING		1	/* suspend code enabled SLEEP mode */
 
 #define _TLF_NAPPING		(1 << TLF_NAPPING)
+#define _TLF_SLEEPING		(1 << TLF_SLEEPING)
 
 #endif /* __KERNEL__ */
 

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

* RE: [PATCH] Defer processing of interrupts when the CPU wakes from sleepmode
  2008-05-14  4:30 [PATCH] Defer processing of interrupts when the CPU wakes from sleep mode Paul Mackerras
@ 2008-05-14 12:03 ` Liu Dave
  2008-05-15  9:30   ` Paul Mackerras
  0 siblings, 1 reply; 4+ messages in thread
From: Liu Dave @ 2008-05-14 12:03 UTC (permalink / raw)
  To: Paul Mackerras, linuxppc-dev

<snip>

> This provides a way to defer processing of an interrupt that wakes the
> processor out of sleep mode.  On 32-bit platforms that use an
> interrupt to wake the processor, we have to have interrupts enabled in
> hardware at the point where we go to sleep, otherwise the processor
> will never wake up.  However, because interrupts are logically
> disabled at this point, we don't want to process the interrupt
> straight away.
>=20
> This is handled by setting the _TLF_SLEEPING flag.  When we get an
> interrupt and _TLF_SLEEPING is set, we firstly clear the MSR_EE
> (external interrupt enable) bit in the saved MSR value, and secondly
> we then return to the address in the link register, like we do for
> _TLF_NAPPING, but without actually handling the interrupt.
>=20
> Note that this is handled somewhat differently on powerbooks, so this
> new code will only be used on non-Apple machines.

Thanks Paul for this patch. The patch looks like very nice.
But the users have to be aware of the LINK register (LR) not corrupted.

So, does power management patch from Scott Wood need to respin?

BTW, why the fast_exception_return does *not* need clear the reservation
with stwcx.?

Thanks,
Dave

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

* RE: [PATCH] Defer processing of interrupts when the CPU wakes from sleepmode
  2008-05-14 12:03 ` [PATCH] Defer processing of interrupts when the CPU wakes from sleepmode Liu Dave
@ 2008-05-15  9:30   ` Paul Mackerras
  2008-05-15  9:44     ` Liu Dave
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Mackerras @ 2008-05-15  9:30 UTC (permalink / raw)
  To: Liu Dave; +Cc: linuxppc-dev

Liu Dave writes:

> Thanks Paul for this patch. The patch looks like very nice.
> But the users have to be aware of the LINK register (LR) not corrupted.

Yes, if you set the _TLF_SLEEPING bit, you need to know what it
does. :)

> So, does power management patch from Scott Wood need to respin?

No, because Scott's original patch did that too.

> BTW, why the fast_exception_return does *not* need clear the reservation
> with stwcx.?

Because we haven't done anything that could have left a dangling
reservation set.

Paul.

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

* RE: [PATCH] Defer processing of interrupts when the CPU wakes from sleepmode
  2008-05-15  9:30   ` Paul Mackerras
@ 2008-05-15  9:44     ` Liu Dave
  0 siblings, 0 replies; 4+ messages in thread
From: Liu Dave @ 2008-05-15  9:44 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

<snip>

Thanks Paul.

> > So, does power management patch from Scott Wood need to respin?
>=20
> No, because Scott's original patch did that too.

Yes, one of scott's patchset did the same function too. So the patch
http://patchwork.ozlabs.org/linuxppc/patch?id=3D18182
will conflict with your patch.

That is why I asked you if we have to repsin scott's patchset.

If have not feedback for Scott's patch,
Could you merge Scott's power management to main tree?

BTW, I noticed the NAP mode for 6xx didn't work for 83xx part.
Did you try it on the other 6xx part?

Thanks,
Dave

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

end of thread, other threads:[~2008-05-15  9:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-14  4:30 [PATCH] Defer processing of interrupts when the CPU wakes from sleep mode Paul Mackerras
2008-05-14 12:03 ` [PATCH] Defer processing of interrupts when the CPU wakes from sleepmode Liu Dave
2008-05-15  9:30   ` Paul Mackerras
2008-05-15  9:44     ` Liu Dave

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