Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers: dma-coherent: use MEMREMAP_WC for DMA_MEMORY_MAP

When the DMA_MEMORY_MAP flag is used, memory which can be accessed
directly should be returned, so use memremap(..., MEMREMAP_WC) to
provide a writecombine mapping.

Signed-off-by: Brian Starkey <brian.starkey@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Brian Starkey and committed by
Linus Torvalds
6b03ae0d c907e0eb

+16 -4
+16 -4
drivers/base/dma-coherent.c
··· 2 2 * Coherent per-device memory handling. 3 3 * Borrowed from i386 4 4 */ 5 + #include <linux/io.h> 5 6 #include <linux/slab.h> 6 7 #include <linux/kernel.h> 7 8 #include <linux/module.h> ··· 32 31 if (!size) 33 32 goto out; 34 33 35 - mem_base = ioremap(phys_addr, size); 34 + if (flags & DMA_MEMORY_MAP) 35 + mem_base = memremap(phys_addr, size, MEMREMAP_WC); 36 + else 37 + mem_base = ioremap(phys_addr, size); 36 38 if (!mem_base) 37 39 goto out; 38 40 ··· 58 54 59 55 out: 60 56 kfree(dma_mem); 61 - if (mem_base) 62 - iounmap(mem_base); 57 + if (mem_base) { 58 + if (flags & DMA_MEMORY_MAP) 59 + memunmap(mem_base); 60 + else 61 + iounmap(mem_base); 62 + } 63 63 return false; 64 64 } 65 65 ··· 71 63 { 72 64 if (!mem) 73 65 return; 74 - iounmap(mem->virt_base); 66 + 67 + if (mem->flags & DMA_MEMORY_MAP) 68 + memunmap(mem->virt_base); 69 + else 70 + iounmap(mem->virt_base); 75 71 kfree(mem->bitmap); 76 72 kfree(mem); 77 73 }