* [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL
@ 2026-05-22 13:48 Ahmad Fatoum
2026-05-26 6:35 ` Sascha Hauer
2026-05-26 6:56 ` Sascha Hauer
0 siblings, 2 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2026-05-22 13:48 UTC (permalink / raw)
To: barebox; +Cc: str, Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL
2026-05-22 13:48 [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL Ahmad Fatoum
@ 2026-05-26 6:35 ` Sascha Hauer
2026-05-26 6:41 ` Ahmad Fatoum
2026-05-26 6:56 ` Sascha Hauer
1 sibling, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2026-05-26 6:35 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, str, Ahmad Fatoum
On 2026-05-22 15:48, Ahmad Fatoum wrote:
> 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.
imx_set_cpu_type() has users in PBL:
arch/arm/mach-imx/atf.c:280: imx_set_cpu_type(IMX_CPU_IMX8MM);
arch/arm/mach-imx/atf.c:343: imx_set_cpu_type(IMX_CPU_IMX8MP);
arch/arm/mach-imx/atf.c:406: imx_set_cpu_type(IMX_CPU_IMX8MN);
arch/arm/mach-imx/atf.c:463: imx_set_cpu_type(IMX_CPU_IMX8MQ);
arch/arm/mach-imx/atf.c:492: imx_set_cpu_type(IMX_CPU_IMX93);
Also several consumers rely on it in PBL:
arch/arm/mach-imx/tzasc.c:358: if (cpu_is_mx8mm() || cpu_is_mx8mn() || cpu_is_mx8mp())
arch/arm/mach-imx/tzasc.c:365: if (cpu_is_mx8mn() || cpu_is_mx8mp())
arch/arm/mach-imx/atf.c:90: if (cpu_is_mx8mn())
arch/arm/mach-imx/atf.c:143: if (cpu_is_mx8mn())
arch/arm/mach-imx/atf.c:198: if (!IS_ENABLED(CONFIG_ARCH_IMX_ATF_PASS_BL_PARAMS) || cpu_is_mx8mq()) {
Sascha
--
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 |
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL
2026-05-26 6:35 ` Sascha Hauer
@ 2026-05-26 6:41 ` Ahmad Fatoum
2026-05-26 6:56 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Ahmad Fatoum @ 2026-05-26 6:41 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox, str
Hello Sascha,
On 5/26/26 08:35, Sascha Hauer wrote:
> On 2026-05-22 15:48, Ahmad Fatoum wrote:
>> 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.
>
> imx_set_cpu_type() has users in PBL:
>
> arch/arm/mach-imx/atf.c:280: imx_set_cpu_type(IMX_CPU_IMX8MM);
> arch/arm/mach-imx/atf.c:343: imx_set_cpu_type(IMX_CPU_IMX8MP);
> arch/arm/mach-imx/atf.c:406: imx_set_cpu_type(IMX_CPU_IMX8MN);
> arch/arm/mach-imx/atf.c:463: imx_set_cpu_type(IMX_CPU_IMX8MQ);
> arch/arm/mach-imx/atf.c:492: imx_set_cpu_type(IMX_CPU_IMX93);
>
> Also several consumers rely on it in PBL:
>
> arch/arm/mach-imx/tzasc.c:358: if (cpu_is_mx8mm() || cpu_is_mx8mn() || cpu_is_mx8mp())
> arch/arm/mach-imx/tzasc.c:365: if (cpu_is_mx8mn() || cpu_is_mx8mp())
> arch/arm/mach-imx/atf.c:90: if (cpu_is_mx8mn())
> arch/arm/mach-imx/atf.c:143: if (cpu_is_mx8mn())
> arch/arm/mach-imx/atf.c:198: if (!IS_ENABLED(CONFIG_ARCH_IMX_ATF_PASS_BL_PARAMS) || cpu_is_mx8mq()) {
Yes and the definition is still emitted for CONFIG_ARCH_IMX_ATF=y.
The change here onl affects 32-bit i.MX.
Cheers,
Ahmad
>
> Sascha
>
> --
> 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 |
>
--
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 |
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL
2026-05-26 6:41 ` Ahmad Fatoum
@ 2026-05-26 6:56 ` Sascha Hauer
0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2026-05-26 6:56 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, str
On 2026-05-26 08:41, Ahmad Fatoum wrote:
> Hello Sascha,
>
> On 5/26/26 08:35, Sascha Hauer wrote:
> > On 2026-05-22 15:48, Ahmad Fatoum wrote:
> >> 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.
> >
> > imx_set_cpu_type() has users in PBL:
> >
> > arch/arm/mach-imx/atf.c:280: imx_set_cpu_type(IMX_CPU_IMX8MM);
> > arch/arm/mach-imx/atf.c:343: imx_set_cpu_type(IMX_CPU_IMX8MP);
> > arch/arm/mach-imx/atf.c:406: imx_set_cpu_type(IMX_CPU_IMX8MN);
> > arch/arm/mach-imx/atf.c:463: imx_set_cpu_type(IMX_CPU_IMX8MQ);
> > arch/arm/mach-imx/atf.c:492: imx_set_cpu_type(IMX_CPU_IMX93);
> >
> > Also several consumers rely on it in PBL:
> >
> > arch/arm/mach-imx/tzasc.c:358: if (cpu_is_mx8mm() || cpu_is_mx8mn() || cpu_is_mx8mp())
> > arch/arm/mach-imx/tzasc.c:365: if (cpu_is_mx8mn() || cpu_is_mx8mp())
> > arch/arm/mach-imx/atf.c:90: if (cpu_is_mx8mn())
> > arch/arm/mach-imx/atf.c:143: if (cpu_is_mx8mn())
> > arch/arm/mach-imx/atf.c:198: if (!IS_ENABLED(CONFIG_ARCH_IMX_ATF_PASS_BL_PARAMS) || cpu_is_mx8mq()) {
>
> Yes and the definition is still emitted for CONFIG_ARCH_IMX_ATF=y.
> The change here onl affects 32-bit i.MX.
Alright, I have overlooked the || defined(CONFIG_ARCH_IMX_ATF).
Sascha
--
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 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL
2026-05-22 13:48 [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL Ahmad Fatoum
2026-05-26 6:35 ` Sascha Hauer
@ 2026-05-26 6:56 ` Sascha Hauer
1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2026-05-26 6:56 UTC (permalink / raw)
To: barebox, Ahmad Fatoum; +Cc: str
On Fri, 22 May 2026 15:48:00 +0200, Ahmad Fatoum wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] ARM: i.MX: prevent use of imx_cpu_type in PBL
https://git.pengutronix.de/cgit/barebox/commit/?id=945f4513ed3b (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-26 7:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-22 13:48 [PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL Ahmad Fatoum
2026-05-26 6:35 ` Sascha Hauer
2026-05-26 6:41 ` Ahmad Fatoum
2026-05-26 6:56 ` Sascha Hauer
2026-05-26 6:56 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox