linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rabin Vincent <rabin@rab.in>
To: "Pedanekar, Hemant" <hemantp@ti.com>
Cc: linux-omap <linux-omap@vger.kernel.org>
Subject: Re: !CONFIG_OMAP_32K_TIMER on OMAP4/panda
Date: Sun, 8 May 2011 14:41:31 +0530	[thread overview]
Message-ID: <BANLkTi=ZGTcsSiDJfHT-dq-oOnfuTCaFHQ@mail.gmail.com> (raw)
In-Reply-To: <2A3DCF3DA181AD40BDE86A3150B27B6B0374D103A2@dbde02.ent.ti.com>

On Sun, May 8, 2011 at 10:29, Pedanekar, Hemant <hemantp@ti.com> 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@rab.in>

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@rab.in>
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@rab.in>
---
 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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-05-08  9:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-07 16:50 !CONFIG_OMAP_32K_TIMER on OMAP4/panda Rabin Vincent
2011-05-08  4:59 ` Pedanekar, Hemant
2011-05-08  9:11   ` Rabin Vincent [this message]
2011-05-13 12:53   ` Kevin Hilman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTi=ZGTcsSiDJfHT-dq-oOnfuTCaFHQ@mail.gmail.com' \
    --to=rabin@rab.in \
    --cc=hemantp@ti.com \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).