Commit 6b03ae0d authored by Brian Starkey's avatar Brian Starkey Committed by Linus Torvalds

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: default avatarBrian Starkey <brian.starkey@arm.com>
Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c907e0eb
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Coherent per-device memory handling. * Coherent per-device memory handling.
* Borrowed from i386 * Borrowed from i386
*/ */
#include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -31,7 +32,10 @@ static bool dma_init_coherent_memory( ...@@ -31,7 +32,10 @@ static bool dma_init_coherent_memory(
if (!size) if (!size)
goto out; goto out;
mem_base = ioremap(phys_addr, size); if (flags & DMA_MEMORY_MAP)
mem_base = memremap(phys_addr, size, MEMREMAP_WC);
else
mem_base = ioremap(phys_addr, size);
if (!mem_base) if (!mem_base)
goto out; goto out;
...@@ -54,8 +58,12 @@ static bool dma_init_coherent_memory( ...@@ -54,8 +58,12 @@ static bool dma_init_coherent_memory(
out: out:
kfree(dma_mem); kfree(dma_mem);
if (mem_base) if (mem_base) {
iounmap(mem_base); if (flags & DMA_MEMORY_MAP)
memunmap(mem_base);
else
iounmap(mem_base);
}
return false; return false;
} }
...@@ -63,7 +71,11 @@ static void dma_release_coherent_memory(struct dma_coherent_mem *mem) ...@@ -63,7 +71,11 @@ static void dma_release_coherent_memory(struct dma_coherent_mem *mem)
{ {
if (!mem) if (!mem)
return; return;
iounmap(mem->virt_base);
if (mem->flags & DMA_MEMORY_MAP)
memunmap(mem->virt_base);
else
iounmap(mem->virt_base);
kfree(mem->bitmap); kfree(mem->bitmap);
kfree(mem); kfree(mem);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment