arch/arm/include/asm/timex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
After commit dfc256dac54c ("calibrate: Rework delay timer calibration"),
certain ARM configurations (such as multi_v5_defconfig) hang during
boot. The use of read_current_timer() in arch/arm's get_cycles() was
improperly converted to delay_read_timer(), resulting in get_cycles()
returning 0 even when the timer has been read or an uninitialized stack
value when delay_read_timer() returns false.
Flip the branches of the ternary condition to fix get_cycles().
Fixes: dfc256dac54c ("calibrate: Rework delay timer calibration")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
arch/arm/include/asm/timex.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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())
#endif
---
base-commit: dfc256dac54c8b692110bf905c64cb130e15963d
change-id: 20260819-fix-arm-get_cycles-c83096ec81a9
Best regards,
--
Cheers,
Nathan
在 2026/8/20 5:43, Nathan Chancellor 写道:
> After commit dfc256dac54c ("calibrate: Rework delay timer calibration"),
> certain ARM configurations (such as multi_v5_defconfig) hang during
> boot. The use of read_current_timer() in arch/arm's get_cycles() was
> improperly converted to delay_read_timer(), resulting in get_cycles()
> returning 0 even when the timer has been read or an uninitialized stack
> value when delay_read_timer() returns false.
>
> Flip the branches of the ternary condition to fix get_cycles().
>
> Fixes: dfc256dac54c ("calibrate: Rework delay timer calibration")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> arch/arm/include/asm/timex.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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; })
LGTM
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
> #define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback())
>
> #endif
>
> ---
> base-commit: dfc256dac54c8b692110bf905c64cb130e15963d
> change-id: 20260819-fix-arm-get_cycles-c83096ec81a9
>
> Best regards,
> --
> Cheers,
> Nathan
>
>
The following commit has been merged into the timers/urgent branch of tip:
Commit-ID: e1e3a0ab69c64eedaf53dce9306f8a090bf038f0
Gitweb: https://git.kernel.org/tip/e1e3a0ab69c64eedaf53dce9306f8a090bf038f0
Author: Nathan Chancellor <nathan@kernel.org>
AuthorDate: Wed, 19 Aug 2026 14:43:21 -07:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Thu, 20 Aug 2026 11:44:08 +02:00
ARM: Fix get_cycles() after delay_read_timer() conversion
After commit dfc256dac54c ("calibrate: Rework delay timer calibration"),
certain ARM configurations (such as multi_v5_defconfig) hang during
boot. The use of read_current_timer() in arch/arm's get_cycles() was
improperly converted to delay_read_timer(), resulting in get_cycles()
returning 0 even when the timer has been read or an uninitialized stack
value when delay_read_timer() returns false.
Flip the branches of the ternary condition to fix get_cycles().
Fixes: dfc256dac54c ("calibrate: Rework delay timer calibration")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: Thomas Gleixner <tglx@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://patch.msgid.link/20260819-fix-arm-get_cycles-v1-1-208bf07ac540@kernel.org
---
arch/arm/include/asm/timex.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h
index 94e40c1..4d31eab 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())
#endif
© 2016 - 2026 Red Hat, Inc.