[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/46] aspeed/timer: Fix match calculations
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 17/46] aspeed/timer: Fix match calculations |
Date: |
Mon, 1 Jul 2019 17:39:14 +0100 |
From: Andrew Jeffery <address@hidden>
If the match value exceeds reload then we don't want to include it in
calculations for the next event.
Signed-off-by: Andrew Jeffery <address@hidden>
Signed-off-by: Cédric Le Goater <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
hw/timer/aspeed_timer.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
index 8d6266b0fd8..745eb8608b5 100644
--- a/hw/timer/aspeed_timer.c
+++ b/hw/timer/aspeed_timer.c
@@ -107,6 +107,11 @@ static inline uint64_t calculate_time(struct AspeedTimer
*t, uint32_t ticks)
return t->start + delta_ns;
}
+static inline uint32_t calculate_match(struct AspeedTimer *t, int i)
+{
+ return t->match[i] < t->reload ? t->match[i] : 0;
+}
+
static uint64_t calculate_next(struct AspeedTimer *t)
{
uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
@@ -118,12 +123,12 @@ static uint64_t calculate_next(struct AspeedTimer *t)
* the timer counts down to zero.
*/
- next = calculate_time(t, MAX(t->match[0], t->match[1]));
+ next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t,
1)));
if (now < next) {
return next;
}
- next = calculate_time(t, MIN(t->match[0], t->match[1]));
+ next = calculate_time(t, MIN(calculate_match(t, 0), calculate_match(t,
1)));
if (now < next) {
return next;
}
@@ -141,8 +146,10 @@ static uint64_t calculate_next(struct AspeedTimer *t)
qemu_set_irq(t->irq, t->level);
}
+ next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0));
+
+ return calculate_time(t, next);
}
static void aspeed_timer_mod(AspeedTimer *t)
--
2.20.1
- [Qemu-devel] [PULL 00/46] target-arm queue, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 16/46] aspeed/timer: Status register contains reload for stopped timer, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 39/46] target/arm: Move TLB related routines to tlb_helper.c, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 30/46] target/arm: Makefile cleanup (KVM), Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 26/46] hw/arm: Add arm SBSA reference machine, skeleton part, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 14/46] aspeed: add support for multiple NICs, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 01/46] hw/arm/boot: fix direct kernel boot with initrd, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 34/46] target/arm: Fix multiline comment syntax, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 08/46] i.mx7d: pci: Update PCI IRQ mapping to match HW, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 45/46] target/arm: Declare arm_log_exception() function publicly, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 17/46] aspeed/timer: Fix match calculations,
Peter Maydell <=
- [Qemu-devel] [PULL 22/46] aspeed: Add support for the swift-bmc board, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 28/46] target/arm: Makefile cleanup (Aarch64), Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 09/46] aspeed: add a per SoC mapping for the interrupt space, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 27/46] hw/arm: Add arm SBSA reference machine, devices part, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 44/46] target/arm: Restrict PSCI to TCG, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 32/46] target/arm: Add copyright boilerplate, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 19/46] aspeed: remove the "ram" link, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 20/46] aspeed: add a RAM memory region container, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 46/46] target/arm: Declare some M-profile functions publicly, Peter Maydell, 2019/07/01
- [Qemu-devel] [PULL 24/46] aspeed: vic: Add support for legacy register interface, Peter Maydell, 2019/07/01