From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Stefan Kerkmann <s.kerkmann@pengutronix.de>,
Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 3/3] pbl: introduce HAS_PBL_CLOCKSOURCE marker
Date: Wed, 22 Jan 2025 10:07:39 +0100 [thread overview]
Message-ID: <7e9b85c3-7a44-4c48-b739-e1d0ec70e027@pengutronix.de> (raw)
In-Reply-To: <20250121-feature-pbl-get-time-ns-v1-3-c3d493397846@pengutronix.de>
Hello Stefan,
On 21.01.25 17:49, Stefan Kerkmann wrote:
> 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@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) \
This is getting too complicated. I'd prefer you factor this out into a separate
maco and have #ifdefs there. See my series for how this could look like:
https://lore.barebox.org/barebox/20250108110420.1850995-1-a.fatoum@pengutronix.de/
> 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
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2025-01-22 9:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-21 16:49 [PATCH 0/3] PBL: enable timeouts in read_poll_timeout macros Stefan Kerkmann
2025-01-21 16:49 ` [PATCH 1/3] ARM64: lib64: pbl: implement get_time_ns and is_timeout Stefan Kerkmann
2025-01-21 16:49 ` [PATCH 2/3] ARM: lib32: " Stefan Kerkmann
2025-01-21 16:49 ` [PATCH 3/3] pbl: introduce HAS_PBL_CLOCKSOURCE marker Stefan Kerkmann
2025-01-22 8:12 ` Sascha Hauer
2025-01-22 9:07 ` Ahmad Fatoum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7e9b85c3-7a44-4c48-b739-e1d0ec70e027@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
--cc=s.kerkmann@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox