All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yao Zi <me@ziyao.cc>
To: Michal Simek <michal.simek@amd.com>, <u-boot@lists.denx.de>,
	<git@amd.com>
Cc: Leo <ycliang@andestech.com>, Rick Chen <rick@andestech.com>,
	Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH] riscv: Skip riscv_cpu_setup() when CPU driver is disabled
Date: Fri, 1 May 2026 08:54:40 +0000	[thread overview]
Message-ID: <afRqUJZF81_y5K_O@pie> (raw)
In-Reply-To: <0d875f98e9d81b68265ea26c379dae8ce5b1f5a9.1777550269.git.michal.simek@amd.com>

On Thu, Apr 30, 2026 at 01:57:51PM +0200, 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.
> 
> 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>
> ---
> 
>  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;

Should we return zero here, or -ENOENT like the original behavior when
no UCLASS_CPU device is found?

Otherwise the patch looks good to me.

Reviewed-by: Yao Zi <me@ziyao.cc>

> +
>  	uclass_find_first_device(UCLASS_CPU, &dev);
>  	if (!dev) {
>  		debug("unable to find the RISC-V cpu device\n");
> -- 
> 2.43.0
> 
> base-commit: ab9f3cb4de54c65bde394e31469c75ec89b18d5b

  reply	other threads:[~2026-05-01  8:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30 11:57 [PATCH] riscv: Skip riscv_cpu_setup() when CPU driver is disabled Michal Simek
2026-05-01  8:54 ` Yao Zi [this message]
2026-05-04  9:00   ` Michal Simek
2026-05-04 20:16     ` Yao Zi

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=afRqUJZF81_y5K_O@pie \
    --to=me@ziyao.cc \
    --cc=git@amd.com \
    --cc=michal.simek@amd.com \
    --cc=rick@andestech.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=ycliang@andestech.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.