[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/68] hw/timer/arm_mptimer.c: Switch to transaction-based ptimer
From: |
Peter Maydell |
Subject: |
[PULL 10/68] hw/timer/arm_mptimer.c: Switch to transaction-based ptimer API |
Date: |
Mon, 14 Oct 2019 17:03:06 +0100 |
Switch the arm_mptimer.c code away from bottom-half based ptimers to
the new transaction-based ptimer API. This just requires adding
begin/commit calls around the various places that modify the ptimer
state, and using the new ptimer_init() function to create the timer.
Signed-off-by: Peter Maydell <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Message-id: address@hidden
---
hw/timer/arm_mptimer.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
index 2a54a011431..fdf97d1800f 100644
--- a/hw/timer/arm_mptimer.c
+++ b/hw/timer/arm_mptimer.c
@@ -27,7 +27,6 @@
#include "hw/timer/arm_mptimer.h"
#include "migration/vmstate.h"
#include "qapi/error.h"
-#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "hw/core/cpu.h"
@@ -65,6 +64,7 @@ static inline uint32_t timerblock_scale(uint32_t control)
return (((control >> 8) & 0xff) + 1) * 10;
}
+/* Must be called within a ptimer transaction block */
static inline void timerblock_set_count(struct ptimer_state *timer,
uint32_t control, uint64_t *count)
{
@@ -77,6 +77,7 @@ static inline void timerblock_set_count(struct ptimer_state
*timer,
ptimer_set_count(timer, *count);
}
+/* Must be called within a ptimer transaction block */
static inline void timerblock_run(struct ptimer_state *timer,
uint32_t control, uint32_t load)
{
@@ -124,6 +125,7 @@ static void timerblock_write(void *opaque, hwaddr addr,
uint32_t control = tb->control;
switch (addr) {
case 0: /* Load */
+ ptimer_transaction_begin(tb->timer);
/* Setting load to 0 stops the timer without doing the tick if
* prescaler = 0.
*/
@@ -132,8 +134,10 @@ static void timerblock_write(void *opaque, hwaddr addr,
}
ptimer_set_limit(tb->timer, value, 1);
timerblock_run(tb->timer, control, value);
+ ptimer_transaction_commit(tb->timer);
break;
case 4: /* Counter. */
+ ptimer_transaction_begin(tb->timer);
/* Setting counter to 0 stops the one-shot timer, or periodic with
* load = 0, without doing the tick if prescaler = 0.
*/
@@ -143,8 +147,10 @@ static void timerblock_write(void *opaque, hwaddr addr,
}
timerblock_set_count(tb->timer, control, &value);
timerblock_run(tb->timer, control, value);
+ ptimer_transaction_commit(tb->timer);
break;
case 8: /* Control. */
+ ptimer_transaction_begin(tb->timer);
if ((control & 3) != (value & 3)) {
ptimer_stop(tb->timer);
}
@@ -160,6 +166,7 @@ static void timerblock_write(void *opaque, hwaddr addr,
timerblock_run(tb->timer, value, count);
}
tb->control = value;
+ ptimer_transaction_commit(tb->timer);
break;
case 12: /* Interrupt status. */
tb->status &= ~value;
@@ -212,9 +219,11 @@ static void timerblock_reset(TimerBlock *tb)
tb->control = 0;
tb->status = 0;
if (tb->timer) {
+ ptimer_transaction_begin(tb->timer);
ptimer_stop(tb->timer);
ptimer_set_limit(tb->timer, 0, 1);
ptimer_set_period(tb->timer, timerblock_scale(0));
+ ptimer_transaction_commit(tb->timer);
}
}
@@ -260,8 +269,7 @@ static void arm_mptimer_realize(DeviceState *dev, Error
**errp)
*/
for (i = 0; i < s->num_cpu; i++) {
TimerBlock *tb = &s->timerblock[i];
- QEMUBH *bh = qemu_bh_new(timerblock_tick, tb);
- tb->timer = ptimer_init_with_bh(bh, PTIMER_POLICY);
+ tb->timer = ptimer_init(timerblock_tick, tb, PTIMER_POLICY);
sysbus_init_irq(sbd, &tb->irq);
memory_region_init_io(&tb->iomem, OBJECT(s), &timerblock_ops, tb,
"arm_mptimer_timerblock", 0x20);
--
2.20.1
- [PULL 00/68] target-arm queue, Peter Maydell, 2019/10/14
- [PULL 02/68] intc/arm_gic: Support IRQ injection for more than 256 vpus, Peter Maydell, 2019/10/14
- [PULL 03/68] ARM: KVM: Check KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 for smp_cpus > 256, Peter Maydell, 2019/10/14
- [PULL 01/68] linux headers: update against v5.4-rc1, Peter Maydell, 2019/10/14
- [PULL 04/68] ptimer: Rename ptimer_init() to ptimer_init_with_bh(), Peter Maydell, 2019/10/14
- [PULL 05/68] ptimer: Provide new transaction-based API, Peter Maydell, 2019/10/14
- [PULL 07/68] hw/timer/arm_timer.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 06/68] tests/ptimer-test: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 08/68] hw/arm/musicpal.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 09/68] hw/timer/allwinner-a10-pit.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 10/68] hw/timer/arm_mptimer.c: Switch to transaction-based ptimer API,
Peter Maydell <=
- [PULL 11/68] hw/timer/cmsdk-apb-dualtimer.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 12/68] hw/timer/cmsdk-apb-timer.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 13/68] hw/timer/digic-timer.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 15/68] hw/timer/exynos4210_mct.c: Switch LFRC to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 16/68] hw/timer/exynos4210_mct.c: Switch ltick to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 14/68] hw/timer/exynos4210_mct.c: Switch GFRC to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 17/68] hw/timer/exynos4210_pwm.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 18/68] hw/timer/exynos4210_rtc.c: Switch 1Hz ptimer to transaction-based API, Peter Maydell, 2019/10/14
- [PULL 19/68] hw/timer/exynos4210_rtc.c: Switch main ptimer to transaction-based API, Peter Maydell, 2019/10/14
- [PULL 20/68] hw/timer/imx_epit.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14