Skip to content

Commit 1b50f95

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: No need to relocate the dtb as it lies in the fixmap region
We used to access the dtb via its linear mapping address but now that the dtb early mapping was moved in the fixmap region, we can keep using this address since it is present in swapper_pg_dir, and remove the dtb relocation. Note that the relocation was wrong anyway since early_memremap() is restricted to 256K whereas the maximum fdt size is 2MB. Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Tested-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230329081932.79831-4-alexghiti@rivosinc.com Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent f158162 commit 1b50f95

1 file changed

Lines changed: 2 additions & 19 deletions

File tree

arch/riscv/mm/init.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -249,25 +249,8 @@ static void __init setup_bootmem(void)
249249
* early_init_fdt_reserve_self() since __pa() does
250250
* not work for DTB pointers that are fixmap addresses
251251
*/
252-
if (!IS_ENABLED(CONFIG_BUILTIN_DTB)) {
253-
/*
254-
* In case the DTB is not located in a memory region we won't
255-
* be able to locate it later on via the linear mapping and
256-
* get a segfault when accessing it via __va(dtb_early_pa).
257-
* To avoid this situation copy DTB to a memory region.
258-
* Note that memblock_phys_alloc will also reserve DTB region.
259-
*/
260-
if (!memblock_is_memory(dtb_early_pa)) {
261-
size_t fdt_size = fdt_totalsize(dtb_early_va);
262-
phys_addr_t new_dtb_early_pa = memblock_phys_alloc(fdt_size, PAGE_SIZE);
263-
void *new_dtb_early_va = early_memremap(new_dtb_early_pa, fdt_size);
264-
265-
memcpy(new_dtb_early_va, dtb_early_va, fdt_size);
266-
early_memunmap(new_dtb_early_va, fdt_size);
267-
_dtb_early_pa = new_dtb_early_pa;
268-
} else
269-
memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
270-
}
252+
if (!IS_ENABLED(CONFIG_BUILTIN_DTB))
253+
memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
271254

272255
dma_contiguous_reserve(dma32_phys_limit);
273256
if (IS_ENABLED(CONFIG_64BIT))

0 commit comments

Comments
 (0)