Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dcf5ac4c authored by Shiraz Hashim's avatar Shiraz Hashim Committed by Charan Teja Reddy
Browse files

arm: keep address range pmd aligned while remap



During early init, all dma areas are remapped to PAGE_SIZE
granularity. Since full pmd regions are cleared to be
remapped into PAGE_SIZE, ensure that address range is pmd
size aligned while not crossing memory boundaries.

This would ensure that even if address region is not pmd
aligned, its mapping would not be cleared but factored in to
PAGE_SIZE regions.

Change-Id: Iad4ad7fd6169cdc693d532821aba453465addb7c
Signed-off-by: default avatarShiraz Hashim <shashim@codeaurora.org>
Signed-off-by: default avatarCharan Teja Reddy <charante@codeaurora.org>
parent 89e53bc5
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -487,6 +487,15 @@ void __init dma_contiguous_remap(void)
		struct map_desc map;
		unsigned long addr;

		/*
		 * Make start and end PMD_SIZE aligned, observing memory
		 * boundaries
		 */
		if (memblock_is_memory(start & PMD_MASK))
			start = start & PMD_MASK;
		if (memblock_is_memory(ALIGN(end, PMD_SIZE)))
			end = ALIGN(end, PMD_SIZE);

		if (end > arm_lowmem_limit)
			end = arm_lowmem_limit;
		if (start >= end)
@@ -507,8 +516,13 @@ void __init dma_contiguous_remap(void)
		 * and ensures that this code is architecturally compliant.
		 */
		for (addr = __phys_to_virt(start); addr < __phys_to_virt(end);
		     addr += PMD_SIZE)
			pmd_clear(pmd_off_k(addr));
		     addr += PMD_SIZE) {
			pmd_t *pmd;

			pmd = pmd_off_k(addr);
			if (pmd_bad(*pmd))
				pmd_clear(pmd);
		}

		flush_tlb_kernel_range(__phys_to_virt(start),
				       __phys_to_virt(end));