2012/2/12 Paul Brook <p...@codesourcery.com>

> > +static void cadence_timer_sync(CadenceTimerState *s)
> > +{
> >...
> > +    r = (int64_t)cadence_timer_get_steps(s, s->cpu_time - old_time);
> > +    x = (int64_t)s->reg_value + ((s->reg_count & COUNTER_CTRL_DEC) ? -r
> :
> > r); +
> > +    for (i = 0; i < 3; ++i) {
> > +        if (is_between((int64_t)s->reg_match[i] << 16, s->reg_value,
> x)) {
> > +            s->reg_intr |= (2 << i);
> > +        }
> > +    }
>
> By my reading this will miss events if they happen after the timer wraps.
> e.g. for a count-up timer with reg_match==1 and the tick callback happens
> to
> get delayed by 4 cycles, the timer may wrap straight to reg_value = 3.
>
> Paul
>

Yeh, good catch. Will change to something like this on the next revision:

    for (i = 0; i < 3; ++i) {
             int64_t m =  (int64_t)s->reg_match[i] << 16;
             if (is_between(m, s->reg_value, x) ||
                is_between(m+interval, s->reg_value, x) ||
                is_between(m-interval, s->reg_value, x)
             ) {
                  s->reg_intr |= (2 << i);
             }
    }

Any other thoughts or comments on this series?

Reply via email to