[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/68] hw/timer/cmsdk-apb-timer.c: Switch to transaction-based pti
From: |
Peter Maydell |
Subject: |
[PULL 12/68] hw/timer/cmsdk-apb-timer.c: Switch to transaction-based ptimer API |
Date: |
Mon, 14 Oct 2019 17:03:08 +0100 |
Switch the cmsdk-apb-timer 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/cmsdk-apb-timer.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
index c9ce9770cef..40728e85e20 100644
--- a/hw/timer/cmsdk-apb-timer.c
+++ b/hw/timer/cmsdk-apb-timer.c
@@ -29,7 +29,6 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
-#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "qapi/error.h"
#include "trace.h"
@@ -121,14 +120,17 @@ static void cmsdk_apb_timer_write(void *opaque, hwaddr
offset, uint64_t value,
"CMSDK APB timer: EXTIN input not supported\n");
}
s->ctrl = value & 0xf;
+ ptimer_transaction_begin(s->timer);
if (s->ctrl & R_CTRL_EN_MASK) {
ptimer_run(s->timer, ptimer_get_limit(s->timer) == 0);
} else {
ptimer_stop(s->timer);
}
+ ptimer_transaction_commit(s->timer);
break;
case A_RELOAD:
/* Writing to reload also sets the current timer value */
+ ptimer_transaction_begin(s->timer);
if (!value) {
ptimer_stop(s->timer);
}
@@ -140,8 +142,10 @@ static void cmsdk_apb_timer_write(void *opaque, hwaddr
offset, uint64_t value,
*/
ptimer_run(s->timer, 0);
}
+ ptimer_transaction_commit(s->timer);
break;
case A_VALUE:
+ ptimer_transaction_begin(s->timer);
if (!value && !ptimer_get_limit(s->timer)) {
ptimer_stop(s->timer);
}
@@ -149,6 +153,7 @@ static void cmsdk_apb_timer_write(void *opaque, hwaddr
offset, uint64_t value,
if (value && (s->ctrl & R_CTRL_EN_MASK)) {
ptimer_run(s->timer, ptimer_get_limit(s->timer) == 0);
}
+ ptimer_transaction_commit(s->timer);
break;
case A_INTSTATUS:
/* Just one bit, which is W1C. */
@@ -191,9 +196,11 @@ static void cmsdk_apb_timer_reset(DeviceState *dev)
trace_cmsdk_apb_timer_reset();
s->ctrl = 0;
s->intstatus = 0;
+ ptimer_transaction_begin(s->timer);
ptimer_stop(s->timer);
/* Set the limit and the count */
ptimer_set_limit(s->timer, 0, 1);
+ ptimer_transaction_commit(s->timer);
}
static void cmsdk_apb_timer_init(Object *obj)
@@ -210,21 +217,21 @@ static void cmsdk_apb_timer_init(Object *obj)
static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
{
CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
- QEMUBH *bh;
if (s->pclk_frq == 0) {
error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
return;
}
- bh = qemu_bh_new(cmsdk_apb_timer_tick, s);
- s->timer = ptimer_init_with_bh(bh,
+ s->timer = ptimer_init(cmsdk_apb_timer_tick, s,
PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD |
PTIMER_POLICY_TRIGGER_ONLY_ON_DECREMENT |
PTIMER_POLICY_NO_IMMEDIATE_RELOAD |
PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
+ ptimer_transaction_begin(s->timer);
ptimer_set_freq(s->timer, s->pclk_frq);
+ ptimer_transaction_commit(s->timer);
}
static const VMStateDescription cmsdk_apb_timer_vmstate = {
--
2.20.1
- [PULL 03/68] ARM: KVM: Check KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 for smp_cpus > 256, (continued)
- [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, 2019/10/14
- [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 <=
- [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
- [PULL 21/68] hw/timer/imx_gpt.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14
- [PULL 22/68] hw/timer/mss-timerc: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/14