Skip to content

Commit 3d2054a

Browse files
JoonsooKimtorvalds
authored andcommitted
ARM: CMA: avoid double mapping to the CMA area if CONFIG_HIGHMEM=y
CMA area is now managed by the separate zone, ZONE_MOVABLE, to fix many MM related problems. In this implementation, if CONFIG_HIGHMEM = y, then ZONE_MOVABLE is considered as HIGHMEM and the memory of the CMA area is also considered as HIGHMEM. That means that they are considered as the page without direct mapping. However, CMA area could be in a lowmem and the memory could have direct mapping. In ARM, when establishing a new mapping for DMA, direct mapping should be cleared since two mapping with different cache policy could cause unknown problem. With this patch, PageHighmem() for the CMA memory located in lowmem returns true so that the function for DMA mapping cannot notice whether it needs to clear direct mapping or not, correctly. To handle this situation, this patch always clears direct mapping for such CMA memory. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Joonsoo Kim <[email protected]> Tested-by: Tony Lindgren <[email protected]> Cc: "Aneesh Kumar K . V" <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Laura Abbott <[email protected]> Cc: Marek Szyprowski <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Michal Nazarewicz <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Russell King <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1d47a3e commit 3d2054a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

arch/arm/mm/dma-mapping.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ void __init dma_contiguous_early_fixup(phys_addr_t base, unsigned long size)
466466
void __init dma_contiguous_remap(void)
467467
{
468468
int i;
469+
470+
if (!dma_mmu_remap_num)
471+
return;
472+
473+
/* call flush_cache_all() since CMA area would be large enough */
474+
flush_cache_all();
469475
for (i = 0; i < dma_mmu_remap_num; i++) {
470476
phys_addr_t start = dma_mmu_remap[i].base;
471477
phys_addr_t end = start + dma_mmu_remap[i].size;
@@ -498,7 +504,15 @@ void __init dma_contiguous_remap(void)
498504
flush_tlb_kernel_range(__phys_to_virt(start),
499505
__phys_to_virt(end));
500506

501-
iotable_init(&map, 1);
507+
/*
508+
* All the memory in CMA region will be on ZONE_MOVABLE.
509+
* If that zone is considered as highmem, the memory in CMA
510+
* region is also considered as highmem even if it's
511+
* physical address belong to lowmem. In this case,
512+
* re-mapping isn't required.
513+
*/
514+
if (!is_highmem_idx(ZONE_MOVABLE))
515+
iotable_init(&map, 1);
502516
}
503517
}
504518

0 commit comments

Comments
 (0)