Message ID | 20160726025625.7343-9-brian.brooks@linaro.org |
---|---|
State | New |
Headers | show |
On 07/26/16 05:56, Brian Brooks wrote: > Signed-off-by: Brian Brooks <brian.brooks@linaro.org> > --- > platform/linux-generic/arch/arm/odp_cpu_arch.c | 25 ++++++------------------- > 1 file changed, 6 insertions(+), 19 deletions(-) > > diff --git a/platform/linux-generic/arch/arm/odp_cpu_arch.c b/platform/linux-generic/arch/arm/odp_cpu_arch.c > index 109dd93..0ae3e0e 100644 > --- a/platform/linux-generic/arch/arm/odp_cpu_arch.c > +++ b/platform/linux-generic/arch/arm/odp_cpu_arch.c > @@ -14,25 +14,12 @@ > #include <odp/api/system_info.h> > #include <odp_debug_internal.h> > > -#define GIGA 1000000000 > - > uint64_t odp_cpu_cycles(void) > { > - struct timespec time; > - uint64_t sec, ns, hz, cycles; > - int ret; > - > - ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); > - > - if (ret != 0) > - ODP_ABORT("clock_gettime failed\n"); > - > - hz = odp_cpu_hz_max(); > - sec = (uint64_t)time.tv_sec; > - ns = (uint64_t)time.tv_nsec; > - > - cycles = sec * hz; > - cycles += (ns * hz) / GIGA; > - > - return cycles; > +#if defined(__aarch64__) > + uint64_t vct; > + __asm__ volatile("isb" : : : "memory"); > + __asm__ volatile("mrs %0, cntvct_el0" : "=r" (vct)); > + return vct; > +#endif here the same, no return code. Our compiler probably will catch it and trap compilation but it's better to take care about it. Maxim. > }
diff --git a/platform/linux-generic/arch/arm/odp_cpu_arch.c b/platform/linux-generic/arch/arm/odp_cpu_arch.c index 109dd93..0ae3e0e 100644 --- a/platform/linux-generic/arch/arm/odp_cpu_arch.c +++ b/platform/linux-generic/arch/arm/odp_cpu_arch.c @@ -14,25 +14,12 @@ #include <odp/api/system_info.h> #include <odp_debug_internal.h> -#define GIGA 1000000000 - uint64_t odp_cpu_cycles(void) { - struct timespec time; - uint64_t sec, ns, hz, cycles; - int ret; - - ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); - - if (ret != 0) - ODP_ABORT("clock_gettime failed\n"); - - hz = odp_cpu_hz_max(); - sec = (uint64_t)time.tv_sec; - ns = (uint64_t)time.tv_nsec; - - cycles = sec * hz; - cycles += (ns * hz) / GIGA; - - return cycles; +#if defined(__aarch64__) + uint64_t vct; + __asm__ volatile("isb" : : : "memory"); + __asm__ volatile("mrs %0, cntvct_el0" : "=r" (vct)); + return vct; +#endif }
Signed-off-by: Brian Brooks <brian.brooks@linaro.org> --- platform/linux-generic/arch/arm/odp_cpu_arch.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) -- 2.9.0