]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
arm64: Limit the CMA buffer to 32-bit if ZONE_DMA
authorCatalin Marinas <catalin.marinas@arm.com>
Fri, 13 Jun 2014 12:41:20 +0000 (13:41 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 18 Jun 2014 11:40:56 +0000 (12:40 +0100)
When the CMA buffer is allocated, it is too early to know whether
devices will require ZONE_DMA memory. This patch limits the CMA buffer
to (DMA_BIT_MASK(32) + 1) if CONFIG_ZONE_DMA is enabled.

In addition, it computes the dma_to_phys(DMA_BIT_MASK(32)) before the
increment (no current functional change).

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/mm/init.c

index 091d428d64aca34d74e493bfc27af2c01806a2bb..f43db8a6926208f9b9419c3114d1c41c13514566 100644 (file)
@@ -71,7 +71,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
        /* 4GB maximum for 32-bit only capable devices */
        if (IS_ENABLED(CONFIG_ZONE_DMA)) {
                unsigned long max_dma_phys =
-                       (unsigned long)dma_to_phys(NULL, DMA_BIT_MASK(32) + 1);
+                       (unsigned long)(dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1);
                max_dma = max(min, min(max, max_dma_phys >> PAGE_SHIFT));
                zone_size[ZONE_DMA] = max_dma - min;
        }
@@ -126,6 +126,8 @@ static void arm64_memory_present(void)
 
 void __init arm64_memblock_init(void)
 {
+       phys_addr_t dma_phys_limit = 0;
+
        /* Register the kernel text, kernel data and initrd with memblock */
        memblock_reserve(__pa(_text), _end - _text);
 #ifdef CONFIG_BLK_DEV_INITRD
@@ -141,7 +143,11 @@ void __init arm64_memblock_init(void)
        memblock_reserve(__pa(idmap_pg_dir), IDMAP_DIR_SIZE);
 
        early_init_fdt_scan_reserved_mem();
-       dma_contiguous_reserve(0);
+
+       /* 4GB maximum for 32-bit only capable devices */
+       if (IS_ENABLED(CONFIG_ZONE_DMA))
+               dma_phys_limit = dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1;
+       dma_contiguous_reserve(dma_phys_limit);
 
        memblock_allow_resize();
        memblock_dump_all();