aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Starkey <brian.starkey@arm.com>2016-03-22 17:28:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-22 18:36:02 -0400
commitc907e0eb43a522de60fb651c011c553f87273222 (patch)
tree7118a20b13c415b508666d1c0a797e972e2ba4eb
parentcf61e2a1487d833e4748dead4096584de70bf742 (diff)
memremap: add MEMREMAP_WC flag
Add a flag to memremap() for writecombine mappings. Mappings satisfied by this flag will not be cached, however writes may be delayed or combined into more efficient bursts. This is most suitable for buffers written sequentially by the CPU for use by other DMA devices. 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>
-rw-r--r--include/linux/io.h1
-rw-r--r--kernel/memremap.c13
2 files changed, 12 insertions, 2 deletions
diff --git a/include/linux/io.h b/include/linux/io.h
index 32403b5716e5..e2c8419278c1 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -135,6 +135,7 @@ enum {
135 /* See memremap() kernel-doc for usage description... */ 135 /* See memremap() kernel-doc for usage description... */
136 MEMREMAP_WB = 1 << 0, 136 MEMREMAP_WB = 1 << 0,
137 MEMREMAP_WT = 1 << 1, 137 MEMREMAP_WT = 1 << 1,
138 MEMREMAP_WC = 1 << 2,
138}; 139};
139 140
140void *memremap(resource_size_t offset, size_t size, unsigned long flags); 141void *memremap(resource_size_t offset, size_t size, unsigned long flags);
diff --git a/kernel/memremap.c b/kernel/memremap.c
index e5e685e6ff2a..a6d382312e6f 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -41,11 +41,13 @@ static void *try_ram_remap(resource_size_t offset, size_t size)
41 * memremap() - remap an iomem_resource as cacheable memory 41 * memremap() - remap an iomem_resource as cacheable memory
42 * @offset: iomem resource start address 42 * @offset: iomem resource start address
43 * @size: size of remap 43 * @size: size of remap
44 * @flags: either MEMREMAP_WB or MEMREMAP_WT 44 * @flags: any of MEMREMAP_WB, MEMREMAP_WT and MEMREMAP_WC
45 * 45 *
46 * memremap() is "ioremap" for cases where it is known that the resource 46 * memremap() is "ioremap" for cases where it is known that the resource
47 * being mapped does not have i/o side effects and the __iomem 47 * being mapped does not have i/o side effects and the __iomem
48 * annotation is not applicable. 48 * annotation is not applicable. In the case of multiple flags, the different
49 * mapping types will be attempted in the order listed below until one of
50 * them succeeds.
49 * 51 *
50 * MEMREMAP_WB - matches the default mapping for System RAM on 52 * MEMREMAP_WB - matches the default mapping for System RAM on
51 * the architecture. This is usually a read-allocate write-back cache. 53 * the architecture. This is usually a read-allocate write-back cache.
@@ -57,6 +59,10 @@ static void *try_ram_remap(resource_size_t offset, size_t size)
57 * cache or are written through to memory and never exist in a 59 * cache or are written through to memory and never exist in a
58 * cache-dirty state with respect to program visibility. Attempts to 60 * cache-dirty state with respect to program visibility. Attempts to
59 * map System RAM with this mapping type will fail. 61 * map System RAM with this mapping type will fail.
62 *
63 * MEMREMAP_WC - establish a writecombine mapping, whereby writes may
64 * be coalesced together (e.g. in the CPU's write buffers), but is otherwise
65 * uncached. Attempts to map System RAM with this mapping type will fail.
60 */ 66 */
61void *memremap(resource_size_t offset, size_t size, unsigned long flags) 67void *memremap(resource_size_t offset, size_t size, unsigned long flags)
62{ 68{
@@ -102,6 +108,9 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)
102 if (!addr && (flags & MEMREMAP_WT)) 108 if (!addr && (flags & MEMREMAP_WT))
103 addr = ioremap_wt(offset, size); 109 addr = ioremap_wt(offset, size);
104 110
111 if (!addr && (flags & MEMREMAP_WC))
112 addr = ioremap_wc(offset, size);
113
105 return addr; 114 return addr;
106} 115}
107EXPORT_SYMBOL(memremap); 116EXPORT_SYMBOL(memremap);