[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v17 09/14] hw/ptimer: Add "no counter round down" poli
From: |
Dmitry Osipenko |
Subject: |
[Qemu-arm] [PATCH v17 09/14] hw/ptimer: Add "no counter round down" policy |
Date: |
Sun, 2 Oct 2016 18:53:41 +0300 |
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 <address@hidden>
---
hw/core/ptimer.c | 9 +++++++++
include/hw/ptimer.h | 4 ++++
2 files changed, 13 insertions(+)
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;
}
diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h
index 5455340..48cccbd 100644
--- a/include/hw/ptimer.h
+++ b/include/hw/ptimer.h
@@ -51,6 +51,10 @@
* immediately, but after a one period. */
#define PTIMER_POLICY_NO_IMMEDIATE_RELOAD (1 << 3)
+/* Make counter value of the running timer represent the actual value and
+ * not the one less. */
+#define PTIMER_POLICY_NO_COUNTER_ROUND_DOWN (1 << 4)
+
/* ptimer.c */
typedef struct ptimer_state ptimer_state;
typedef void (*ptimer_cb)(void *opaque);
--
2.9.3
- [Qemu-arm] [PATCH v17 07/14] hw/ptimer: Add "no immediate reload" policy, (continued)
- [Qemu-arm] [PATCH v17 07/14] hw/ptimer: Add "no immediate reload" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 14/14] tests: Add tests for the ARM MPTimer, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 01/14] hw/ptimer: Add "wraparound after one period" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 04/14] tests: ptimer: Add tests for "continuous trigger" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 03/14] hw/ptimer: Add "continuous trigger" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 05/14] hw/ptimer: Add "no immediate trigger" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 08/14] tests: ptimer: Add tests for "no immediate reload" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 10/14] tests: ptimer: Add tests for "no counter round down" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 06/14] tests: ptimer: Add tests for "no immediate trigger" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 02/14] tests: ptimer: Add tests for "wraparound after one period" policy, Dmitry Osipenko, 2016/10/02
- [Qemu-arm] [PATCH v17 09/14] hw/ptimer: Add "no counter round down" policy,
Dmitry Osipenko <=
- Re: [Qemu-arm] [PATCH v17 00/14] PTimer fixes/features and ARM MPTimer conversion, Peter Maydell, 2016/10/24