Skip to content

Commit 8016690

Browse files
rananta468Marc Zyngier
authored andcommitted
KVM: arm64: selftests: Add basic support to generate delays
Add udelay() support to generate a delay in the guest. The routines are derived and simplified from kernel's arch/arm64/lib/delay.c. Signed-off-by: Raghavendra Rao Ananta <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d977ed3 commit 8016690

File tree

1 file changed

+25
-0
lines changed
  • tools/testing/selftests/kvm/include/aarch64

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* ARM simple delay routines
4+
*/
5+
6+
#ifndef SELFTEST_KVM_ARM_DELAY_H
7+
#define SELFTEST_KVM_ARM_DELAY_H
8+
9+
#include "arch_timer.h"
10+
11+
static inline void __delay(uint64_t cycles)
12+
{
13+
enum arch_timer timer = VIRTUAL;
14+
uint64_t start = timer_get_cntct(timer);
15+
16+
while ((timer_get_cntct(timer) - start) < cycles)
17+
cpu_relax();
18+
}
19+
20+
static inline void udelay(unsigned long usec)
21+
{
22+
__delay(usec_to_cycles(usec));
23+
}
24+
25+
#endif /* SELFTEST_KVM_ARM_DELAY_H */

0 commit comments

Comments
 (0)