* [PATCH v2] riscv: Skip riscv_cpu_setup() when CPU driver is disabled
@ 2026-05-11 8:31 Michal Simek
2026-06-08 8:44 ` Michal Simek
2026-06-29 9:00 ` Michal Simek
0 siblings, 2 replies; 5+ messages in thread
From: Michal Simek @ 2026-05-11 8:31 UTC (permalink / raw)
To: u-boot, git; +Cc: Yao Zi, Leo, Rick Chen, Tom Rini
Building on commit c64fc632a86a ("riscv: cpu: Use CONFIG_IS_ENABLED(CPU)
instead of plain ifdef"), add an early return in riscv_cpu_setup() when
CONFIG_CPU is not enabled. This allows platforms to save code space in
SPL by disabling CONFIG_SPL_CPU.
Without this patch, building U-Boot with CONFIG_CPU=n and CONFIG_EVENT=y
is broken: riscv_cpu_setup() is registered as an EVT_DM_POST_INIT_F event
spy, and when the CPU uclass is unavailable uclass_find_first_device()
returns no device, so the function returns -ENODEV. That in turn makes
event_notify_null() in dm_init_and_scan() fail and triggers a boot hang
("initcall initf_dm() failed"). Returning 0 early avoids that failure.
The compiler's dead-code elimination combined with --gc-sections
removes the unreachable code and all associated static data,
achieving significant size reduction without preprocessor guards:
spl/u-boot-spl:all -4332 spl/u-boot-spl:rodata -2872
spl/u-boot-spl:text -1460
Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Yao Zi <me@ziyao.cc>
---
Changes in v2:
- extend commit message
arch/riscv/cpu/cpu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
index bbadd0c9a469..3bec7c7cb6d0 100644
--- a/arch/riscv/cpu/cpu.c
+++ b/arch/riscv/cpu/cpu.c
@@ -638,6 +638,9 @@ int riscv_cpu_setup(void)
const char *isa, **exts;
struct udevice *dev;
+ if (!CONFIG_IS_ENABLED(CPU))
+ return 0;
+
uclass_find_first_device(UCLASS_CPU, &dev);
if (!dev) {
debug("unable to find the RISC-V cpu device\n");
--
2.43.0
base-commit: 04687b44082b822ffff4a70992fdffb56f364d35
branch: debian-sent3
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] riscv: Skip riscv_cpu_setup() when CPU driver is disabled
2026-05-11 8:31 [PATCH v2] riscv: Skip riscv_cpu_setup() when CPU driver is disabled Michal Simek
@ 2026-06-08 8:44 ` Michal Simek
2026-06-29 9:00 ` Michal Simek
1 sibling, 0 replies; 5+ messages in thread
From: Michal Simek @ 2026-06-08 8:44 UTC (permalink / raw)
To: u-boot, git, Tom Rini; +Cc: Yao Zi, Leo, Rick Chen, Tom Rini
Hi Rick, cc: Tom,
On 5/11/26 10:31, Michal Simek wrote:
> Building on commit c64fc632a86a ("riscv: cpu: Use CONFIG_IS_ENABLED(CPU)
> instead of plain ifdef"), add an early return in riscv_cpu_setup() when
> CONFIG_CPU is not enabled. This allows platforms to save code space in
> SPL by disabling CONFIG_SPL_CPU.
>
> Without this patch, building U-Boot with CONFIG_CPU=n and CONFIG_EVENT=y
> is broken: riscv_cpu_setup() is registered as an EVT_DM_POST_INIT_F event
> spy, and when the CPU uclass is unavailable uclass_find_first_device()
> returns no device, so the function returns -ENODEV. That in turn makes
> event_notify_null() in dm_init_and_scan() fail and triggers a boot hang
> ("initcall initf_dm() failed"). Returning 0 early avoids that failure.
>
> The compiler's dead-code elimination combined with --gc-sections
> removes the unreachable code and all associated static data,
> achieving significant size reduction without preprocessor guards:
>
> spl/u-boot-spl:all -4332 spl/u-boot-spl:rodata -2872
> spl/u-boot-spl:text -1460
>
> Signed-off-by: Michal Simek <michal.simek@amd.com>
> Reviewed-by: Yao Zi <me@ziyao.cc>
> ---
>
> Changes in v2:
> - extend commit message
>
> arch/riscv/cpu/cpu.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> index bbadd0c9a469..3bec7c7cb6d0 100644
> --- a/arch/riscv/cpu/cpu.c
> +++ b/arch/riscv/cpu/cpu.c
> @@ -638,6 +638,9 @@ int riscv_cpu_setup(void)
> const char *isa, **exts;
> struct udevice *dev;
>
> + if (!CONFIG_IS_ENABLED(CPU))
> + return 0;
> +
> uclass_find_first_device(UCLASS_CPU, &dev);
> if (!dev) {
> debug("unable to find the RISC-V cpu device\n");
Rick: Can you apply this patch?
Thanks,
Michal
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] riscv: Skip riscv_cpu_setup() when CPU driver is disabled
2026-05-11 8:31 [PATCH v2] riscv: Skip riscv_cpu_setup() when CPU driver is disabled Michal Simek
2026-06-08 8:44 ` Michal Simek
@ 2026-06-29 9:00 ` Michal Simek
2026-06-29 14:28 ` Tom Rini
[not found] ` <5q5jvub5st33a5i3wfepjbqjcvxmxfyrjun7wxptqfjccra54d@ceo2hhhzibnv>
1 sibling, 2 replies; 5+ messages in thread
From: Michal Simek @ 2026-06-29 9:00 UTC (permalink / raw)
To: u-boot, git, Tom Rini; +Cc: Yao Zi, Leo, Rick Chen
Hi Tom,
On 5/11/26 10:31, Michal Simek wrote:
> Building on commit c64fc632a86a ("riscv: cpu: Use CONFIG_IS_ENABLED(CPU)
> instead of plain ifdef"), add an early return in riscv_cpu_setup() when
> CONFIG_CPU is not enabled. This allows platforms to save code space in
> SPL by disabling CONFIG_SPL_CPU.
>
> Without this patch, building U-Boot with CONFIG_CPU=n and CONFIG_EVENT=y
> is broken: riscv_cpu_setup() is registered as an EVT_DM_POST_INIT_F event
> spy, and when the CPU uclass is unavailable uclass_find_first_device()
> returns no device, so the function returns -ENODEV. That in turn makes
> event_notify_null() in dm_init_and_scan() fail and triggers a boot hang
> ("initcall initf_dm() failed"). Returning 0 early avoids that failure.
>
> The compiler's dead-code elimination combined with --gc-sections
> removes the unreachable code and all associated static data,
> achieving significant size reduction without preprocessor guards:
>
> spl/u-boot-spl:all -4332 spl/u-boot-spl:rodata -2872
> spl/u-boot-spl:text -1460
>
> Signed-off-by: Michal Simek <michal.simek@amd.com>
> Reviewed-by: Yao Zi <me@ziyao.cc>
> ---
>
> Changes in v2:
> - extend commit message
>
> arch/riscv/cpu/cpu.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> index bbadd0c9a469..3bec7c7cb6d0 100644
> --- a/arch/riscv/cpu/cpu.c
> +++ b/arch/riscv/cpu/cpu.c
> @@ -638,6 +638,9 @@ int riscv_cpu_setup(void)
> const char *isa, **exts;
> struct udevice *dev;
>
> + if (!CONFIG_IS_ENABLED(CPU))
> + return 0;
> +
> uclass_find_first_device(UCLASS_CPU, &dev);
> if (!dev) {
> debug("unable to find the RISC-V cpu device\n");
Can you please take it directly to next branch?
Thanks,
Michal
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] riscv: Skip riscv_cpu_setup() when CPU driver is disabled
2026-06-29 9:00 ` Michal Simek
@ 2026-06-29 14:28 ` Tom Rini
[not found] ` <5q5jvub5st33a5i3wfepjbqjcvxmxfyrjun7wxptqfjccra54d@ceo2hhhzibnv>
1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2026-06-29 14:28 UTC (permalink / raw)
To: Michal Simek, Leo Liang, Tim Ouyang; +Cc: u-boot, git, Yao Zi, Rick Chen
[-- Attachment #1: Type: text/plain, Size: 2281 bytes --]
On Mon, Jun 29, 2026 at 11:00:40AM +0200, Michal Simek wrote:
> Hi Tom,
>
> On 5/11/26 10:31, Michal Simek wrote:
> > Building on commit c64fc632a86a ("riscv: cpu: Use CONFIG_IS_ENABLED(CPU)
> > instead of plain ifdef"), add an early return in riscv_cpu_setup() when
> > CONFIG_CPU is not enabled. This allows platforms to save code space in
> > SPL by disabling CONFIG_SPL_CPU.
> >
> > Without this patch, building U-Boot with CONFIG_CPU=n and CONFIG_EVENT=y
> > is broken: riscv_cpu_setup() is registered as an EVT_DM_POST_INIT_F event
> > spy, and when the CPU uclass is unavailable uclass_find_first_device()
> > returns no device, so the function returns -ENODEV. That in turn makes
> > event_notify_null() in dm_init_and_scan() fail and triggers a boot hang
> > ("initcall initf_dm() failed"). Returning 0 early avoids that failure.
> >
> > The compiler's dead-code elimination combined with --gc-sections
> > removes the unreachable code and all associated static data,
> > achieving significant size reduction without preprocessor guards:
> >
> > spl/u-boot-spl:all -4332 spl/u-boot-spl:rodata -2872
> > spl/u-boot-spl:text -1460
> >
> > Signed-off-by: Michal Simek <michal.simek@amd.com>
> > Reviewed-by: Yao Zi <me@ziyao.cc>
> > ---
> >
> > Changes in v2:
> > - extend commit message
> >
> > arch/riscv/cpu/cpu.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> > index bbadd0c9a469..3bec7c7cb6d0 100644
> > --- a/arch/riscv/cpu/cpu.c
> > +++ b/arch/riscv/cpu/cpu.c
> > @@ -638,6 +638,9 @@ int riscv_cpu_setup(void)
> > const char *isa, **exts;
> > struct udevice *dev;
> > + if (!CONFIG_IS_ENABLED(CPU))
> > + return 0;
> > +
> > uclass_find_first_device(UCLASS_CPU, &dev);
> > if (!dev) {
> > debug("unable to find the RISC-V cpu device\n");
>
> Can you please take it directly to next branch?
I understand your frustration at how the RISC-V changes have been being
handled for several months now. I'm adding the new custodian (Tim) as
well as Leo's new email to the email here as I expect a pull request for
the next branch (and I can help with questions on "how", off-list, if
needed), hopefully soon.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread[parent not found: <5q5jvub5st33a5i3wfepjbqjcvxmxfyrjun7wxptqfjccra54d@ceo2hhhzibnv>]
end of thread, other threads:[~2026-07-20 6:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 8:31 [PATCH v2] riscv: Skip riscv_cpu_setup() when CPU driver is disabled Michal Simek
2026-06-08 8:44 ` Michal Simek
2026-06-29 9:00 ` Michal Simek
2026-06-29 14:28 ` Tom Rini
[not found] ` <5q5jvub5st33a5i3wfepjbqjcvxmxfyrjun7wxptqfjccra54d@ceo2hhhzibnv>
[not found] ` <d00b7401-d52e-4d49-bfd3-6330d8b31a94@amd.com>
2026-07-20 6:11 ` Michal Simek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox