Subject: Re: [PATCH 3/6] powerpc/time: Use clocksource_register_hz

From: john stultz <[email-masked]>
Date: Mon, 28 Nov 2011 15:30:53 -0800

On Thu, 2011-11-24 at 17:07 +1100, Anton Blanchard wrote:
> plain text document attachment (clock3)
> Use clocksource_register_hz which calculates the shift/mult
> factors for us. Also remove the shift = 22 assumption in
> vsyscall_update - thanks to Paul Mackerras and John Stultz for
> catching that.
> 
> Signed-off-by: Anton Blanchard <[email-masked]>
> ---
> 
> Index: linux-build/arch/powerpc/kernel/time.c
> ===================================================================
> --- linux-build.orig/arch/powerpc/kernel/time.c	2011-11-17 10:11:51.175038860 +1100
> +++ linux-build/arch/powerpc/kernel/time.c	2011-11-17 10:11:55.547114957 +1100
> @@ -86,8 +86,6 @@ static struct clocksource clocksource_rt
>  	.rating       = 400,
>  	.flags        = CLOCK_SOURCE_IS_CONTINUOUS,
>  	.mask         = CLOCKSOURCE_MASK(64),
> -	.shift        = 22,
> -	.mult         = 0,	/* To be filled in */
>  	.read         = rtc_read,
>  };
> 
> @@ -97,8 +95,6 @@ static struct clocksource clocksource_ti
>  	.rating       = 400,
>  	.flags        = CLOCK_SOURCE_IS_CONTINUOUS,
>  	.mask         = CLOCKSOURCE_MASK(64),
> -	.shift        = 22,
> -	.mult         = 0,	/* To be filled in */
>  	.read         = timebase_read,
>  };
> 
> @@ -822,9 +818,8 @@ void update_vsyscall(struct timespec *wa
>  	++vdso_data->tb_update_count;
>  	smp_mb();
> 
> -	/* XXX this assumes clock->shift == 22 */
> -	/* 4611686018 ~= 2^(20+64-22) / 1e9 */
> -	new_tb_to_xs = (u64) mult * 4611686018ULL;
> +	/* 19342813113834067 ~= 2^(20+64) / 1e9 */
> +	new_tb_to_xs = (u64) mult * (19342813113834067ULL >> clock->shift);

I never verified the math on this, but assuming Paul had it right, this
patch looks good!

Acked-by: John Stultz <[email-masked]>

Thanks again!
-john