mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] AVR32: Switch to generic timekeeping framework
Date: Tue, 08 Aug 2006 11:48:20 -0700	[thread overview]
Message-ID: <1155062900.13030.67.camel@cog.beaverton.ibm.com> (raw)
In-Reply-To: <11550448722406-git-send-email-hskinnemoen@atmel.com>

On Tue, 2006-08-08 at 15:47 +0200, Haavard Skinnemoen wrote:
> Define CONFIG_GENERIC_TIME and remove arch-specific versions of
> do_{get,set}timeofday(). Define and use a clocksource based on the
> AVR32 cycle counter.
> 
> Also clean up asm/timex.h a bit, including defining CLOCK_TICK_RATE
> to a "good cheat value" borrowed from MIPS instead of the i8254 value
> used by "everyone" else, which is really quite pointless on AVR32.
> 
> Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
> ---
>  arch/avr32/Kconfig        |    4 +
>  arch/avr32/kernel/time.c  |  172 +++++++++-------------------------------------
>  include/asm-avr32/timex.h |   26 ++++--
>  3 files changed, 59 insertions(+), 143 deletions(-)

Can't argue w/ a diffstat like that :)
Glad to see the code is working for you!


Acked-by: John Stultz <johnstul@us.ibm.com>


> @@ -286,22 +183,22 @@ void __init time_init(void)
>  	       (unsigned long)sysreg_read(COUNT),
>  	       (unsigned long)sysreg_read(COMPARE));
>  
> -	if (!avr32_hpt_frequency && boot_cpu_data.clk)
> -		avr32_hpt_frequency = clk_get_rate(boot_cpu_data.clk);
> -
> -	if (avr32_hpt_frequency) {
> -		cycles_per_jiffy = (avr32_hpt_frequency + HZ / 2) / HZ;
> +	count_hz = clk_get_rate(boot_cpu_data.clk);
> +	shift = clocksource_avr32.shift;
> +	mult = clocksource_hz2mult(count_hz, shift);
> +	clocksource_avr32.mult = mult;
> +
> +	printk("Cycle counter: mult=%lu, shift=%lu\n", mult, shift);
> +
> +	{
> +		u64 tmp;
> +
> +		tmp = TICK_NSEC;
> +		tmp <<= shift;
> +		tmp += mult / 2;
> +		do_div(tmp, mult);
>  
> -		/* 10^6 * 2^32 / avr32_hpt_frequency */
> -		{
> -			u64 tmp = 1000000ULL << 32;
> -			do_div(tmp, avr32_hpt_frequency);
> -			sll32_usecs_per_cycle = tmp;
> -		}
> -
> -		printk("Using %u.%03u MHz high precision timer.\n",
> -		       ((avr32_hpt_frequency + 500) / 1000) / 1000,
> -		       ((avr32_hpt_frequency + 500) / 1000) % 1000);
> +		cycles_per_jiffy = tmp;

That looks redundant to the calculate_interval code in timer.c and
points to a need for a generic nanosecond to cycles interface. I'll put
that on my TODO list.

> +/*
> + * This is the frequency of the timer used for Linux's timer interrupt.
> + * The value should be defined as accurate as possible or under certain
> + * circumstances Linux timekeeping might become inaccurate or fail.
> + *
> + * For many system the exact clockrate of the timer isn't known but due to
> + * the way this value is used we can get away with a wrong value as long
> + * as this value is:
> + *
> + *  - a multiple of HZ
> + *  - a divisor of the actual rate
> + *
> + * 500000 is a good such cheat value.
> + *
> + * The obscure number 1193182 is the same as used by the original i8254
> + * time in legacy PC hardware; the chip is never found in AVR32 systems.
> + */
> +#define CLOCK_TICK_RATE		500000	/* Underlying HZ */
>  

Hmm.. Hopefully the future NTP cleanup will remove the need for these
sorts of, uh.. tricks. :)

thanks
-john


      reply	other threads:[~2006-08-08 18:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-08 13:47 Haavard Skinnemoen
2006-08-08 18:48 ` john stultz [this message]

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=1155062900.13030.67.camel@cog.beaverton.ibm.com \
    --to=johnstul@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=hskinnemoen@atmel.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®