mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
kho: initialize preserved memory map radix tree earlier
Currently the preserved memory radix tree is initialized from kho_memory_init(), which happens relatively late in MM init. In a coming patch, the tree will be used from kho_memory_init_early(). Move the tree initialization there. Simplify some of the code in kho_mem_retrieve() by getting rid of the err variable and jumping to err directly. Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org> Link: https://patch.msgid.link/20260801084833.1897543-16-pratyush@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
This commit is contained in:
parent
4513fea02a
commit
01a0dd3d6f
|
|
@ -1533,24 +1533,8 @@ static void __init kho_mem_retrieve(void)
|
|||
const struct kho_radix_walk_cb cb = {
|
||||
.leaf = kho_preserved_memory_reserve,
|
||||
};
|
||||
const void *fdt = kho_get_fdt();
|
||||
void *mem_map = kho_get_mem_map(fdt);
|
||||
int err;
|
||||
|
||||
/*
|
||||
* kho_get_mem_map() should always succeed. If it fails, kho_populate()
|
||||
* catches that and never sets kho_in.scratch_phys, which stops memory
|
||||
* retrieval.
|
||||
*/
|
||||
if (WARN_ON(!mem_map))
|
||||
return;
|
||||
|
||||
err = kho_radix_init_tree(&kho_in.radix_tree, mem_map);
|
||||
if (err)
|
||||
goto err;
|
||||
|
||||
err = kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL);
|
||||
if (err)
|
||||
if (kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL))
|
||||
goto err;
|
||||
|
||||
return;
|
||||
|
|
@ -1762,15 +1746,40 @@ fs_initcall(kho_init);
|
|||
|
||||
void __init kho_memory_init_early(void)
|
||||
{
|
||||
const void *fdt = kho_get_fdt();
|
||||
void *mem_map;
|
||||
|
||||
if (!is_kho_boot())
|
||||
return;
|
||||
|
||||
/*
|
||||
* kho_get_mem_map() should always succeed. If it fails, kho_populate()
|
||||
* catches that and never sets kho_in.scratch_phys, which stops memory
|
||||
* retrieval.
|
||||
*/
|
||||
mem_map = kho_get_mem_map(fdt);
|
||||
if (WARN_ON(!mem_map))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* kho_scratch_overlap() needs kho_scratch to be initialized. It
|
||||
* is used by free_area_init() on KHO boots, so initialize it
|
||||
* early.
|
||||
*/
|
||||
kho_scratch = phys_to_virt(kho_in.scratch_phys);
|
||||
|
||||
if (kho_radix_init_tree(&kho_in.radix_tree, mem_map))
|
||||
goto err;
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
/*
|
||||
* Failed to initialize preserved memory radix tree. Clear FDT
|
||||
* and scratch so KHO users don't treat it as a KHO boot.
|
||||
*/
|
||||
kho_in.fdt_phys = 0;
|
||||
kho_in.scratch_phys = 0;
|
||||
}
|
||||
|
||||
void __init kho_memory_init(void)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user