qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [kvm-unit-tests PATCH 2/2] arm64: timer: Add TVAL timeout I


From: Andre Przywara
Subject: [Qemu-devel] [kvm-unit-tests PATCH 2/2] arm64: timer: Add TVAL timeout IRQ trigger test
Date: Mon, 16 Jul 2018 16:14:38 +0100

So far we were only testing the CVAL register. Add a test which programs
a (relative) TVAL value to check this functionality as well.
Also we go into WFI and wait for the interrupt to release us from it.
The timer tests are run with a 2 second timeout on the host side, so
that any failure in coming back would be covered.

Signed-off-by: Andre Przywara <address@hidden>
---
 arm/timer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arm/timer.c b/arm/timer.c
index 1c9ef44..275d049 100644
--- a/arm/timer.c
+++ b/arm/timer.c
@@ -211,6 +211,7 @@ static void test_timer(struct timer_info *info)
        u64 now = info->read_counter();
        u64 time_10s = read_sysreg(cntfrq_el0) * 10;
        u64 later = now + time_10s;
+       s32 left;
 
        /* We don't want the irq handler to fire because that will change the
         * timer state and we want to test the timer output signal.  We can
@@ -236,6 +237,15 @@ static void test_timer(struct timer_info *info)
 
        /* Disable the timer again */
        info->write_ctl(0);
+
+       /* Test TVAL and IRQ trigger */
+       info->irq_received = false;
+       info->write_tval(read_sysreg(cntfrq_el0) / 100);        /* 10 ms */
+       info->write_ctl(ARCH_TIMER_CTL_ENABLE);
+       wfi();
+       left = info->read_tval();
+       report("interrupt received after TVAL/WFI", info->irq_received);
+       report("timer has expired (%d)", left < 0, left);
 }
 
 static void test_vtimer(void)
-- 
2.14.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]