summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMostafa Saleh <smostafa@google.com>2026-06-03 11:05:20 +0000
committerWill Deacon <will@kernel.org>2026-07-21 22:27:47 +0000
commit442d366cc1aabc699015a2e10a41bba17fe416ad (patch)
treebd3796bf842f87e2168d8eb5c265eef0e90bfc7f
parent24f55f511b9e1c19dc48d11bfe0dc60c86bdb376 (diff)
downloadlinux-next-442d366cc1aabc699015a2e10a41bba17fe416ad.tar.gz
linux-next-442d366cc1aabc699015a2e10a41bba17fe416ad.zip
arm64/mm: Simplify SWIOTLB setup in arch_mm_preinit()
At the moment, arch_mm_preinit() checks if the system has limited addressing or is running under CCA to enable SWIOTLB, only after to be forced to true anyway if it was false due to CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC being unconditionally true for arm64. Simplify this logic, by making it clear that SWIOTLB is always used but its size depends on the address layout of the system. Signed-off-by: Mostafa Saleh <smostafa@google.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org> Tested-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org> Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arch/arm64/mm/init.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 97987f850a33..9fb17043dd0d 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -336,25 +336,21 @@ void __init arch_setup_zero_pages(void)
void __init arch_mm_preinit(void)
{
unsigned int flags = SWIOTLB_VERBOSE;
- bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit);
if (is_realm_world()) {
- swiotlb = true;
flags |= SWIOTLB_FORCE;
- }
-
- if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && !swiotlb) {
+ } else if (max_pfn <= PFN_DOWN(arm64_dma_phys_limit)) {
/*
* If no bouncing needed for ZONE_DMA, reduce the swiotlb
* buffer for kmalloc() bouncing to 1MB per 1GB of RAM.
*/
unsigned long size =
DIV_ROUND_UP(memblock_phys_mem_size(), 1024);
+
swiotlb_adjust_size(min(swiotlb_size_or_default(), size));
- swiotlb = true;
}
- swiotlb_init(swiotlb, flags);
+ swiotlb_init(true, flags);
/*
* Check boundaries twice: Some fundamental inconsistencies can be