From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: str@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL
Date: Fri, 22 May 2026 15:48:00 +0200 [thread overview]
Message-ID: <20260522134803.2988021-1-a.fatoum@pengutronix.de> (raw)
Functions like cpu_is_mx6q internally call cpu_is_mx6() first,
which can be evaluated at compile-time if only i.MX6 boards are enabled.
This allowed calling cpu_is_mx6q in PBL entry points as long as barebox was
compiled for only a single SoC.
Since the multi-arch/multi-platform support was added however,
cpu_is_mx6 became a runtime check that's never true in PBL, leading all
cpu_is_mx* in 32-boards to silently fail at runtime.
We have no in-tree boards that are affected by this, so until some
out-of-tree user is bothered enough to fix is, acknowledge that this no
longer works and turn the silent breakage into a loud compile-time error
whenever anything ends up referencing __imx_cpu_type.
Fixes: 1826809f122e ("ARM: i.MX: fix cpu_is_imx on CONFIG_ARM_MULTIARCH configurations")
Fixes: 60a3fd36fa1e ("arm: mach-imx: set cpu type in pbl")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/mach-imx/Makefile | 4 ++--
include/mach/imx/generic.h | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index a7d60068b954..5c26af577504 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -20,7 +20,7 @@ obj-$(CONFIG_ARCH_VF610) += vf610.o
obj-pbl-$(CONFIG_ARCH_IMX8M) += imx8m.o
obj-pbl-$(CONFIG_ARCH_IMX_SCRATCHMEM) += scratch.o
obj-$(CONFIG_ARCH_IMX9) += imx9.o imx-v3-image.o
-lwl-$(CONFIG_ARCH_IMX_ATF) += atf.o
+lwl-$(CONFIG_ARCH_IMX_ATF) += atf.o imx.o
obj-pbl-$(CONFIG_ARCH_IMX_TZASC) += tzasc.o
obj-pbl-$(CONFIG_ARCH_IMX_ROMAPI) += romapi.o
obj-$(CONFIG_IMX_IIM) += iim.o
@@ -28,7 +28,7 @@ obj-$(CONFIG_NAND_IMX) += nand.o
lwl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
obj-y += imx.o
obj-$(CONFIG_CMD_BOOTROM) += bootrom-cmd.o
-obj-pbl-y += esdctl.o boot.o imx.o
+obj-pbl-y += esdctl.o boot.o
obj-$(CONFIG_BAREBOX_UPDATE) += imx-bbu-internal.o
obj-$(CONFIG_BAREBOX_UPDATE_IMX_EXTERNAL_NAND) += imx-bbu-external-nand.o
pbl-$(CONFIG_USB_GADGET_DRIVER_ARC_PBL) += imx-udc.o
diff --git a/include/mach/imx/generic.h b/include/mach/imx/generic.h
index 5f81aa65a745..0b06c00ac46d 100644
--- a/include/mach/imx/generic.h
+++ b/include/mach/imx/generic.h
@@ -86,12 +86,23 @@ static inline bool imx8mp_keep_compatible_soc_uid(void)
/* range e.g. GPIO_1_5 is gpio 5 under linux */
#define IMX_GPIO_NR(bank, nr) (((bank) - 1) * 32 + (nr))
+#if IN_PROPER || defined(CONFIG_ARCH_IMX_ATF)
extern unsigned int __imx_cpu_type;
static __always_inline void imx_set_cpu_type(unsigned int cpu_type)
{
__imx_cpu_type = cpu_type;
}
+#else
+/*
+ * If you need this in your PBL entry point, consider using functions
+ * that only query the hardware directly like __cpu_mx6_is_*().
+ */
+extern int __imx_cpu_type(void) __compiletime_error("This API is not available in PBL");
+
+#define __imx_cpu_type __imx_cpu_type()
+#endif
+
#ifdef CONFIG_ARCH_IMX1
# ifdef imx_cpu_type
--
2.47.3
reply other threads:[~2026-05-22 13:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260522134803.2988021-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=str@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