diff options
author | Dmitry Osipenko <digetx@gmail.com> | 2016-10-24 16:26:52 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-10-24 16:26:52 +0100 |
commit | 5580ea4576b60a4fa615c85e254fab1401149b45 (patch) | |
tree | 3d7d4dbe2ed49179b0b6a3ea352925ade49ec480 /hw | |
parent | 56700e1aa6959c082a839285022fa4e48d5cf512 (diff) | |
download | qemu-5580ea4576b60a4fa615c85e254fab1401149b45.zip qemu-5580ea4576b60a4fa615c85e254fab1401149b45.tar.gz qemu-5580ea4576b60a4fa615c85e254fab1401149b45.tar.bz2 |
hw/ptimer: Add "no counter round down" policy
For most of the timers counter starts to decrement after first period
expires. Due to rounding down performed by the ptimer_get_count, it returns
counter - 1 for the running timer, so that for the ptimer user it looks
like counter gets decremented immediately after running the timer. Add "no
counter round down" policy that provides correct behaviour for those timers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Message-id: ef39622d0ebfdc32a0877e59ffdf6910dc3db688.1475421224.git.digetx@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/core/ptimer.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index 2a69daf..3af82af 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -231,6 +231,15 @@ uint64_t ptimer_get_count(ptimer_state *s) } } } + + if (s->policy_mask & PTIMER_POLICY_NO_COUNTER_ROUND_DOWN) { + /* If now == last then delta == limit, i.e. the counter already + represents the correct value. It would be rounded down a 1ns + later. */ + if (now != last) { + counter += 1; + } + } } else { counter = s->delta; } |