]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[arm] Use CNTVCT_EL0 as profiling timestamp
authorMichael Brown <mcb30@ipxe.org>
Wed, 11 May 2016 20:44:23 +0000 (21:44 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 12 May 2016 10:16:41 +0000 (11:16 +0100)
The raw cycle counter at PMCCNTR_EL0 works in qemu but seems to always
read as zero on physical hardware (tested on Juno r1 and Cavium
ThunderX), even after ensuring that PMCR_EL0.E and PMCNTENSET_EL0.C
are both enabled.

Use CNTVCT_EL0 instead; this seems to count at a lower resolution
(tens of CPU cycles), but is usable for profiling.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/arm64/include/bits/profile.h

index cad02ea4b7c22981bfed7ac564f52c8bbf941893..62ffa3772580a689a71f52c274bd3071ead92846 100644 (file)
@@ -21,9 +21,7 @@ profile_timestamp ( void ) {
        uint64_t cycles;
 
        /* Read cycle counter */
-       __asm__ __volatile__ ( "msr PMCR_EL0, %1\n\t"
-                              "mrs %0, PMCCNTR_EL0\n\t"
-                              : "=r" ( cycles ) : "r" ( 1 ) );
+       __asm__ __volatile__ ( "mrs %0, CNTVCT_EL0\n\t" : "=r" ( cycles ) );
        return cycles;
 }