]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
LoongArch: Prefer top-down allocation after arch_mem_init()
authorHuacai Chen <chenhuacai@loongson.cn>
Tue, 10 Feb 2026 11:31:13 +0000 (19:31 +0800)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:26 +0000 (07:21 -0500)
commit7a6b754bddd346d9c5e83ef95fd87f40538f9835
tree29a6f38f65d86bbb16e374e9cb7fb6def022c979
parent61a56df2fbaad3a4d00f0c6a904b5d1ee8982eb4
LoongArch: Prefer top-down allocation after arch_mem_init()

[ Upstream commit 2172d6ebac9372eb01fe4505a53e18cb061e103b ]

Currently we use bottom-up allocation after sparse_init(), the reason is
sparse_init() need a lot of memory, and bottom-up allocation may exhaust
precious low memory (below 4GB). On the other hand, SWIOTLB and CMA need
low memories for DMA32, so swiotlb_init() and dma_contiguous_reserve()
need bottom-up allocation.

Since swiotlb_init() and dma_contiguous_reserve() are both called in
arch_mem_init(), we no longer need bottom-up allocation after that. So
we set the allocation policy to top-down at the end of arch_mem_init(),
in order to avoid later memory allocations (such as KASAN) exhaust low
memory.

This solve at least two problems:
1. Some buggy BIOSes use 0xfd000000~0xfe000000 for secondary CPUs, but
   didn't reserve this range, which causes smpboot failures.
2. Some DMA32 devices, such as Loongson-DRM and OHCI, cannot work with
   KASAN enabled.

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/loongarch/kernel/setup.c