diff mbox

[kvm-unit-tests,2/2] arm64: timer: Add TVAL timeout IRQ trigger test

Message ID 20180716151438.9877-3-andre.przywara@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andre Przywara July 16, 2018, 3:14 p.m. UTC
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 <andre.przywara@arm.com>
---
 arm/timer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Andrew Jones July 17, 2018, 10:53 a.m. UTC | #1
On Mon, Jul 16, 2018 at 04:14:38PM +0100, Andre Przywara wrote:
> 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 <andre.przywara@arm.com>
> ---
>  arm/timer.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>

Reviewed-by: Andrew Jones <drjones@redhat.com>
diff mbox

Patch

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)