linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 05/14] ARM: integrator: use clocksource_of_init for sp804
Date: Fri, 15 Mar 2013 12:15:54 +0000	[thread overview]
Message-ID: <20130315121554.GH4977@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CACRpkdZjddrHgTu+fjYVOb0Pk+1VYUU=S7LU_O_vdNKYH_vjiw@mail.gmail.com>

On Wed, Mar 13, 2013 at 10:00:14AM +0100, Linus Walleij wrote:
> Then the Integrator/AP timer has this code in the
> integrator_clockevent_init() function:
> 
> 	clkevt_base = base;
> 	/* Calculate and program a divisor */
> 	if (rate > 0x100000 * HZ) {
> 		rate /= 256;
> 		ctrl |= TIMER_CTRL_DIV256;
> 	} else if (rate > 0x10000 * HZ) {
> 		rate /= 16;
> 		ctrl |= TIMER_CTRL_DIV16;
> 	}
> 
> It appears the SP804 has no code to handle this
> divisor/prescaler at all. Which means that you regress
> the Integrator/AP again.
> 
> It appears (from arm_timer.h) that the SP804 actually
> has this prescaler, but then first make a separate patch
> to make the SP804 driver use that divisor (like above) so
> you don't degrade the quality of the AP timer. The prescaler
> make it possible to let the system sleep for longer times
> when using NO_HZ so it's *pretty* important (and it will
> increas the quality of all SP804-based machines as well).
> 
> As you surely understand, since the counter on the
> Integrator/AP is only 16 bit this is very important, since
> we don't want it to wake up too often.
> 
> Then the clocksource init function has this:
> 
> 	if (rate >= 1500000) {
> 		rate /= 16;
> 		ctrl |= TIMER_CTRL_DIV16;
> 	}
> 
> Here I'm more uncertain. As I know from extensive
> discussions with John and Thomas, there are many many
> factors to decide the clocksource. Basically the above lines
> limits the precision of the clocksource in exchange for a
> longer time until wrap-around. Again, the 16bit nature of the
> Integrator/AP timer is a factor here.

Integrator/AP selects the prescaler based on the fact that it is only a
16-bit counter, which has to be clocked at a rate which gives us our
desired periodic tick interval.

SP804 does not do this because, being a 32-bit counter, it is completely
unnecessary to use the prescaler - and using the prescaler will result
in loss of fine-grained timing accuracy.  Making use of the prescaler
there is absurd - the timer will run to 4000 odd seconds before wrapping
with a prescaler of 1.

You end up needing 64-bit arithmetic if you try to apply the Integrator/AP
logic to SP804 - it becomes this:

 	if (rate > 0x1000000000 * HZ) {
 		rate /= 256;
 		ctrl |= TIMER_CTRL_DIV256;
 	} else if (rate > 0x100000000 * HZ) {
 		rate /= 16;
 		ctrl |= TIMER_CTRL_DIV16;
 	}

or more precisely:
	if (rate > HZ * 0x100 * ((unsigned long long)wrap + 1)) {
...
 	} else if (rate > HZ * 0x10 * ((unsigned long long)wrap + 1)) {
...

You need that wrap value anyway for clockevents_config_and_register.

  reply	other threads:[~2013-03-15 12:15 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12 17:08 [PATCH v2 00/14] add hisilicon soc support Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 01/14] clocksource: move sp timer driver Haojian Zhuang
2013-03-12 18:11   ` Arnd Bergmann
2013-03-13  2:20     ` Haojian Zhuang
2013-03-12 19:08   ` Russell King - ARM Linux
2013-03-12 17:08 ` [PATCH v2 02/14] clocksource: sp804: add device tree support Haojian Zhuang
2013-03-12 18:14   ` Arnd Bergmann
2013-03-12 18:51   ` Arnd Bergmann
2013-03-12 18:53     ` Rob Herring
2013-03-12 17:08 ` [PATCH v2 03/14] clocksource: sp804: append CONFIG_OF Haojian Zhuang
2013-03-12 19:17   ` Arnd Bergmann
2013-03-13  3:25     ` Haojian Zhuang
2013-03-14 13:48       ` Arnd Bergmann
2013-03-12 17:08 ` [PATCH v2 04/14] ARM: highbank: use clocksource_of_init for sp804 Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 05/14] ARM: integrator: " Haojian Zhuang
2013-03-12 18:54   ` Arnd Bergmann
2013-03-13  2:00     ` Haojian Zhuang
2013-03-13  5:25     ` Linus Walleij
2013-03-12 19:15   ` Rob Herring
2013-03-12 19:33     ` Arnd Bergmann
2013-03-12 20:52       ` Rob Herring
2013-03-13  2:04         ` Haojian Zhuang
2013-03-13  6:41           ` Linus Walleij
2013-03-13  7:09             ` Haojian Zhuang
2013-03-13  8:43               ` Arnd Bergmann
2013-03-13  9:00               ` Linus Walleij
2013-03-15 12:15                 ` Russell King - ARM Linux [this message]
2013-03-15 13:59                   ` Linus Walleij
2013-03-13 13:56             ` Rob Herring
2013-03-13  9:03       ` Linus Walleij
2013-03-15 11:54     ` Russell King - ARM Linux
2013-03-13  6:35   ` Linus Walleij
2013-03-12 17:08 ` [PATCH v2 06/14] ARM: vexpress: " Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 07/14] ARM: debug: support debug ll on hisilicon soc Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 08/14] clk: hs: add clock support Haojian Zhuang
2013-03-12 19:00   ` Arnd Bergmann
2013-03-13  4:08     ` Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 09/14] ARM: hs: add board support with device tree Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 10/14] ARM: hs: enable hi4511 " Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 11/14] ARM: config: append arch hs into multi defconfig Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 12/14] Document: append hisilicon clock binding Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 13/14] Document: dts: create hisilicon document Haojian Zhuang
2013-03-12 17:08 ` [PATCH v2 14/14] Document: add device tree binding file for sp804 Haojian Zhuang
2013-03-12 19:02   ` Arnd Bergmann
2013-03-13  1:45     ` Haojian Zhuang

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=20130315121554.GH4977@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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).