public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk@arm.linux.org.uk>
To: Paul Walmsley <paul@pwsan.com>
Cc: Aaro Koskinen <aaro.koskinen@nokia.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>,
	Tony Lindgren <tony@atomide.com>,
	linux-omap@vger.kernel.org
Subject: Re: Open issues after 2.6.38 merge window
Date: Mon, 17 Jan 2011 21:19:56 +0000	[thread overview]
Message-ID: <20110117211956.GD4042@flint.arm.linux.org.uk> (raw)
In-Reply-To: <alpine.DEB.2.00.1101171341591.13225@utopia.booyaka.com>

On Mon, Jan 17, 2011 at 02:00:17PM -0700, Paul Walmsley wrote:
> On Mon, 17 Jan 2011, Russell King wrote:
> 
> > On Mon, Jan 17, 2011 at 01:31:47PM -0700, Paul Walmsley wrote:
> > > 
> > > OMAP15xx uses the MPU timer for its clocksource, since OMAP15xx doesn't 
> > > have GPTIMERs or the 32k sync timer, and the MPU timer code in 
> > > mach-omap1/time.c wasn't updated for sched_clock() support.
> > > 
> > > Adding an init_fixed_sched_clock() into omap_init_clocksource() should 
> > > fix the boot on OMAP15xx/7xx.
> > 
> > No, it needs fixing properly.  There's no reason the gpt clocksource
> > can't be used for sched_clock.
> 
> There's a very good reason why it can't on OMAP15xx/7xx.  GPTIMER/DMTIMER 
> IP blocks are only present on OMAP1610 and later[1].  Nor is a 
> SYNCTIMER_32K IP block present on OMAP15xx/7xx[2].

Yes I realise that.  That doesn't negate what I said though.  Let me
show you how to do it:

static DEFINE_CLOCK_DATA(cd);

static inline u32 32k_read_cycles(void)
{
...
}

static inline u32 gpt_read_cycles(void)
{
...
}


#if defined(GPTIMER) && defined(32KTIMER)
static u32 (*omap_read_cycles)(void);
#elif defined(32KTIMER)
#define SC_MULT			4000000000u
#define SC_SHIFT		17
#define omap_read_cycles	32k_read_cycles
#else
#define SC_MULT			gpt_value_if_fixed
#define SC_SHIFT		gpt_value_if_fixed
#define omap_read_cycles	gpt_read_cycles
#endif

unsigned long long notrace sched_clock(void)
{
	u32 cyc = omap_read_cycles();
#ifdef SC_MULT
	return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT);
#else
	return cyc_to_sched_clock(&cd, cyc, (u32)~0);
#endif
}

static void notrace omap_update_sched_clock(void)
{
	u32 cyc = omap_read_cycles();
	update_sched_clock(&cd, cyc, (u32)~0);
}

void omap_init_sched_clock(int gpt)
{
	unsigned long rate;

#ifndef omap_read_cycles
	omap_read_cycles = gpt ? gpt_read_cycles : 32k_read_cycles;
#endif

	if (gpt)
		rate = gpt_rate;
	else
		rate = 32768;

#ifdef SC_MULT
	init_fixed_sched_clock(&cd, omap_update_sched_clock, 32, rate
			       SC_MULT, SC_SHIFT);
#else
	init_sched_clock(&cd, omap_update_sched_clock, 32, rate);
#endif
}

Both a GPT _and_ 32K sched_clock implementation together, selectable
at runtime or build time depending on what is selected.  I'll give you
that it isn't nice code, but it does what's required.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:

  reply	other threads:[~2011-01-17 21:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-14 19:47 Open issues after 2.6.38 merge window Tony Lindgren
2011-01-14 20:24 ` Tony Lindgren
2011-01-14 20:37 ` Jarkko Nikula
2011-01-14 20:54   ` Tony Lindgren
2011-01-14 22:22     ` Nishanth Menon
2011-01-14 20:57 ` David Anders
2011-01-14 23:38   ` Tony Lindgren
2011-01-14 23:59     ` Tony Lindgren
2011-01-14 23:54 ` Thomas Weber
2011-01-15  5:19 ` Santosh Shilimkar
2011-01-17 10:15   ` Santosh Shilimkar
2011-01-27 18:41     ` Tony Lindgren
2011-01-17 11:37 ` Aaro Koskinen
2011-01-17 11:59   ` Santosh Shilimkar
2011-01-17 12:11     ` Russell King
2011-01-17 12:19       ` Santosh Shilimkar
2011-01-17 12:24         ` Russell King
2011-01-17 18:29           ` Tony Lindgren
2011-01-17 12:22     ` Aaro Koskinen
2011-01-17 12:35       ` Santosh Shilimkar
2011-01-17 12:50         ` Russell King
2011-01-17 18:20           ` Tony Lindgren
2011-01-17 20:31       ` Paul Walmsley
2011-01-17 20:39         ` Russell King
2011-01-17 21:00           ` Paul Walmsley
2011-01-17 21:19             ` Russell King [this message]
2011-01-17 22:49               ` Paul Walmsley

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=20110117211956.GD4042@flint.arm.linux.org.uk \
    --to=rmk@arm.linux.org.uk \
    --cc=aaro.koskinen@nokia.com \
    --cc=jkrzyszt@tis.icnet.pl \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.com \
    /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