qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 2/4] cadence_ttc: initial version of device m


From: Peter Crosthwaite
Subject: Re: [Qemu-devel] [PATCH v3 2/4] cadence_ttc: initial version of device model
Date: Sun, 12 Feb 2012 10:00:02 +1000



2012/2/12 Paul Brook <address@hidden>
> +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

[Prev in Thread] Current Thread [Next in Thread]