Skip to content

Commit 122c234

Browse files
baruchsiachChristoph Hellwig
authored andcommitted
arm64: mm: keep low RAM dma zone
Commit ba0fb44 ("dma-mapping: replace zone_dma_bits by zone_dma_limit") optimistically assumed that device-tree dma-ranges property describes the system DMA limits. That assumption ignores DMA limits of individual devices that are not encoded in device tree. Commit 833bd28 ("arm64: mm: fix DMA zone when dma-ranges is missing") fixed part of the problem for platforms that do not provide dma-ranges at all. However platforms like SM8550-HDK provide DMA bus limit, but have devices with stronger DMA limits. of_dma_get_max_cpu_address() does not take device limitations into account. These platforms implicitly rely on DMA zone in low 32-bit RAM area. Until we find a better way to figure out the optimal DMA zone range, restore the low RAM DMA zone we had before commit ba0fb44. Fixes: ba0fb44 ("dma-mapping: replace zone_dma_bits by zone_dma_limit") Closes: https://lore.kernel.org/r/[email protected] Reported-by: Neil Armstrong <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Suggested-by: Robin Murphy <[email protected]> Signed-off-by: Baruch Siach <[email protected]> Tested-by: Neil Armstrong <[email protected]> # on SM8550-HDK Tested-by: Marek Szyprowski <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 334304a commit 122c234

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

arch/arm64/mm/init.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,14 @@ static void __init arch_reserve_crashkernel(void)
116116

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

122128
return min(zone_limit, memblock_end_of_DRAM() - 1) + 1;
123129
}

0 commit comments

Comments
 (0)