mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/2] clock: make udelay(), get_time_ns() and is_timeout() weak aliases
@ 2026-09-09 11:42 Ahmad Fatoum
  2026-09-09 11:42 ` [PATCH master 2/2] ARM64: fall back to reading the counter directly in the PBL udelay() Ahmad Fatoum
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-09-09 11:42 UTC (permalink / raw)
  To: barebox; +Cc: ske, mtr, Ahmad Fatoum

The ARM64 PBL is about to override these three for the time before a
clocksource is registered. Give the clocksource based implementations
names of their own and turn the generic ones into weak aliases, so an
override can still call the clocksource based version. No functional
change.

Assisted-by: Claude:fable-5.1
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/clock.c  | 13 ++++++++++---
 include/clock.h |  5 +++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/common/clock.c b/common/clock.c
index fc770ac8530f..0f2f47ed5399 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -50,7 +50,7 @@ late_initcall(dummy_csrc_warn);
 /**
  * get_time_ns - get current timestamp in nanoseconds
  */
-uint64_t get_time_ns(void)
+uint64_t clocksource_current_get_time_ns(void)
 {
 	struct clocksource *cs = current_clock;
 	uint64_t cycle_now, cycle_delta;
@@ -73,6 +73,8 @@ uint64_t get_time_ns(void)
 	time_ns += ns_offset;
 	return time_ns;
 }
+
+uint64_t get_time_ns(void) __weak __alias(clocksource_current_get_time_ns);
 EXPORT_SYMBOL(get_time_ns);
 
 /**
@@ -165,7 +167,7 @@ int is_timeout_non_interruptible(uint64_t start_ns, uint64_t time_offset_ns)
 }
 EXPORT_SYMBOL(is_timeout_non_interruptible);
 
-int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
+int clocksource_current_is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
 {
 	int ret = is_timeout_non_interruptible(start_ns, time_offset_ns);
 
@@ -174,6 +176,9 @@ int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
 
 	return ret;
 }
+
+int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
+	__weak __alias(clocksource_current_is_timeout);
 EXPORT_SYMBOL(is_timeout);
 
 void ndelay(unsigned long nsecs)
@@ -184,12 +189,14 @@ void ndelay(unsigned long nsecs)
 }
 EXPORT_SYMBOL(ndelay);
 
-void udelay(unsigned long usecs)
+void clocksource_current_udelay(unsigned long usecs)
 {
 	uint64_t start = get_time_ns();
 
 	while(!is_timeout(start, usecs * USECOND));
 }
+
+void udelay(unsigned long usecs) __weak __alias(clocksource_current_udelay);
 EXPORT_SYMBOL(udelay);
 
 void mdelay(unsigned long msecs)
diff --git a/include/clock.h b/include/clock.h
index ca69535e9185..ea87bfd2020a 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -58,6 +58,11 @@ void udelay(unsigned long usecs);
 void mdelay(unsigned long msecs);
 void mdelay_non_interruptible(unsigned long msecs);
 
+/* the clocksource based implementations the weak functions above alias */
+void clocksource_current_udelay(unsigned long usecs);
+uint64_t clocksource_current_get_time_ns(void);
+int clocksource_current_is_timeout(uint64_t start_ns, uint64_t time_offset_ns);
+
 #if IN_PROPER
 void clocksource_srand(void);
 #else
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-09 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 11:42 [PATCH master 1/2] clock: make udelay(), get_time_ns() and is_timeout() weak aliases Ahmad Fatoum
2026-09-09 11:42 ` [PATCH master 2/2] ARM64: fall back to reading the counter directly in the PBL udelay() Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox