Skip to contentSkip to conversation

powerpc: Add irqtrace support for 32-bit powerpc (v2)

PATCH In review Benjamin Herrenschmidt 2 participants 3 messages Jun 18, 2009 – Jun 19, 2009 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Add irqtrace support for 32-bit powerpc (v2)

Based on initial work from: Dale Farnsworth <[email protected]>

Add the low level irq tracing hooks for 32-bit powerpc needed to enable full lockdep functionality.

The approach taken to deal with the code in entry_32.S is that we don't trace all the transitions of MSR:EE when we just turn it off to peek at TI_FLAGS without races. Only when we are calling into C code or returning from exceptions with a state that have changed from what lockdep thinks.

There's a little bugger though: If we take an exception that keeps interrupts enabled (such as an alignment exception) while interrupts are enabled, we will call trace_hardirqs_on() on the way back spurriously. Not a big deal, but to get rid of it would require remembering in pt_regs that the exception was one of the type that kept interrupts enabled which we don't know at this stage. (Well, we could test all cases for regs->trap but that sucks too much).

---

This one fixes a bug, trace_hardirqs_on was too late in the
restore: code path and would clobber things. This boots fine now on a PowerBook.

 arch/powerpc/Kconfig              |    1 
 arch/powerpc/include/asm/hw_irq.h |   20 ++---
 arch/powerpc/kernel/entry_32.S    |  127 ++++++++++++++++++++++++++++++++++++--
 arch/powerpc/kernel/setup_32.c    |    2 
 arch/powerpc/kernel/udbg.c        |    1 
 5 files changed, 136 insertions(+), 15 deletions(-)
arch/powerpc/Kconfig +0 -1
@@ -62,7 +62,6 @@ config HAVE_LATENCYTOP_SUPPORT
 
 config TRACE_IRQFLAGS_SUPPORT
 	bool
-	depends on PPC64
 	default y
 
 config LOCKDEP_SUPPORT
arch/powerpc/kernel/entry_32.S +123 -4

214 lines not on this page · raw message

arch/powerpc/kernel/setup_32.c +2 -0
Index: linux-work/arch/powerpc/kernel/setup_32.c
===================================================================
@@ -119,6 +119,8 @@ notrace unsigned long __init early_init(
  */
 notrace void __init machine_init(unsigned long dt_ptr)
 {
+	lockdep_init();
+
 	/* Enable early debugging if any specified (see udbg.h) */
 	udbg_early_init();
 
arch/powerpc/include/asm/hw_irq.h +10 -10
Index: linux-work/arch/powerpc/include/asm/hw_irq.h
===================================================================
@@ -68,13 +68,13 @@ static inline int irqs_disabled_flags(un
 
 #if defined(CONFIG_BOOKE)
 #define SET_MSR_EE(x)	mtmsr(x)
-#define local_irq_restore(flags)	__asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory")
+#define raw_local_irq_restore(flags)	__asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory")
 #else
 #define SET_MSR_EE(x)	mtmsr(x)
-#define local_irq_restore(flags)	mtmsr(flags)
+#define raw_local_irq_restore(flags)	mtmsr(flags)
 #endif
 
-static inline void local_irq_disable(void)
+static inline void raw_local_irq_disable(void)
 {
 #ifdef CONFIG_BOOKE
 	__asm__ __volatile__("wrteei 0": : :"memory");
@@ -86,7 +86,7 @@ static inline void local_irq_disable(voi
 #endif
 }
 
-static inline void local_irq_enable(void)
+static inline void raw_local_irq_enable(void)
 {
 #ifdef CONFIG_BOOKE
 	__asm__ __volatile__("wrteei 1": : :"memory");
@@ -98,7 +98,7 @@ static inline void local_irq_enable(void
 #endif
 }
 
-static inline void local_irq_save_ptr(unsigned long *flags)
+static inline void raw_local_irq_save_ptr(unsigned long *flags)
 {
 	unsigned long msr;
 	msr = mfmsr();
@@ -110,12 +110,12 @@ static inline void local_irq_save_ptr(un
 #endif
 }
 
-#define local_save_flags(flags)	((flags) = mfmsr())
-#define local_irq_save(flags)	local_irq_save_ptr(&flags)
-#define irqs_disabled()		((mfmsr() & MSR_EE) == 0)
+#define raw_local_save_flags(flags)	((flags) = mfmsr())
+#define raw_local_irq_save(flags)	raw_local_irq_save_ptr(&flags)
+#define raw_irqs_disabled()		((mfmsr() & MSR_EE) == 0)
+#define raw_irqs_disabled_flags(flags)	(((flags) & MSR_EE) == 0)
 
-#define hard_irq_enable()	local_irq_enable()
-#define hard_irq_disable()	local_irq_disable()
+#define hard_irq_disable()		raw_local_irq_disable()
 
 static inline int irqs_disabled_flags(unsigned long flags)
 {
arch/powerpc/kernel/udbg.c +1 -0
Index: linux-work/arch/powerpc/kernel/udbg.c
===================================================================
@@ -65,6 +65,7 @@ void __init udbg_early_init(void)
 #ifdef CONFIG_PPC_EARLY_DEBUG
 	console_loglevel = 10;
 #endif
+	register_early_udbg_console();
 }
 
 /* udbg library, used by xmon et al */
#1 lore raw

arch/powerpc/kernel/udbg.c void __init udbg_early_init(void) · line 69

Quoted 12 lines · Benjamin Herrenschmidt

Index: linux-work/arch/powerpc/kernel/udbg.c
===================================================================
--- linux-work.orig/arch/powerpc/kernel/udbg.c 2009-06-18 13:21:29.000000000 +1000
+++ linux-work/arch/powerpc/kernel/udbg.c 2009-06-18
13:21:39.000000000 +1000

arch/powerpc/kernel/udbg.c +1 -0
@@ -65,6 +65,7 @@ void __init udbg_early_init(void)
 #ifdef CONFIG_PPC_EARLY_DEBUG
        console_loglevel = 10;
 #endif
+       register_early_udbg_console();
 }

And that bit of course have nothing to do in that patch :-)

No need for a respin for now though unless we find other problems.

Cheers,
Ben.

Tested-by on v1 1/1
#2 lore raw
In reply to Benjamin Herrenschmidt
Quoted 20 lines · Benjamin Herrenschmidt

Based on initial work from: Dale Farnsworth <[email protected]>

Add the low level irq tracing hooks for 32-bit powerpc needed to enable full lockdep functionality.

The approach taken to deal with the code in entry_32.S is that we don't trace all the transitions of MSR:EE when we just turn it off to peek at TI_FLAGS without races. Only when we are calling into C code or returning from exceptions with a state that have changed from what lockdep thinks.

There's a little bugger though: If we take an exception that keeps interrupts enabled (such as an alignment exception) while interrupts are enabled, we will call trace_hardirqs_on() on the way back spurriously. Not a big deal, but to get rid of it would require remembering in pt_regs that the exception was one of the type that kept interrupts enabled which we don't know at this stage. (Well, we could test all cases for regs->trap but that sucks too much).

Quoted 6 lines

---

This one fixes a bug, trace_hardirqs_on was too late in the
restore: code path and would clobber things. This boots fine now on a PowerBook.

on SMP e500 based system (8572)

- k