[PATCH v2 06/16] LoongArch: skeleton and headers

Simon Glass sjg at chromium.org
Thu Jul 2 12:28:23 CEST 2026


Hi Jiaxun,

On 2026-07-01T11:17:53, Yao Zi <me at ziyao.cc> wrote:
> LoongArch: skeleton and headers
>
> Commit for directories, Kconfig, Makefile and headers
>
> Some of them are copied from linux, some of them are derived
> from other architectures, the rest are wriiten on my own.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang at flygoat.com>
> Signed-off-by: Yao Zi <me at ziyao.cc>

> Some of them are copied from linux, some of them are derived
> from other architectures, the rest are wriiten on my own.

Typo: wriiten -> written. Please also expand this into a proper
motivation paragraph - what LoongArch is, which ISA variant this
covers, and where the imported headers came from.

> diff --git a/arch/loongarch/include/asm/asm.h b/arch/loongarch/include/asm/asm.h
> @@ -0,0 +1,186 @@
> +/*
> + * Size of a register
> + */
> +#if defined(__loongarch__) && __loongarch_grlen == 64
> +#define SZREG        4
> +#else
> +#define SZREG        8
> +#endif

This is inverted - on 64-bit LoongArch a register is 8 bytes, not
4. The result is that REG_L/REG_S resolve to ld.w/st.w on the only
ISA this series supports. Linux seems to use __loongarch64, BTW.

> diff --git a/arch/loongarch/include/asm/system.h b/arch/loongarch/include/asm/system.h
> @@ -0,0 +1,74 @@
> +#define local_irq_save(__flags)                                 \
> +     do {                                                        \
> +             __flags = arch_local_irq_save(CSR_SSTATUS, SR_SIE) & SR_SIE; \
> +     } while (0)

This is leftover RISC-V code - arch_local_irq_save() above takes
no arguments, and CSR_SSTATUS/SR_SIE are not defined for LoongArch.
It compiles today because nothing invokes local_irq_save(), but
will break the moment anyone does. Please rewrite to call the
LoongArch save/restore helpers, matching the enable/disable pattern
above.

> diff --git a/arch/loongarch/include/asm/types.h b/arch/loongarch/include/asm/types.h
> @@ -0,0 +1,37 @@
> +#ifdef __KERNEL__
> +
> +#define BITS_PER_LONG _LOONGARCH_SZLONG

_LOONGARCH_SZLONG is never defined anywhere in the tree, so this
expands to an empty token. Please either define it (e.g. 64 for LA64)
or drop this and rely on asm-generic/bitsperlong.h like other arches.

> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> @@ -0,0 +1,19 @@
> +ARCH_FLAGS = -march=loongarch64 -mabi=lp64s -msoft-float

Since LA32 is on the TODO list, please gate this on CONFIG_ARCH_LA64
(or whatever the final symbol is) rather than hard-coding
loongarch64/lp64s.

Regards,
Simon


More information about the U-Boot mailing list