Re: [PATCH 6/7] save and restore etm state across core OFF modes

2010-07-30 Thread Alexander Shishkin
On Sun, Jul 25, 2010 at 08:05:19 +0300, Alexander Shishkin wrote:
> This prevents ETM stalls whenever core enters OFF mode. Original patch
> author is Richard Woodruff .
> 
> This version of the patch makes use of the ETM OS save/restore mechanism,
> which takes about 55 words in omap3_arm_context[] instead of 128. Also,
> saving ETM context can be switched on/off at runtime.

Can I have some (n)acks on this one and 7/7 as well?

Regards,
--
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/7] save and restore etm state across core OFF modes

2010-07-25 Thread Alexander Shishkin
On Sun, Jul 25, 2010 at 12:34:22 -0600, Hari Kanigeri wrote:
> > +config ENABLE_OFF_MODE_JTAG_ETM_DEBUG
> > +       bool "Enable hardware emulation context save and restore"
> > +       depends on ARCH_OMAP3
> 
> -- Shouldn't this be depends on OMAP3_EMU instead ?

Not really. OMAP3_EMU will enable ETM/ETB drivers within omap, but this
particular patch is also needed if you're using an external hardware
debugger to debug code across OFF modes.

> > +       default y
> 
> -- As this is debug option, can you keep this "n" by default ?

This option allows for enabling certain debugging functionality in runtime
(via a sysfs file), which is turned off by default. It is debatable whether
this option should default to 'y' or 'n', seeing as it doesn't add much
overhead to the normal usecase.

> > +       help
> > +         This option enables JTAG & ETM debugging across power states.
> > +         With out this option emulation features are reset across OFF
> > +         mode state changes.

But I see that the wording is misleading and unclear, so I'll try to come
up with something more descriptive.

Regards,
--
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/7] save and restore etm state across core OFF modes

2010-07-25 Thread Hari Kanigeri
> +config ENABLE_OFF_MODE_JTAG_ETM_DEBUG
> +       bool "Enable hardware emulation context save and restore"
> +       depends on ARCH_OMAP3

-- Shouldn't this be depends on OMAP3_EMU instead ?

> +       default y

-- As this is debug option, can you keep this "n" by default ?

> +       help
> +         This option enables JTAG & ETM debugging across power states.
> +         With out this option emulation features are reset across OFF
> +         mode state changes.
> +

Hari
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] save and restore etm state across core OFF modes

2010-07-25 Thread Alexander Shishkin
This prevents ETM stalls whenever core enters OFF mode. Original patch
author is Richard Woodruff .

This version of the patch makes use of the ETM OS save/restore mechanism,
which takes about 55 words in omap3_arm_context[] instead of 128. Also,
saving ETM context can be switched on/off at runtime.

Signed-off-by: Alexander Shishkin 
Cc: Richard Woodruff 
Cc: Tony Lindgren 
Cc: Russell King 
Cc: Paul Walmsley 
Cc: Kevin Hilman 
Cc: linux-omap@vger.kernel.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-ker...@vger.kernel.org
---
 arch/arm/mach-omap2/Kconfig   |9 ++
 arch/arm/mach-omap2/control.c |2 +-
 arch/arm/mach-omap2/sleep34xx.S   |  135 +
 arch/arm/plat-omap/include/plat/control.h |2 +-
 4 files changed, 146 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index b48bacf..0413d88 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -243,6 +243,15 @@ config MACH_OMAP4_PANDA
default y
depends on ARCH_OMAP4
 
+config ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   bool "Enable hardware emulation context save and restore"
+   depends on ARCH_OMAP3
+   default y
+   help
+ This option enables JTAG & ETM debugging across power states.
+ With out this option emulation features are reset across OFF
+ mode state changes.
+
 config OMAP3_EMU
bool "OMAP3 debugging peripherals"
depends on ARCH_OMAP3
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index a8d20ee..22dd240 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -93,7 +93,7 @@ void *omap3_secure_ram_storage;
  * The address is stored in scratchpad, so that it can be used
  * during the restore path.
  */
-u32 omap3_arm_context[128];
+u32 omap3_arm_context[256];
 
 struct omap3_control_regs {
u32 sysconfig;
diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index d522cd7..cd6a1d4 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "cm.h"
 #include "prm.h"
@@ -226,6 +227,18 @@ loop:
nop
bl wait_sdrc_ok
 
+#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   /*
+* Restore Coresight debug registers
+*/
+   ldr r6, debug_vbase /* base Vaddr of CortexA8-Debug */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   ldr r6, etm_vbase   /* base Vaddr of ETM */
+   bl  unlock_debug/* remove global lock if set */
+   str r6, [r6, #ETMMR_OSLAR]  /* clear OSLAR lock using non-key */
+#endif
+
ldmfd   sp!, {r0-r12, pc}   @ restore regs and return
 restore_es3:
/*b restore_es3*/   @ Enable to debug restore code
@@ -385,6 +398,44 @@ logic_l1_restore:
/*normal memory remap register */
MCR p15, 0, r5, c10, c2, 1
 
+#ifdef CONFIG_ENABLE_OFF_MODE_JTAG_ETM_DEBUG
+   /*
+* Restore Coresight debug registers
+*/
+   ldr r6, debug_pbase /* base paddr of CortexA8-Debug */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   str r4, [r6, #ETMMR_OSLAR]  /* reset-pointer (already locked) */
+   ldr r4, [r6, #ETMMR_OSSRR]  /* dummy read */
+   ldr r4, [r3], #4/* load save size */
+   cmp r4, #0  /* check for zero */
+debug_restore:
+   itttne  /* t2/compat if-then block */
+   ldrne   r5, [r3], #4/* get saved value */
+   strne   r5, [r6,#ETMMR_OSSRR]   /* restore saved value */
+   subnes  r4, r4, #1  /* decrement loop */
+   bne debug_restore   /* loop till done */
+   str r5, [r6, #ETMMR_OSSRR]  /* clear lock */
+   /*
+* Restore CoreSight ETM registers
+*/
+   ldr r6, etm_pbase   /* base paddr of ETM */
+   ldr r4, debug_xlar_key  /* get lock key for OSLAR */
+   bl  unlock_debug/* remove global lock if set */
+   str r4, [r6, #ETMMR_OSLAR]  /* reset-pointer (already locked) */
+   ldr r4, [r6, #ETMMR_OSSRR]  /* dummy read */
+   ldr r4, [r3], #4/* load save size */
+   cmp r4, #0  /* check for zero */
+   beq etm_skip
+etm_restore:
+   ldrne   r5, [r3], #4/* get saved value */
+   strne   r5, [r6, #ETMMR_OSSRR]  /* restore saved value */
+   subnes  r4, r4, #1  /* decrement loop */
+   bne etm_restore /* loop till done */
+etm_skip:
+   str r6, [r6, #ETMMR_OSLAR]  /* remo