[patch 06/38] calibrate: Rework delay timer calibration

Jon Hunter jonathanh at nvidia.com
Thu Aug 20 09:12:30 PDT 2026


Hi Thomas,

On 10/04/2026 13:18, Thomas Gleixner wrote:
> The header define in asm/timex,h and the naming of the function to read the
> delay timer are confusing at best.
> 
> Convert it to a config switch selected by the archictures, which provide
> the functionality, and rename the function to delay_read_timer(), which
> makes the purpose clear. Move the declaration to linux/delay.h where it
> belongs.
> 
> Remove the resulting empty asm/timex.h files as well.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx at kernel.org>
> Cc: Arnd Bergmann <arnd at arndb.de>

...

> --- a/arch/arm/include/asm/timex.h
> +++ b/arch/arm/include/asm/timex.h
> @@ -10,7 +10,10 @@
>   #define _ASMARM_TIMEX_H
>   
>   typedef unsigned long cycles_t;
> -#define get_cycles()	({ cycles_t c; read_current_timer(&c) ? 0 : c; })
> +// Temporary workaround
> +bool delay_read_timer(unsigned long *t);
> +
> +#define get_cycles()	({ cycles_t c; delay_read_timer(&c) ? 0 : c; })
>   #define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())


I have noticed a boot regression on some of our 32-bit Tegra platforms. 
Bisect is pointing to this commit. Making the following change does fix 
it, as delay_read_timer() now returns a valid value when true ...

diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h
index 94e40c19cfc5..4d31eab9dba2 100644
--- a/arch/arm/include/asm/timex.h
+++ b/arch/arm/include/asm/timex.h
@@ -13,7 +13,7 @@ typedef unsigned long cycles_t;
  // Temporary workaround until timex.h is cleaned up
  bool delay_read_timer(unsigned long *t);

-#define get_cycles()   ({ cycles_t c; delay_read_timer(&c) ? 0 : c; })
+#define get_cycles()   ({ cycles_t c; delay_read_timer(&c) ? c : 0; })
  #define random_get_entropy() (((unsigned long)get_cycles()) ?: 
random_get_entropy_fallback())

Cheers
Jon

-- 
nvpublic




More information about the linux-riscv mailing list