[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 19/21] hw/timer/mss-timerc: Switch to transaction-based ptimer
From: |
Peter Maydell |
Subject: |
[PATCH v2 19/21] hw/timer/mss-timerc: Switch to transaction-based ptimer API |
Date: |
Tue, 8 Oct 2019 18:17:38 +0100 |
Switch the mss-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>
---
include/hw/timer/mss-timer.h | 1 -
hw/timer/mss-timer.c | 11 ++++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/include/hw/timer/mss-timer.h b/include/hw/timer/mss-timer.h
index d15d1732f81..e5a784b27e4 100644
--- a/include/hw/timer/mss-timer.h
+++ b/include/hw/timer/mss-timer.h
@@ -46,7 +46,6 @@
#define R_TIM1_MAX 6
struct Msf2Timer {
- QEMUBH *bh;
ptimer_state *ptimer;
uint32_t regs[R_TIM1_MAX];
diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c
index a34c2402b00..b1c9a805011 100644
--- a/hw/timer/mss-timer.c
+++ b/hw/timer/mss-timer.c
@@ -24,7 +24,6 @@
*/
#include "qemu/osdep.h"
-#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "qemu/log.h"
#include "hw/irq.h"
@@ -67,6 +66,7 @@ static void timer_update_irq(struct Msf2Timer *st)
qemu_set_irq(st->irq, (ier && isr));
}
+/* Must be called from within a ptimer_transaction_begin/commit block */
static void timer_update(struct Msf2Timer *st)
{
uint64_t count;
@@ -159,7 +159,9 @@ timer_write(void *opaque, hwaddr offset,
switch (addr) {
case R_TIM_CTRL:
st->regs[R_TIM_CTRL] = value;
+ ptimer_transaction_begin(st->ptimer);
timer_update(st);
+ ptimer_transaction_commit(st->ptimer);
break;
case R_TIM_RIS:
@@ -171,7 +173,9 @@ timer_write(void *opaque, hwaddr offset,
case R_TIM_LOADVAL:
st->regs[R_TIM_LOADVAL] = value;
if (st->regs[R_TIM_CTRL] & TIMER_CTRL_ENBL) {
+ ptimer_transaction_begin(st->ptimer);
timer_update(st);
+ ptimer_transaction_commit(st->ptimer);
}
break;
@@ -228,9 +232,10 @@ static void mss_timer_init(Object *obj)
for (i = 0; i < NUM_TIMERS; i++) {
struct Msf2Timer *st = &t->timers[i];
- st->bh = qemu_bh_new(timer_hit, st);
- st->ptimer = ptimer_init_with_bh(st->bh, PTIMER_POLICY_DEFAULT);
+ st->ptimer = ptimer_init(timer_hit, st, PTIMER_POLICY_DEFAULT);
+ ptimer_transaction_begin(st->ptimer);
ptimer_set_freq(st->ptimer, t->freq_hz);
+ ptimer_transaction_commit(st->ptimer);
sysbus_init_irq(SYS_BUS_DEVICE(obj), &st->irq);
}
--
2.20.1
- [PATCH v2 09/21] hw/timer/cmsdk-apb-timer.c: Switch to transaction-based ptimer API, (continued)
- [PATCH v2 09/21] hw/timer/cmsdk-apb-timer.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/08
- [PATCH v2 07/21] hw/timer/arm_mptimer.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/08
- [PATCH v2 10/21] hw/timer/digic-timer.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/08
- [PATCH v2 12/21] hw/timer/exynos4210_mct.c: Switch LFRC to transaction-based ptimer API, Peter Maydell, 2019/10/08
- [PATCH v2 14/21] hw/timer/exynos4210_pwm.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/08
- [PATCH v2 19/21] hw/timer/mss-timerc: Switch to transaction-based ptimer API,
Peter Maydell <=
- [PATCH v2 16/21] hw/timer/exynos4210_rtc.c: Switch main ptimer to transaction-based API, Peter Maydell, 2019/10/08
- [PATCH v2 17/21] hw/timer/imx_epit.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/08
- [PATCH v2 18/21] hw/timer/imx_gpt.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/08
- [PATCH v2 21/21] hw/net/lan9118.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/08
- [PATCH v2 20/21] hw/watchdog/cmsdk-apb-watchdog.c: Switch to transaction-based ptimer API, Peter Maydell, 2019/10/08