OMAP GPTimer for OProfile(Errata#628216)
PATCH 1/1 OMAP GPTimer for OProfile(Errata#628216)
From: DebBarma, Tarun Kanti <[email protected]>
[ARM Cortex-A8 Errata 628216]
If a Perf Counter OVFL occurs simultaneously with an update to a CP14 or CP15 register, the OVFL status can be lost.
In order to workaround problem in Cortex-A8 Performance Counter, OMAP GPTIMER is used by OProfile.
--- arch/arm/Kconfig | 59 +++++++++++++++--- arch/arm/oprofile/Makefile | 1 + arch/arm/oprofile/common.c | 4 + arch/arm/oprofile/op_arm_model.h | 1 + arch/arm/oprofile/op_model_omap_gptimer.c | 96 +++++++++++++++++++++++++++++ 5 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 arch/arm/oprofile/op_model_omap_gptimer.c
arch/arm/Kconfig +51 -8
@@ -175,27 +175,70 @@ config ARM_L1_CACHE_SHIFT_6 help Setting ARM L1 cache line size to 64 Bytes. -if OPROFILE +menuconfig INSTRUMENTATION + bool "Instrumentation Support" + default y + ---help--- + Say Y here to get to see options related to performance measurement, + system-wide debugging and testing. This option alone does not add any + kernel code. + + If you say N, all options in this submenu will be skipped and + disabled. If you're trying to debug the kernel itself, check the + Kernel Hacking menu. + +if INSTRUMENTATION + +config PROFILING + bool "Profiling support" + help + Say Y here to enable the extended profiling support mechanisms + used by profilers such as OProfile. + +config OPROFILE + tristate "OProfile system profiling" + depends on PROFILING + help + OProfile is a profiling system capable of profiling the + whole system, including the kernel, kernel modules, libraries, + and applications. + + If unsure, say N. +choice + prompt "Oprofile Mode" + depends on OPROFILE + default OPROFILE_OMAP_GPTIMER config OPROFILE_ARMV6 - def_bool y + bool "Oprofile ARMv6" depends on CPU_V6 && !SMP select OPROFILE_ARM11_CORE config OPROFILE_MPCORE - def_bool y + bool "Oprofile MPcore" depends on CPU_V6 && SMP select OPROFILE_ARM11_CORE -config OPROFILE_ARM11_CORE - bool - config OPROFILE_ARMV7 - def_bool y + bool "Oprofile ARMv7" depends on CPU_V7 && !SMP + help + Uses Performance counters for profiling + +config OPROFILE_OMAP_GPTIMER + bool "Oprofile GPTimer" + depends on ARCH_OMAP + select OMAP_32K_TIMER + select OMAP_DM_TIMER + help + Uses GPTIMER for profiling. Currently this is the preferred + way since Performance counters have known bugs in Cortex-A8 +endchoice + +config OPROFILE_ARM11_CORE bool -endif +endif # INSTRUMENTATION config VECTORS_BASE hex
arch/arm/oprofile/Makefile +1 -0
@@ -8,6 +8,7 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ oprofile-y := $(DRIVER_OBJS) common.o backtrace.o oprofile-$(CONFIG_CPU_XSCALE) += op_model_xscale.o +oprofile-$(CONFIG_OPROFILE_OMAP_GPTIMER) += op_model_omap_gptimer.o oprofile-$(CONFIG_OPROFILE_ARM11_CORE) += op_model_arm11_core.o oprofile-$(CONFIG_OPROFILE_ARMV6) += op_model_v6.o oprofile-$(CONFIG_OPROFILE_MPCORE) += op_model_mpcore.o
arch/arm/oprofile/common.c +4 -0
@@ -133,6 +133,10 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) ops->backtrace = arm_backtrace; +#ifdef CONFIG_OPROFILE_OMAP_GPTIMER + spec = &op_omap_gptimer_spec; +#endif +#ifdef CONFIG_CPU_XSCALE spec = &op_xscale_spec;#endif
arch/arm/oprofile/op_arm_model.h +1 -0
@@ -24,6 +24,7 @@ struct op_arm_model_spec {extern struct op_arm_model_spec op_xscale_spec;#endif +extern struct op_arm_model_spec op_omap_gptimer_spec;extern struct op_arm_model_spec op_armv6_spec;extern struct op_arm_model_spec op_mpcore_spec;extern struct op_arm_model_spec op_armv7_spec;
arch/arm/oprofile/op_model_omap_gptimer.c new file +96 -0
96 lines not on this page · raw message
Signature · 1 line
1.6.0.4
Tarun,
Quoted 99 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Manjunatha GK
Sent: Thursday, April 01, 2010 8:54 PM
To: [email protected]
Cc: DebBarma, Tarun Kanti; Siarhei Siamashka; G, Manjunath Kondaiah
Subject: [PATCH] OMAP GPTimer for OProfile(Errata#628216)From: DebBarma, Tarun Kanti <[email protected]>
[ARM Cortex-A8 Errata 628216]
If a Perf Counter OVFL occurs simultaneously with an update to a CP14 or CP15 register, the OVFL status can be lost.In order to workaround problem in Cortex-A8 Performance Counter, OMAP GPTIMER is used by OProfile.
Signed-off-by Tarun Kanti DebBarma <[email protected]>Cc Siarhei Siamashka <[email protected]>Cc Manjunatha GK <[email protected]>--- arch/arm/Kconfig | 59 +++++++++++++++--- arch/arm/oprofile/Makefile | 1 + arch/arm/oprofile/common.c | 4 + arch/arm/oprofile/op_arm_model.h | 1 + arch/arm/oprofile/op_model_omap_gptimer.c | 96 +++++++++++++++++++++++++++++ 5 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 arch/arm/oprofile/op_model_omap_gptimer.carch/arm/Kconfig +44
-7@@ -175,27 +175,70 @@ config ARM_L1_CACHE_SHIFT_6 help Setting ARM L1 cache line size to 64 Bytes. -if OPROFILE +menuconfig INSTRUMENTATION + bool "Instrumentation Support" + default y + ---help--- + Say Y here to get to see options related to performance measurement, + system-wide debugging and testing. This option alone does not add any + kernel code. + + If you say N, all options in this submenu will be skipped and + disabled. If you're trying to debug the kernel itself, check the + Kernel Hacking menu. + +if INSTRUMENTATION + +config PROFILING + bool "Profiling support" + help + Say Y here to enable the extended profiling support mechanisms + used by profilers such as OProfile. + +config OPROFILE + tristate "OProfile system profiling" + depends on PROFILING + help + OProfile is a profiling system capable of profiling the + whole system, including the kernel, kernel modules, libraries, + and applications. + + If unsure, say N. +choice + prompt "Oprofile Mode" + depends on OPROFILE + default OPROFILE_OMAP_GPTIMER config OPROFILE_ARMV6 - def_bool y + bool "Oprofile ARMv6" depends on CPU_V6 && !SMP select OPROFILE_ARM11_CORE config OPROFILE_MPCORE - def_bool y + bool "Oprofile MPcore" depends on CPU_V6 && SMP select OPROFILE_ARM11_CORE -config OPROFILE_ARM11_CORE - bool - config OPROFILE_ARMV7 - def_bool y + bool "Oprofile ARMv7" depends on CPU_V7 && !SMP + help + Uses Performance counters for profiling + +config OPROFILE_OMAP_GPTIMER + bool "Oprofile GPTimer" + depends on ARCH_OMAP + select OMAP_32K_TIMER + select OMAP_DM_TIMER
arch/arm/Kconfig config ARM_L1_CACHE_SHIFT_6 · line 241
Quoted 10 lines
arch/arm/Kconfig +7
-1+ help + Uses GPTIMER for profiling. Currently this is the preferred + way since Performance counters have known bugs in Cortex-A8 +endchoice + +config OPROFILE_ARM11_CORE bool -endif +endif # INSTRUMENTATION
Do you need so many KConfig entries??
Quoted 84 lines
arch/arm/Kconfig +0
-0config VECTORS_BASE hexarch/arm/oprofile/Makefile +1
-0@@ -8,6 +8,7 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ oprofile-y := $(DRIVER_OBJS) common.o backtrace.o oprofile-$(CONFIG_CPU_XSCALE) += op_model_xscale.o +oprofile-$(CONFIG_OPROFILE_OMAP_GPTIMER) += op_model_omap_gptimer.o oprofile-$(CONFIG_OPROFILE_ARM11_CORE) += op_model_arm11_core.o oprofile-$(CONFIG_OPROFILE_ARMV6) += op_model_v6.o oprofile-$(CONFIG_OPROFILE_MPCORE) += op_model_mpcore.oarch/arm/oprofile/common.c +4
-0@@ -133,6 +133,10 @@ int __init oprofile_arch_init(struct oprofile_operations *ops) ops->backtrace = arm_backtrace; +#ifdef CONFIG_OPROFILE_OMAP_GPTIMER + spec = &op_omap_gptimer_spec; +#endif +#ifdef CONFIG_CPU_XSCALE spec = &op_xscale_spec;#endif arch/arm/oprofile/op_arm_model.h +1
-0@@ -24,6 +24,7 @@ struct op_arm_model_spec {extern struct op_arm_model_spec op_xscale_spec;#endif +extern struct op_arm_model_spec op_omap_gptimer_spec;extern struct op_arm_model_spec op_armv6_spec;extern struct op_arm_model_spec op_mpcore_spec;extern struct op_arm_model_spec op_armv7_spec;arch/arm/oprofile/op_model_omap_gptimer.c new file +37
-0@@ -0,0 +1,96 @@ +/** +* OMAP gptimer based event monitor driver for oprofile +* +* Copyright (C) 2009 Nokia Corporation +* Author: Siarhei Siamashka <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +#include <linux/types.h> +#include <linux/oprofile.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <plat/dmtimer.h> + +#include "op_counter.h" +#include "op_arm_model.h" + +static struct omap_dm_timer *gptimer; + +static int gptimer_init (void ) +{ +return 0 ; +} + +static int gptimer_setup (void ) +{ +return 0 ; +} + +static irqreturn_t gptimer_interrupt (int irq,void *arg) +{ +omap_dm_timer_write_status (gptimer,OMAP_TIMER_INT_OVERFLOW ); +oprofile_add_sample (get_irq_regs (),0 );
arch/arm/oprofile/op_model_omap_gptimer.c line 47
Quoted 10 lines
arch/arm/oprofile/op_model_omap_gptimer.c new file +10
-0+return IRQ_HANDLED ; +} + +static int gptimer_start (void ) +{ +int err; +u32 count = counter_config[0 ].count; + +BUG_ON (gptimer !=NULL ); +/* First try to request timers from CORE power domain for OMAP3 */
If any timer is ok, why specific timer ?
arch/arm/oprofile/op_model_omap_gptimer.c line 60
Quoted 13 lines
arch/arm/oprofile/op_model_omap_gptimer.c new file +13
-0+if (cpu_is_omap34xx ()) { + gptimer =omap_dm_timer_request_specific (10 ); +if (gptimer ==NULL ) + gptimer =omap_dm_timer_request_specific (11 ); + } +/* Just any timer would be fine */ +if (gptimer ==NULL ) + gptimer =omap_dm_timer_request (); + +if (gptimer ==NULL ) +return -ENODEV ; + +omap_dm_timer_set_source (gptimer,OMAP_TIMER_SRC_32_KHZ );
With Sys clock this can give better resolution o.w any accuracy below ~30 uS is lost.
Quoted 25 lines
arch/arm/oprofile/op_model_omap_gptimer.c new file +25
-0+ err =request_irq (omap_dm_timer_get_irq (gptimer), gptimer_interrupt, +IRQF_DISABLED ,"oprofile gptimer" ,NULL ); +if (err) { +omap_dm_timer_free (gptimer); + gptimer =NULL ; +printk (KERN_ERR "oprofile: unable to request gptimer IRQ\n" ); +return err; + } + +/* opcontrol sets default value as 100000 which makes the sample rate +* too low, hence resetting +*/ +if ((count <0 ) || (count ==100000 )) + count =1 ; + +omap_dm_timer_set_load_start (gptimer,1 ,0xffffffff - count); +omap_dm_timer_set_int_enable (gptimer,OMAP_TIMER_INT_OVERFLOW ); +return 0 ; +} + +static void gptimer_stop (void ) +{ +omap_dm_timer_set_int_enable (gptimer,0 ); +free_irq (omap_dm_timer_get_irq (gptimer),NULL ); +omap_dm_timer_free (gptimer);
arch/arm/oprofile/op_model_omap_gptimer.c line 95
Quoted 10 lines
arch/arm/oprofile/op_model_omap_gptimer.c new file +10
-0+ gptimer =NULL ; +} + +struct op_arm_model_spec op_omap_gptimer_spec = { + .init = gptimer_init, + .num_counters =1 , + .setup_ctrs = gptimer_setup, + .start = gptimer_start, + .stop = gptimer_stop, + .name ="arm/armv6" ,
This is done for Cortex-A8 right which is armv7
Quoted 8 lines
arch/arm/oprofile/op_model_omap_gptimer.c new file +1
-1+}; --1.6.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · On Thursday 01 April 2010 18:24:08 ext Manjunatha GK wrote:
From: DebBarma, Tarun Kanti <[email protected]>
[ARM Cortex-A8 Errata 628216]
If a Perf Counter OVFL occurs simultaneously with an update to a CP14 or CP15 register, the OVFL status can be lost.In order to workaround problem in Cortex-A8 Performance Counter, OMAP GPTIMER is used by OProfile.
Thanks for digging this up. But even though GPTIMER has a lower overhead, there is actually a better (more portable) fix which is on the way into mainline kernel:
http://marc.info/?l=oprofile-list&m=126754919315010&w=2
Samples collection frequency can be adjusted by another patch (the default 128Hz used on most ARM boards/devices is way too low).
oprofile kernel module can be loaded with 'timer=1' parameter to override the use of buggy Cortex-A8 PMU.
Signature · 2 lines
Best regards, Siarhei Siamashka
Quoted 25 lines
-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Siarhei Siamashka
Sent: 2010-04-01 21:02
To: G, Manjunath Kondaiah; Koskinen Aaro (Nokia-D/Helsinki)
Cc: [email protected]; DebBarma, Tarun Kanti
Subject: Re: [PATCH] OMAP GPTimer for OProfile(Errata#628216)Quoted 8 lines · On Thursday 01 April 2010 18:24:08 ext Manjunatha GK wrote:
From: DebBarma, Tarun Kanti <[email protected]>
[ARM Cortex-A8 Errata 628216]
If a Perf Counter OVFL occurs simultaneously with an update to a CP14 or CP15 register, the OVFL status can be lost.In order to workaround problem in Cortex-A8 Performance Counter, OMAP GPTIMER is used by OProfile.
Thanks for digging this up. But even though GPTIMER has a lower overhead, there is actually a better (more portable) fix which is on the way into mainline kernel:
http://marc.info/?l=oprofile-list&m=126754919315010&w=2
Quoted 5 lines
Samples collection frequency can be adjusted by another patch (the default 128Hz used on most ARM boards/devices is way too low).
oprofile kernel module can be loaded with 'timer=1' parameter to override the use of buggy Cortex-A8 PMU.
[Ghorai] ok. Your patch did not work if I build inside kernel image. Here is the error - $>opcontrol --setup --vmlinux=/vmlinuxcpu_type 'unset' is not valid
you should upgrade oprofile or force the use of timer mode /usr/bin/objdump
Quoted 8 lines
--
Best regards,
Siarhei Siamashka
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html