ARM: mxc: Add dummy_get_cycles to avoid access before init is done
Subsystems (3)
PATCH 1/2 ARM: mxc: Add dummy_get_cycles to avoid access before init is done
this is needed to use get_cycles with sched_clock. Accessing timer without enabled clk will result in crash
Signed-off-by Jan Weitzel <[email protected]>
--- arch/arm/plat-mxc/time.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
arch/arm/plat-mxc/time.c +8 -1
@@ -105,6 +105,11 @@ static void gpt_irq_acknowledge(void)__raw_writel (V2_TSTAT_OF1 , timer_base +V2_TSTAT ); } +static cycle_t dummy_get_cycles (struct clocksource *cs) +{ +return 0 ; +} +static cycle_t mx1_2_get_cycles (struct clocksource *cs) {return __raw_readl (timer_base +MX1_2_TCN );
@@ -118,7 +123,7 @@ static cycle_t v2_get_cycles(struct clocksource *cs)static struct clocksource clocksource_mxc = { .name ="mxc_timer1" , .rating =200 , - .read = mx1_2_get_cycles, + .read = dummy_get_cycles, .mask =CLOCKSOURCE_MASK (32 ), .flags =CLOCK_SOURCE_IS_CONTINUOUS , };
@@ -129,6 +134,8 @@ static int __init mxc_clocksource_init(struct clk *timer_clk)if (timer_is_v2 ()) clocksource_mxc.read = v2_get_cycles; +else + clocksource_mxc.read = mx1_2_get_cycles;clocksource_register_hz (&clocksource_mxc, c);
Signature · 1 line
1.7.0.4
PATCH 2/2 ARM: mxc: Add sched_clock to mxc platform
Add sched_clock using cyc_to_sched_clock and update_sched_clock with HAVE_SCHED_CLOCK
tested on iMX27 and iMX35
Signed-off-by Jan Weitzel <[email protected]>
--- arch/arm/Kconfig | 1 + arch/arm/plat-mxc/time.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-)
arch/arm/Kconfig +1 -0
@@ -356,6 +356,7 @@ config ARCH_MXC select GENERIC_CLOCKEVENTS select ARCH_REQUIRE_GPIOLIB select CLKDEV_LOOKUP + select HAVE_SCHED_CLOCK help Support for Freescale MXC/iMX-based family of processors
arch/arm/plat-mxc/time.c +16 -0
@@ -27,6 +27,7 @@#include <linux/clk.h> #include <mach/hardware.h> +#include <asm/sched_clock.h> #include <asm/mach/time.h> #include <mach/common.h>
@@ -128,6 +129,20 @@ static struct clocksource clocksource_mxc = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; +static DEFINE_CLOCK_DATA (cd); +unsigned long long notrace sched_clock (void ) +{ +cycle_t cyc = clocksource_mxc.read (&clocksource_mxc); + +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 ); +} + +static void notrace mxc_update_sched_clock(void) +{ +cycle_t cyc = clocksource_mxc.read (&clocksource_mxc); +update_sched_clock (&cd, cyc, (u32 )~0 ); +} +static int __init mxc_clocksource_init (struct clk *timer_clk) {unsigned int c =clk_get_rate (timer_clk);
@@ -137,6 +152,7 @@ static int __init mxc_clocksource_init(struct clk *timer_clk)else clocksource_mxc.read = mx1_2_get_cycles; +init_sched_clock (&cd, mxc_update_sched_clock,32 , c);clocksource_register_hz (&clocksource_mxc, c);return 0 ;
Signature · 1 line
1.7.0.4
PATCH 2/2 ARM: mxc: Add sched_clock to mxc platform
Quoted 35 lines · Jan Weitzel
Add
sched_clockusingcyc_to_sched_clockandupdate_sched_clockwithHAVE_SCHED_CLOCK
tested on iMX27 and iMX35Signed-off-by Jan Weitzel <[email protected]>--- arch/arm/Kconfig | 1 + arch/arm/plat-mxc/time.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-)arch/arm/Kconfig +1
-0@@ -356,6 +356,7 @@ config ARCH_MXC select GENERIC_CLOCKEVENTS select ARCH_REQUIRE_GPIOLIB select CLKDEV_LOOKUP + select HAVE_SCHED_CLOCK help Support for Freescale MXC/iMX-based family of processorsarch/arm/plat-mxc/time.c +1
-0@@ -27,6 +27,7 @@#include <linux/clk.h> #include <mach/hardware.h> +#include <asm/sched_clock.h> #include <asm/mach/time.h> #include <mach/common.h>
arch/arm/plat-mxc/time.c static struct clocksource clocksource_mxc = { · line 137
Quoted 9 lines
arch/arm/plat-mxc/time.c +6
-0@@ -128,6 +129,20 @@ static struct clocksource clocksource_mxc = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; +static DEFINE_CLOCK_DATA (cd); +unsigned long long notrace sched_clock (void ) +{ +cycle_t cyc = clocksource_mxc.read (&clocksource_mxc); + +return cyc_to_sched_clock (&cd, cyc, (u32 )~0 );
This cast to u32 isn't needed. The third argument to cyc_to_sched_clock (and update_sched_clock below) is a u32 anyhow. I would support
~(u32)0
though.
Best regards
Uwe
Quoted 19 lines
arch/arm/plat-mxc/time.c +9
-0+} + +static void notrace mxc_update_sched_clock(void) +{ +cycle_t cyc = clocksource_mxc.read (&clocksource_mxc); +update_sched_clock (&cd, cyc, (u32 )~0 ); +} +static int __init mxc_clocksource_init (struct clk *timer_clk) {unsigned int c =clk_get_rate (timer_clk);@@ -137,6 +152,7 @@ static int __init mxc_clocksource_init(struct clk *timer_clk)else clocksource_mxc.read = mx1_2_get_cycles; +init_sched_clock (&cd, mxc_update_sched_clock,32 , c);clocksource_register_hz (&clocksource_mxc, c);return 0 ;
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |