public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	linux-mips@linux-mips.org, Thomas Gleixner <tglx@linutronix.de>,
	Michal Simek <monstr@monstr.eu>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] MIPS: Add a high resolution sched_clock() via cnt32_to_63().
Date: Sun, 22 Nov 2009 12:35:09 +0000	[thread overview]
Message-ID: <20091122123509.GA1941@linux-mips.org> (raw)
In-Reply-To: <1258888086.4548.52.camel@falcon.domain.org>

On Sun, Nov 22, 2009 at 07:08:05PM +0800, Wu Zhangjin wrote:

> > > +	data = (0xffffffffUL / tclk / 2 - 2) * HZ;
> 
> Because the MIPS c0 count's frequency is half of the cpu frequency(Hi,
> Ralf, does every MIPS c0 count meet this feature?), so, the above line
> should be:

There are processors which have no cp0 counter at all; these are mostly
very old pre-R4000 era 32-bit MIPS I and MIPS II cores.

Of those which have a cp0 counter most will clock it at "half the maximum
instruction issue rate" and a few at the full rate.  Finally for a few
such as the RM52xx either half or the full count the rate is selectable by
the reset initialization bitstream fed into the processor.  Too make this
feature suck nicely there is no way for software to find out which rate
was selected so software must know that or calibrate against a timer of
known frequency.

Platform-specific code does this by setting mips_hpt_frequency to the
count rate before calling init_r4k_clocksource; it's also the value being
passed into setup_sched_clock_update() so you don't need to count for the
half / full clock rate thing there.

I don't see why you need the -2 in your formula so the whole thing can
be simplified to:

	data = 0x80000000 / tclk * HZ;

  Ralf

  parent reply	other threads:[~2009-11-22 12:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-22  7:44 [PATCH v2] MIPS: Add a high resolution sched_clock() via cnt32_to_63() Wu Zhangjin
2009-11-22  8:13 ` Ingo Molnar
2009-11-22 11:08   ` Wu Zhangjin
2009-11-22 11:55     ` Sergei Shtylyov
2009-11-22 12:35     ` Ralf Baechle [this message]
2009-11-22 13:18       ` Wu Zhangjin
2009-11-22 11:51   ` Sergei Shtylyov
2009-11-22 18:06     ` Ingo Molnar
2009-11-22 20:23       ` Ralf Baechle
2009-11-23  8:42         ` Ingo Molnar
2009-12-02  1:58           ` Maciej W. Rozycki

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=20091122123509.GA1941@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=mingo@elte.hu \
    --cc=monstr@monstr.eu \
    --cc=tglx@linutronix.de \
    --cc=wuzhangjin@gmail.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