From: Christoph Lameter (Ampere) Move the conversion from time to cycles of arch_timer into arch_timer.h. Add nsec conversion since we will need that soon. Signed-off-by: Christoph Lameter Index: linux/arch/arm64/lib/delay.c =================================================================== --- linux.orig/arch/arm64/lib/delay.c +++ linux/arch/arm64/lib/delay.c @@ -15,14 +15,6 @@ #include -#define USECS_TO_CYCLES(time_usecs) \ - xloops_to_cycles((time_usecs) * 0x10C7UL) - -static inline unsigned long xloops_to_cycles(unsigned long xloops) -{ - return (xloops * loops_per_jiffy * HZ) >> 32; -} - void __delay(unsigned long cycles) { cycles_t start = get_cycles(); @@ -39,7 +31,7 @@ void __delay(unsigned long cycles) wfet(end); } else if (arch_timer_evtstrm_available()) { const cycles_t timer_evt_period = - USECS_TO_CYCLES(ARCH_TIMER_EVT_STREAM_PERIOD_US); + ARCH_TIMER_USECS_TO_CYCLES(ARCH_TIMER_EVT_STREAM_PERIOD_US); while ((get_cycles() - start + timer_evt_period) < cycles) wfe(); @@ -52,7 +44,7 @@ EXPORT_SYMBOL(__delay); inline void __const_udelay(unsigned long xloops) { - __delay(xloops_to_cycles(xloops)); + __delay(arch_timer_xloops_to_cycles(xloops)); } EXPORT_SYMBOL(__const_udelay); Index: linux/include/clocksource/arm_arch_timer.h =================================================================== --- linux.orig/include/clocksource/arm_arch_timer.h +++ linux/include/clocksource/arm_arch_timer.h @@ -90,6 +90,19 @@ extern u64 (*arch_timer_read_counter)(vo extern struct arch_timer_kvm_info *arch_timer_get_kvm_info(void); extern bool arch_timer_evtstrm_available(void); +#include + +static inline unsigned long arch_timer_xloops_to_cycles(unsigned long xloops) +{ + return (xloops * loops_per_jiffy * HZ) >> 32; +} + +#define ARCH_TIMER_USECS_TO_CYCLES(time_usecs) \ + arch_timer_xloops_to_cycles((time_usecs) * 0x10C7UL) + +#define ARCH_TIMER_NSECS_TO_CYCLES(time_nsecs) \ + arch_timer_xloops_to_cycles((time_nsecs) * 0x5UL) + #else static inline u32 arch_timer_get_rate(void)