[PATCH kvm-unit-tests 2/3] arm64: timer: Fix test on APM X-Gene

Christoffer Dall
2017-07-13T19:19:44Z

When running the vtimer test on an APM X-Gene, setting the timer value
to (2^64 - 1) apparently results in the timer always firing, even
thought the counter is mich lower than the cval.

Since the idea of the code is to set everything up and schedule the
timer for some time very far in the future, take a pragmatic approach
and just add 10s worth of delay instead.

Signed-off-by: Christoffer Dall <cdall@linaro.org>
---
arm/timer.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arm/timer.c b/arm/timer.c
index 02d9e0a..77d257c 100644
--- a/arm/timer.c
+++ b/arm/timer.c
@@ -70,10 +70,14 @@ static bool test_cval_10msec(void)

static void test_vtimer(void)
{
+ u64 now = read_sysreg(cntvct_el0);
+ u64 time_10s = read_sysreg(cntfrq_el0) * 10;
+ u64 later = now + time_10s;
+
report_prefix_push("vtimer-busy-loop");

- /* Enable the timer */
- write_sysreg(~0, cntv_cval_el0);
+ /* Enable the timer, but schedule it for much later*/
+ write_sysreg(later, cntv_cval_el0);
isb();
write_sysreg(CNTV_CTL_ENABLE, cntv_ctl_el0);

--
2.9.0