Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1345943

[PATCH v2 1/4] memremap: don't modify flags

From Brian Starkey <brian.starkey@arm.com>
Newsgroups linux.kernel
Subject [PATCH v2 1/4] memremap: don't modify flags
Date 2016-02-29 17:20 +0100
Message-ID <r7yIa-5le-7@gated-at.bofh.it> (permalink)
References <r7yyu-5hu-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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: Brian Starkey <brian.starkey@arm.com>
---
 kernel/memremap.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/memremap.c b/kernel/memremap.c
index 59c55af..92adb19 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -64,6 +64,9 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)
 				       IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE);
 	void *addr = NULL;
 
+	if (!flags)
+		return NULL;
+
 	if (is_ram == REGION_MIXED) {
 		WARN_ONCE(1, "memremap attempted on mixed range %pa size: %#lx\n",
 				&offset, (unsigned long) size);
@@ -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 */
 	if (flags & MEMREMAP_WB) {
-		flags &= ~MEMREMAP_WB;
 		/*
 		 * MEMREMAP_WB is special in that it can be satisifed
 		 * 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)
 	}
 
 	/*
-	 * If we don't have a mapping yet and more request flags are
-	 * pending then we will be attempting to establish a new virtual
+	 * If we don't have a mapping yet and other request flags are
+	 * present then we will be attempting to establish a new virtual
 	 * address mapping.  Enforce that this mapping is not aliasing
 	 * 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",
 				&offset, (unsigned long) size);
 		return NULL;
 	}
 
-	if (!addr && (flags & MEMREMAP_WT)) {
-		flags &= ~MEMREMAP_WT;
+	if (!addr && (flags & MEMREMAP_WT))
 		addr = ioremap_wt(offset, size);
-	}
 
 	return addr;
 }
-- 
1.7.9.5

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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