[PATCH] powerpc/mpic_timer: fix the time calculation is not accurate

Dongsheng.Wang at freescale.com Dongsheng.Wang at freescale.com
Mon Dec 30 13:21:51 EST 2013



> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Saturday, December 28, 2013 8:00 AM
> To: Wang Dongsheng-B40534
> Cc: galak at kernel.crashing.org; linuxppc-dev at lists.ozlabs.org
> Subject: Re: [PATCH] powerpc/mpic_timer: fix the time calculation is not
> accurate
> 
> On Mon, 2013-12-23 at 10:33 +0800, Dongsheng Wang wrote:
> > From: Wang Dongsheng <dongsheng.wang at freescale.com>
> >
> > When the timer GTCCR toggle bit is inverted, we calculated the rest of
> > the time is not accurate. So we need to ignore this bit.
> >
> > Signed-off-by: Wang Dongsheng <dongsheng.wang at freescale.com>
> >
> > diff --git a/arch/powerpc/sysdev/mpic_timer.c
> > b/arch/powerpc/sysdev/mpic_timer.c
> > index 22d7d57..0fb70c9 100644
> > --- a/arch/powerpc/sysdev/mpic_timer.c
> > +++ b/arch/powerpc/sysdev/mpic_timer.c
> > @@ -41,6 +41,7 @@
> >  #define MPIC_TIMER_TCR_ROVR_OFFSET	24
> >
> >  #define TIMER_STOP			0x80000000
> > +#define GTCCR_TOG			0x80000000
> >  #define TIMERS_PER_GROUP		4
> >  #define MAX_TICKS			(~0U >> 1)
> >  #define MAX_TICKS_CASCADE		(~0U)
> > @@ -96,8 +97,15 @@ static void convert_ticks_to_time(struct timer_group_priv
> *priv,
> >  	time->tv_sec = (__kernel_time_t)div_u64(ticks, priv->timerfreq);
> >  	tmp_sec = (u64)time->tv_sec * (u64)priv->timerfreq;
> >
> > -	time->tv_usec = (__kernel_suseconds_t)
> > -		div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq);
> > +	time->tv_usec = 0;
> > +
> > +	/*
> > +	 * In some cases tmp_sec may be greater than ticks, because in the
> > +	 * process of calculation ticks and tmp_sec will be rounded.
> > +	 */
> > +	if (tmp_sec <= ticks)
> > +		time->tv_usec = (__kernel_suseconds_t)
> > +			div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq);
> 
> I don't see how this part of the patch relates to the patch description.
> 
Thanks, I miss this description, :(.
I should split the patch.

-Dongsheng

> -Scott
> 



More information about the Linuxppc-dev mailing list