On 03/19/2013 02:55:58 AM, Wang Dongsheng-B40534 wrote:
> > +static void convert_ticks_to_time(struct timer_group_priv *priv,
> > + const u64 ticks, struct timeval *time) {
> > + u64 tmp_sec;
> > + u32 rem_us;
> > + u32 div;
> > +
> > + if (!(priv->flags & FSL_GLOBAL_TIMER)) {
> > + time->tv_sec = (__kernel_time_t)
> > + div_u64_rem(ticks, priv->timerfreq, &rem_us);
> > + tmp_sec = (u64)time->tv_sec * (u64)priv->timerfreq;
> > + time->tv_usec = (__kernel_suseconds_t)
> > + div_u64((ticks - tmp_sec) * 1000000,
> > priv->timerfreq);
> > +
> > + return;
> > + }
> > +
> > + div = (1 << (MPIC_TIMER_TCR_CLKDIV_64 >> 8)) * 8;
> > +
> > + time->tv_sec = (__kernel_time_t)div_u64(ticks, priv->timerfreq
> > / div);
> > + tmp_sec = div_u64((u64)time->tv_sec * (u64)priv->timerfreq,
> > div);
> > +
> > + time->tv_usec = (__kernel_suseconds_t)
> > + div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq /
> > div);
> > +
> > + return;
>
> Why don't you just adjust the clock frequency up front for
CLKDIV_64,
> rather than introduce alternate (and untested!) code paths
throughout the
> driver?
>
No, It cannot be integrated. The div cannot be removed.
Because if do priv->timerfreq /= div, that will affect the accuracy.
Like:
3 * 5 / 2 = 7;
3 / 2 * 5 = 5;
I don't follow -- a change in the clock speed is a change in the clock
speed, no matter how you accomplish it.
How you round is a different question. You should probably be rounding
up always, based on the final clock frequency -- though it's unlikely
to matter much given the high precision of the timer relative to the
input granularity.
BTW
if (!(priv->flags & FSL_GLOBAL_TIMER)) {
time->tv_sec = (__kernel_time_t)
div_u64_rem(ticks, priv->timerfreq, &rem_us);
tmp_sec = (u64)time->tv_sec * (u64)priv->timerfreq;
time->tv_usec = (__kernel_suseconds_t)
div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq);
return;
}
This branch I has been tested.
Test methods:
1. Get timerfreq and set timerfreq.
timerfreq /= 64;(Clock ratio is divide by 64)
2. Clear FSL_GLOBAL_TIMER flag.
Even if it was tested once, it's unlikely to continue to be tested
without a user.
-Scott
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev