Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1345952
| From | Brian Starkey <brian.starkey@arm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 3/4] drivers: dma-coherent: use MEMREMAP_WC for DMA_MEMORY_MAP |
| Date | 2016-02-29 17:20 +0100 |
| Message-ID | <r7yIc-5le-63@gated-at.bofh.it> (permalink) |
| References | <r7yyu-5hu-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
---
drivers/base/dma-coherent.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 87b8083..25bb398 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -2,6 +2,7 @@
* Coherent per-device memory handling.
* Borrowed from i386
*/
+#include <linux/io.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -31,7 +32,10 @@ static bool dma_init_coherent_memory(
if (!size)
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)
goto out;
@@ -54,8 +58,12 @@ static bool dma_init_coherent_memory(
out:
kfree(dma_mem);
- if (mem_base)
- iounmap(mem_base);
+ if (mem_base) {
+ if (flags & DMA_MEMORY_MAP)
+ memunmap(mem_base);
+ else
+ iounmap(mem_base);
+ }
return false;
}
@@ -63,7 +71,11 @@ static void dma_release_coherent_memory(struct dma_coherent_mem *mem)
{
if (!mem)
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);
}
--
1.7.9.5
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/4] Fix kernel panic in dma-coherent allocations Brian Starkey <brian.starkey@arm.com> - 2016-02-29 17:10 +0100
[PATCH v2 1/4] memremap: don't modify flags Brian Starkey <brian.starkey@arm.com> - 2016-02-29 17:20 +0100
[PATCH v2 4/4] drivers: dma-coherent: use memset_io for DMA_MEMORY_IO mappings Brian Starkey <brian.starkey@arm.com> - 2016-02-29 17:20 +0100
Re: [PATCH v2 4/4] drivers: dma-coherent: use memset_io for DMA_MEMORY_IO mappings Andrew Morton <akpm@linux-foundation.org> - 2016-03-01 00:20 +0100
Re: [PATCH v2 4/4] drivers: dma-coherent: use memset_io for DMA_MEMORY_IO mappings Brian Starkey <brian.starkey@arm.com> - 2016-03-01 10:10 +0100
[PATCH v2 3/4] drivers: dma-coherent: use MEMREMAP_WC for DMA_MEMORY_MAP Brian Starkey <brian.starkey@arm.com> - 2016-02-29 17:20 +0100
[PATCH v2 2/4] memremap: add MEMREMAP_WC flag. Brian Starkey <brian.starkey@arm.com> - 2016-02-29 17:20 +0100
csiph-web