Thread (74 messages) 74 messages, 19 authors, 2026-08-20

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

flat view

From: Jon Hunter <jonathanh@nvidia.com>
Date: 2026-08-20 16:12:57
Also in: linux-alpha, linux-crypto, linux-ext4, linux-fbdev, linux-hams, linux-iommu, linux-m68k, linux-mm, linux-riscv, linux-s390, linux-tegra, linux-wireless, linuxppc-dev, lkml, loongarch, sparclinux
Subsystem: arm port, the rest · Maintainers: Russell King, Linus Torvalds

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@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
...
quoted hunk ↗ jump to hunk
--- 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help