[PATCH 3/3] pbl: introduce HAS_PBL_CLOCKSOURCE marker
Stefan Kerkmann
s.kerkmann at pengutronix.de
Tue Jan 21 08:49:28 PST 2025
This finally enables the usage of the polled timeout functions in the
barebox pbl with real timeouts for supported architectures. Currently
only ARMv7 and ARMv8 are enabled.
Signed-off-by: Stefan Kerkmann <s.kerkmann at pengutronix.de>
---
arch/arm/cpu/Kconfig | 2 ++
arch/arm/lib32/Makefile | 2 +-
include/linux/iopoll.h | 8 ++++----
pbl/Kconfig | 3 +++
4 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig
index 84fe770b6da892723528eeea89ae2b0eda122d07..3569f3d3483a6289d7a6eca3d1715e06144df8d4 100644
--- a/arch/arm/cpu/Kconfig
+++ b/arch/arm/cpu/Kconfig
@@ -84,6 +84,7 @@ config CPU_V6
config CPU_V7
bool
select CPU_32v7
+ select HAS_PBL_CLOCKSOURCE
# ARMv8
config CPU_V8
@@ -125,6 +126,7 @@ config CPU_32v7
config CPU_64v8
bool
select CPU_64
+ select HAS_PBL_CLOCKSOURCE
comment "processor features"
diff --git a/arch/arm/lib32/Makefile b/arch/arm/lib32/Makefile
index a139a80fb84973e01e24b063eb6b1d774a60a056..4509d483b27ec7da038b17729f552d6f09fd39ec 100644
--- a/arch/arm/lib32/Makefile
+++ b/arch/arm/lib32/Makefile
@@ -31,7 +31,7 @@ extra-y += barebox.lds
pbl-y += lib1funcs.o
pbl-y += ashldi3.o
pbl-y += div0.o
-pbl-$(CONFIG_CPU_32v7) += arm_architected_timer.o
+pbl-$(CONFIG_HAS_PBL_CLOCKSOURCE) += arm_architected_timer.o
CFLAGS_arm_architected_timer.o := -march=armv7-a
obj-pbl-y += setjmp.o
diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
index 9350a3d05007fbf760e2dea2a981cb86641343fd..df7fdbfa4ae0aec825cc02afa8f14d1ea1f1e535 100644
--- a/include/linux/iopoll.h
+++ b/include/linux/iopoll.h
@@ -26,19 +26,19 @@
* When available, you'll probably want to use one of the specialized
* macros defined below rather than this macro directly.
*
- * We do not have timing functions in the PBL, so ignore the timeout value and
- * loop infinitely here.
+ * In the PBL the timeout is ignored if timing functions are not implemented.
+ * This potentially means looping infinitely!
*/
#define read_poll_timeout(op, val, cond, timeout_us, args...) \
({ \
uint64_t start = 0; \
- if (IN_PROPER && (timeout_us) != 0) \
+ if ((IN_PROPER || IS_ENABLED(CONFIG_HAS_PBL_CLOCKSOURCE)) && (timeout_us) != 0) \
start = get_time_ns(); \
for (;;) { \
(val) = op(args); \
if (cond) \
break; \
- if (IN_PROPER && (timeout_us) != 0 && \
+ if ((IN_PROPER || IS_ENABLED(CONFIG_HAS_PBL_CLOCKSOURCE)) && (timeout_us) != 0 && \
is_timeout(start, ((timeout_us) * USECOND))) { \
(val) = op(args); \
break; \
diff --git a/pbl/Kconfig b/pbl/Kconfig
index 98d71791454b1a31f315ca3fdffa675e6d3dcb50..c2697a2bd00d807a78ac6bc9f0bcf7b28d150c59 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -26,6 +26,9 @@ config PBL_SINGLE_IMAGE
depends on !HAVE_PBL_MULTI_IMAGES
default y
+config HAS_PBL_CLOCKSOURCE
+ bool
+
if PBL_IMAGE
config USE_COMPRESSED_DTB
--
2.39.5
More information about the barebox
mailing list