Skip to content

Commit 56a7087

Browse files
Yang Shictmarinas
authored andcommitted
arm64: mm: Fix zone_dma_limit calculation
Commit ba0fb44 ("dma-mapping: replace zone_dma_bits by zone_dma_limit") and subsequent patches changed how zone_dma_limit is calculated to allow a reduced ZONE_DMA even when RAM starts above 4GB. Commit 122c234 ("arm64: mm: keep low RAM dma zone") further fixed this to ensure ZONE_DMA remains below U32_MAX if RAM starts below 4GB, especially on platforms that do not have IORT or DT description of the device DMA ranges. While zone boundaries calculation was fixed by the latter commit, zone_dma_limit, used to determine the GFP_DMA flag in the core code, was not updated. This results in excessive use of GFP_DMA and unnecessary ZONE_DMA allocations on some platforms. Update zone_dma_limit to match the actual upper bound of ZONE_DMA. Fixes: ba0fb44 ("dma-mapping: replace zone_dma_bits by zone_dma_limit") Cc: <[email protected]> # 6.12.x Reported-by: Yutang Jiang <[email protected]> Tested-by: Yutang Jiang <[email protected]> Signed-off-by: Yang Shi <[email protected]> Link: https://lore.kernel.org/r/[email protected] [[email protected]: some tweaking of the commit log] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 49ccf2c commit 56a7087

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

arch/arm64/mm/init.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,6 @@ static void __init arch_reserve_crashkernel(void)
117117

118118
static phys_addr_t __init max_zone_phys(phys_addr_t zone_limit)
119119
{
120-
/**
121-
* Information we get from firmware (e.g. DT dma-ranges) describe DMA
122-
* bus constraints. Devices using DMA might have their own limitations.
123-
* Some of them rely on DMA zone in low 32-bit memory. Keep low RAM
124-
* DMA zone on platforms that have RAM there.
125-
*/
126-
if (memblock_start_of_DRAM() < U32_MAX)
127-
zone_limit = min(zone_limit, U32_MAX);
128-
129120
return min(zone_limit, memblock_end_of_DRAM() - 1) + 1;
130121
}
131122

@@ -141,6 +132,14 @@ static void __init zone_sizes_init(void)
141132
acpi_zone_dma_limit = acpi_iort_dma_get_max_cpu_address();
142133
dt_zone_dma_limit = of_dma_get_max_cpu_address(NULL);
143134
zone_dma_limit = min(dt_zone_dma_limit, acpi_zone_dma_limit);
135+
/*
136+
* Information we get from firmware (e.g. DT dma-ranges) describe DMA
137+
* bus constraints. Devices using DMA might have their own limitations.
138+
* Some of them rely on DMA zone in low 32-bit memory. Keep low RAM
139+
* DMA zone on platforms that have RAM there.
140+
*/
141+
if (memblock_start_of_DRAM() < U32_MAX)
142+
zone_dma_limit = min(zone_dma_limit, U32_MAX);
144143
arm64_dma_phys_limit = max_zone_phys(zone_dma_limit);
145144
max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit);
146145
#endif

0 commit comments

Comments
 (0)