]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
LoongArch: Consolidate max_pfn & max_low_pfn calculation
authorHuacai Chen <chenhuacai@loongson.cn>
Sun, 9 Nov 2025 08:02:01 +0000 (16:02 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Mon, 10 Nov 2025 00:37:06 +0000 (08:37 +0800)
commitce5ad03e459ecb3b4993a8f311fd4f2fb3e6ef81
tree17fd9284eec4e5977552348fca669835f4553e44
parent43a9e6a10bdde32445ad2725f568e08a94e51dc9
LoongArch: Consolidate max_pfn & max_low_pfn calculation

Now there 5 places which calculate max_pfn & max_low_pfn:
1. in fdt_setup() for FDT systems;
2. in memblock_init() for ACPI systems;
3. in init_numa_memory() for NUMA systems;
4. in arch_mem_init() to recalculate for "mem=" cmdline;
5. in paging_init() to recalculate for NUMA systems.

Since memblock_init() is called both for ACPI and FDT systems, move the
calculation out of the for_each_efi_memory_desc() loop can eliminate the
first case. The last case is very questionable (may be derived from the
MIPS/Loongson code) and breaks the "mem=" cmdline, so should be removed.
And then the NUMA version of paging_init() can be also eliminated.

After consolidation there are 3 places of calculation:
1. in memblock_init() for both ACPI and FDT systems;
2. in init_numa_memory() to recalculate for NUMA systems;
3. in arch_mem_init() to recalculate for the "mem=" cmdline.

For all cases the calculation is:
max_pfn = PFN_DOWN(memblock_end_of_DRAM());
max_low_pfn = min(PFN_DOWN(HIGHMEM_START), max_pfn);

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/mem.c
arch/loongarch/kernel/numa.c
arch/loongarch/kernel/setup.c
arch/loongarch/mm/init.c