Question about BUILTIN_DTB support in RISCV

Yangyu Chen cyy at cyyself.name
Tue Feb 20 08:41:17 PST 2024


Same problem here. I review the code in the current mainline kernel.
On arch/riscv/kernel/head.S:297:

```asm
#ifdef CONFIG_BUILTIN_DTB
	la a0, __dtb_start
	XIP_FIXUP_OFFSET a0
#else
	mv a0, a1
#endif /* CONFIG_BUILTIN_DTB */
	call setup_vm
```

Then, function `void __init setup_vm(uintptr_t dtb_pa)` will take this
dtb address from a0, and consume the dtb_pa as the only one dtb to set
dtb_early_va and dtb_early_pa. It will never change. Then, the
`parse_dtb` function which will be called from start_kernel-
>setup_arch->parse_dtb will only use dtb_early_va.

I think there is something that might need to be changed. As
CONFIG_BUILTIN_DTB depends on NONPORTABLE, we might need a config like
BUILTIN_DTB_NAME / BUILTIN_DTB_SOURCE to specify what dtb to be linked
to the kernel as loongarch / sh / xtensa does. Currently, we have only
ARCH_CANAAN_K210_DTB_SOURCE to select when building the K210 kernel.
Things to do is to make this configuration more general and let it be
set on all riscv rather than k210 only currently.

Thanks,
Yangyu Chen




More information about the linux-riscv mailing list