On Sun, May 8, 2011 at 10:29, Pedanekar, Hemant <hemantp@xxxxxx> wrote: > diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c > index 3b9cf85..290fbfa 100644 > --- a/arch/arm/mach-omap2/timer-gp.c > +++ b/arch/arm/mach-omap2/timer-gp.c > @@ -229,6 +229,11 @@ static void __init omap2_gp_clocksource_init(void) > "%s: failed to request dm-timer\n"; > static char err2[] __initdata = KERN_ERR > "%s: can't register clocksource!\n"; > + char clocksource_hwmod_name[8]; /* 8 = sizeof("timerXX0") */ > + > + /* XXX: This may not be always true, we might get different timer */ > + sprintf(clocksource_hwmod_name, "timer%d", gptimer_id + 1); > + omap_hwmod_setup_one(clocksource_hwmod_name); > > gpt = omap_dm_timer_request(); > if (!gpt) > Thanks, this appears to fix the gp timer clocksource on OMAP4: Tested-by: Rabin Vincent <rabin@xxxxxx> However, sched_clock() is broken with !CONFIG_OMAP_32K_TIMER, and it needs the below patch in addition to yours: 8<---------- >From 3fa494b910cc65c31b661a0a99a9fcf207d9b795 Mon Sep 17 00:00:00 2001 From: Rabin Vincent <rabin@xxxxxx> Date: Sun, 8 May 2011 14:23:50 +0530 Subject: [PATCH] OMAP2+: use timer-gp as sched_clock when 32k timer is disabled When OMAP_32K_TIMER is disabled, sched_clock() always returns zero because it incorrectly always uses the (non-initialized) 32k timer clocksource. To fix this, make sched_clock() use the gp timer clocksource when the 32k timer is disabled. Signed-off-by: Rabin Vincent <rabin@xxxxxx> --- arch/arm/mach-omap2/timer-gp.c | 16 ++++++++++++++-- arch/arm/plat-omap/counter_32k.c | 8 ++++---- arch/arm/plat-omap/dmtimer.c | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c index 3b9cf85..e783bfe 100644 --- a/arch/arm/mach-omap2/timer-gp.c +++ b/arch/arm/mach-omap2/timer-gp.c @@ -198,15 +198,20 @@ static void __init omap2_gp_clocksource_init(void) */ static DEFINE_CLOCK_DATA(cd); static struct omap_dm_timer *gpt_clocksource; -static cycle_t clocksource_read_cycles(struct clocksource *cs) +static cycle_t notrace clocksource_read_cycles(struct clocksource *cs) { return (cycle_t)omap_dm_timer_read_counter(gpt_clocksource); } +static cycle_t notrace clocksource_gpt_read_dummy(struct clocksource *cs) +{ + return 0; +} + static struct clocksource clocksource_gpt = { .name = "gp timer", .rating = 300, - .read = clocksource_read_cycles, + .read = clocksource_gpt_read_dummy, .mask = CLOCKSOURCE_MASK(32), .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; @@ -220,6 +225,12 @@ static void notrace dmtimer_update_sched_clock(void) update_sched_clock(&cd, cyc, (u32)~0); } +unsigned long long notrace sched_clock(void) +{ + u32 cyc = clocksource_gpt.read(&clocksource_gpt); + return cyc_to_sched_clock(&cd, cyc, (u32)~0); +} + /* Setup free-running counter for clocksource */ static void __init omap2_gp_clocksource_init(void) { @@ -240,6 +251,7 @@ static void __init omap2_gp_clocksource_init(void) omap_dm_timer_set_load_start(gpt, 1, 0); + clocksource_gpt.read = clocksource_read_cycles; init_sched_clock(&cd, dmtimer_update_sched_clock, 32, tick_rate); if (clocksource_register_hz(&clocksource_gpt, tick_rate)) diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c index f7fed60..9231499 100644 --- a/arch/arm/plat-omap/counter_32k.c +++ b/arch/arm/plat-omap/counter_32k.c @@ -126,13 +126,13 @@ static inline unsigned long long notrace _omap_32k_sched_clock(void) return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT); } -#ifndef CONFIG_OMAP_MPU_TIMER -unsigned long long notrace sched_clock(void) +#ifdef CONFIG_OMAP_MPU_TIMER +unsigned long long notrace omap_32k_sched_clock(void) { return _omap_32k_sched_clock(); } -#else -unsigned long long notrace omap_32k_sched_clock(void) +#elif defined(CONFIG_OMAP_32K_TIMER) +unsigned long long notrace sched_clock(void) { return _omap_32k_sched_clock(); } diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index ee9f6eb..0648d63 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -700,7 +700,7 @@ void omap_dm_timer_write_status(struct omap_dm_timer *timer, unsigned int value) } EXPORT_SYMBOL_GPL(omap_dm_timer_write_status); -unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *timer) +unsigned int notrace omap_dm_timer_read_counter(struct omap_dm_timer *timer) { unsigned int l; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html