Commit cf61e2a1 authored by Brian Starkey's avatar Brian Starkey Committed by Linus Torvalds

memremap: don't modify flags

These patches implement a MEMREMAP_WC flag for memremap(), which can be
used to obtain writecombine mappings.  This is then used for setting up
dma_coherent_mem regions which use the DMA_MEMORY_MAP flag.

The motivation is to fix an alignment fault on arm64, and the suggestion
to implement MEMREMAP_WC for this case was made at [1].  That particular
issue is handled in patch 4, which makes sure that the appropriate
memset function is used when zeroing allocations mapped as IO memory.

This patch (of 4):

Don't modify the flags input argument to memremap(). MEMREMAP_WB is
already a special case so we can check for it directly instead of
clearing flag bits in each mapper.
Signed-off-by: default avatarBrian Starkey <brian.starkey@arm.com>
Cc: Catalin 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 41b27154
...@@ -64,6 +64,9 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags) ...@@ -64,6 +64,9 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)
IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE); IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE);
void *addr = NULL; void *addr = NULL;
if (!flags)
return NULL;
if (is_ram == REGION_MIXED) { if (is_ram == REGION_MIXED) {
WARN_ONCE(1, "memremap attempted on mixed range %pa size: %#lx\n", WARN_ONCE(1, "memremap attempted on mixed range %pa size: %#lx\n",
&offset, (unsigned long) size); &offset, (unsigned long) size);
...@@ -72,7 +75,6 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags) ...@@ -72,7 +75,6 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)
/* Try all mapping types requested until one returns non-NULL */ /* Try all mapping types requested until one returns non-NULL */
if (flags & MEMREMAP_WB) { if (flags & MEMREMAP_WB) {
flags &= ~MEMREMAP_WB;
/* /*
* MEMREMAP_WB is special in that it can be satisifed * MEMREMAP_WB is special in that it can be satisifed
* from the direct map. Some archs depend on the * from the direct map. Some archs depend on the
...@@ -86,21 +88,19 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags) ...@@ -86,21 +88,19 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)
} }
/* /*
* If we don't have a mapping yet and more request flags are * If we don't have a mapping yet and other request flags are
* pending then we will be attempting to establish a new virtual * present then we will be attempting to establish a new virtual
* address mapping. Enforce that this mapping is not aliasing * address mapping. Enforce that this mapping is not aliasing
* System RAM. * System RAM.
*/ */
if (!addr && is_ram == REGION_INTERSECTS && flags) { if (!addr && is_ram == REGION_INTERSECTS && flags != MEMREMAP_WB) {
WARN_ONCE(1, "memremap attempted on ram %pa size: %#lx\n", WARN_ONCE(1, "memremap attempted on ram %pa size: %#lx\n",
&offset, (unsigned long) size); &offset, (unsigned long) size);
return NULL; return NULL;
} }
if (!addr && (flags & MEMREMAP_WT)) { if (!addr && (flags & MEMREMAP_WT))
flags &= ~MEMREMAP_WT;
addr = ioremap_wt(offset, size); addr = ioremap_wt(offset, size);
}
return addr; return addr;
} }
......
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