[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v16 05/16] hw/ptimer: Add "wraparound after one
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH v16 05/16] hw/ptimer: Add "wraparound after one period" policy |
Date: |
Tue, 20 Sep 2016 18:20:44 +0100 |
On 7 September 2016 at 14:22, Dmitry Osipenko <address@hidden> wrote:
> Currently, periodic counter wraps around immediately once counter reaches
> "0", this is wrong behaviour for some of the timers, resulting in one period
> being lost. Add new ptimer policy that provides correct behaviour for such
> timers, so that counter stays with "0" for a one period before wrapping
> around.
This says it's just adding a new policy...
> @@ -91,7 +96,7 @@ uint64_t ptimer_get_count(ptimer_state *s)
> {
> uint64_t counter;
>
> - if (s->enabled) {
> + if (s->enabled && s->delta != 0) {
> int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
> int64_t next = s->next_event;
> bool expired = (now - next >= 0);
> @@ -145,6 +150,14 @@ uint64_t ptimer_get_count(ptimer_state *s)
> div += 1;
> }
> counter = rem / div;
> +
> + if (!oneshot && s->delta == s->limit) {
> + /* Before wrapping around, timer should stay with counter = 0
> + for a one period. The delta has been adjusted by +1 for
> + the wrapped around counter, so taking a modulo of limit +
> 1
> + gives that period. */
> + counter %= s->limit + 1;
> + }
> }
> } else {
> counter = s->delta;
...but the changes in this function look like they affect
behaviour even if that policy flag isn't set.
thanks
-- PMM
[Qemu-devel] [PATCH v16 05/16] hw/ptimer: Add "wraparound after one period" policy, Dmitry Osipenko, 2016/09/07
- Re: [Qemu-devel] [PATCH v16 05/16] hw/ptimer: Add "wraparound after one period" policy,
Peter Maydell <=
[Qemu-devel] [PATCH v16 10/16] tests: ptimer: Add tests for "no immediate trigger" policy, Dmitry Osipenko, 2016/09/07
[Qemu-devel] [PATCH v16 02/16] hw/ptimer: Introduce timer policy feature, Dmitry Osipenko, 2016/09/07
[Qemu-devel] [PATCH v16 08/16] tests: ptimer: Add tests for "continuous trigger" policy, Dmitry Osipenko, 2016/09/07
[Qemu-devel] [PATCH v16 07/16] hw/ptimer: Add "continuous trigger" policy, Dmitry Osipenko, 2016/09/07
[Qemu-devel] [PATCH v16 06/16] tests: ptimer: Add tests for "wraparound after one period" policy, Dmitry Osipenko, 2016/09/07
[Qemu-devel] [PATCH v16 09/16] hw/ptimer: Add "no immediate trigger" policy, Dmitry Osipenko, 2016/09/07
[Qemu-devel] [PATCH v16 12/16] tests: ptimer: Add tests for "no immediate reload" policy, Dmitry Osipenko, 2016/09/07