From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] memremap: add arch specific hook for MEMREMAP_WB mappings
Date: Fri, 26 Feb 2016 18:34:12 +0100 [thread overview]
Message-ID: <1456508053-15015-3-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1456508053-15015-1-git-send-email-ard.biesheuvel@linaro.org>
Currently, the memremap code serves MEMREMAP_WB mappings directly from
the kernel direct mapping, unless the region is in high memory, in which
case it falls back to using ioremap_cache(). However, the semantics of
ioremap_cache() are not unambiguously defined, and on ARM, it will
actually result in a mapping type that differs from the attributes used
for the linear mapping, and for this reason, the ioremap_cache() call
fails if the region is part of the memory managed by the kernel.
So instead, implement an optional hook 'arch_memremap_wb' whose default
implementation calls ioremap_cache() as before, but which can be
overridden by the architecture to do what is appropriate for it.
Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
kernel/memremap.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 7a1b5c3ef14e..77c41648ba16 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -27,6 +27,13 @@ __weak void __iomem *ioremap_cache(resource_size_t offset, unsigned long size)
}
#endif
+#ifndef arch_memremap_wb
+static void *arch_memremap_wb(resource_size_t offset, unsigned long size)
+{
+ return (__force void *)ioremap_cache(offset, size);
+}
+#endif
+
static void *try_ram_remap(resource_size_t offset, size_t size)
{
struct page *page = pfn_to_page(offset >> PAGE_SHIFT);
@@ -34,7 +41,7 @@ static void *try_ram_remap(resource_size_t offset, size_t size)
/* In the simple case just return the existing linear address */
if (!PageHighMem(page))
return __va(offset);
- return NULL; /* fallback to ioremap_cache */
+ return arch_memremap_wb(offset, size);
}
/**
@@ -80,8 +87,6 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)
*/
if (is_ram == REGION_INTERSECTS)
addr = try_ram_remap(offset, size);
- if (!addr)
- addr = ioremap_cache(offset, size);
}
/*
--
2.5.0
next prev parent reply other threads:[~2016-02-26 17:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 17:34 [PATCH v2 0/3] fix memremap on ARM Ard Biesheuvel
2016-02-26 17:34 ` [PATCH v2 1/3] Revert "mtd: pxa2xx-flash: switch from ioremap_cache to memremap" Ard Biesheuvel
2016-02-26 17:34 ` Ard Biesheuvel [this message]
2016-02-26 17:34 ` [PATCH v2 3/3] ARM: memremap: implement arch_memremap_wb() Ard Biesheuvel
2016-03-03 16:24 ` [PATCH v2 0/3] fix memremap on ARM Ard Biesheuvel
2016-03-03 17:13 ` Russell King - ARM Linux
2016-03-03 17:16 ` Ard Biesheuvel
2016-03-03 17:27 ` Dan Williams
2016-03-03 17:30 ` Ard Biesheuvel
2016-03-03 17:33 ` Dan Williams
2016-03-03 17:41 ` Ard Biesheuvel
2016-03-03 17:55 ` Dan Williams
2016-03-03 17:57 ` Ard Biesheuvel
2016-03-03 18:01 ` Dan Williams
2016-03-03 18:07 ` Ard Biesheuvel
2016-03-03 19:36 ` Russell King - ARM Linux
2016-03-03 19:42 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456508053-15015-3-git-send-email-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).