Add aarch64 cpu clock support
authorJens Axboe <axboe@kernel.dk>
Fri, 11 Feb 2022 13:58:12 +0000 (06:58 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 11 Feb 2022 13:58:12 +0000 (06:58 -0700)
We can use cntvct_el0 to read the CPU clock.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
arch/arch-aarch64.h

index 2a86cc5ab4d9b9cb1bef2dcf5d0aab24bfc38fb8..94571709eb2756d41a921f981b669ae27ee7b1ae 100644 (file)
@@ -27,4 +27,21 @@ static inline int arch_ffz(unsigned long bitmask)
 
 #define ARCH_HAVE_FFZ
 
+static inline unsigned long long get_cpu_clock(void)
+{
+       unsigned long val;
+
+       asm volatile("mrs %0, cntvct_el0" : "=r" (val));
+       return val;
+}
+#define ARCH_HAVE_CPU_CLOCK
+
+#define ARCH_HAVE_INIT
+extern bool tsc_reliable;
+static inline int arch_init(char *envp[])
+{
+       tsc_reliable = true;
+       return 0;
+}
+
 #endif