diff options
author | Toshi Kani <toshi.kani@hp.com> | 2015-06-04 12:55:15 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-06-07 09:28:56 -0400 |
commit | d838270e2516db11084bed4e294017eb7b646a75 (patch) | |
tree | 5c2beb8e62d8d37a379160522bd2040c7dade7f0 | |
parent | ecb2febaaa3945e1578359adc30ca818e78540fb (diff) |
x86/mm, asm-generic: Add ioremap_wt() for creating Write-Through mappings
Add ioremap_wt() for creating Write-Through mappings on x86. It
follows the same model as ioremap_wc() for multi-arch support.
Define ARCH_HAS_IOREMAP_WT in the x86 version of io.h to
indicate that ioremap_wt() is implemented on x86.
Also update the PAT documentation file to cover ioremap_wt().
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Elliott@hp.com
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: arnd@arndb.de
Cc: hch@lst.de
Cc: hmh@hmh.eng.br
Cc: jgross@suse.com
Cc: konrad.wilk@oracle.com
Cc: linux-mm <linux-mm@kvack.org>
Cc: linux-nvdimm@lists.01.org
Cc: stefan.bader@canonical.com
Cc: yigal@plexistor.com
Link: http://lkml.kernel.org/r/1433436928-31903-8-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | Documentation/x86/pat.txt | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/io.h | 2 | ||||
-rw-r--r-- | arch/x86/mm/ioremap.c | 21 | ||||
-rw-r--r-- | include/asm-generic/io.h | 9 | ||||
-rw-r--r-- | include/asm-generic/iomap.h | 4 |
5 files changed, 39 insertions, 1 deletions
diff --git a/Documentation/x86/pat.txt b/Documentation/x86/pat.txt index 521bd8adc3b8..db0de6cfc351 100644 --- a/Documentation/x86/pat.txt +++ b/Documentation/x86/pat.txt | |||
@@ -12,7 +12,7 @@ virtual addresses. | |||
12 | 12 | ||
13 | PAT allows for different types of memory attributes. The most commonly used | 13 | PAT allows for different types of memory attributes. The most commonly used |
14 | ones that will be supported at this time are Write-back, Uncached, | 14 | ones that will be supported at this time are Write-back, Uncached, |
15 | Write-combined and Uncached Minus. | 15 | Write-combined, Write-through and Uncached Minus. |
16 | 16 | ||
17 | 17 | ||
18 | PAT APIs | 18 | PAT APIs |
@@ -40,6 +40,8 @@ ioremap_nocache | -- | UC- | UC- | | |||
40 | | | | | | 40 | | | | | |
41 | ioremap_wc | -- | -- | WC | | 41 | ioremap_wc | -- | -- | WC | |
42 | | | | | | 42 | | | | | |
43 | ioremap_wt | -- | -- | WT | | ||
44 | | | | | | ||
43 | set_memory_uc | UC- | -- | -- | | 45 | set_memory_uc | UC- | -- | -- | |
44 | set_memory_wb | | | | | 46 | set_memory_wb | | | | |
45 | | | | | | 47 | | | | | |
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index a94463063b46..83ec9b1d77cc 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h | |||
@@ -35,6 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #define ARCH_HAS_IOREMAP_WC | 37 | #define ARCH_HAS_IOREMAP_WC |
38 | #define ARCH_HAS_IOREMAP_WT | ||
38 | 39 | ||
39 | #include <linux/string.h> | 40 | #include <linux/string.h> |
40 | #include <linux/compiler.h> | 41 | #include <linux/compiler.h> |
@@ -320,6 +321,7 @@ extern void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); | |||
320 | extern int ioremap_change_attr(unsigned long vaddr, unsigned long size, | 321 | extern int ioremap_change_attr(unsigned long vaddr, unsigned long size, |
321 | enum page_cache_mode pcm); | 322 | enum page_cache_mode pcm); |
322 | extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size); | 323 | extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size); |
324 | extern void __iomem *ioremap_wt(resource_size_t offset, unsigned long size); | ||
323 | 325 | ||
324 | extern bool is_early_ioremap_ptep(pte_t *ptep); | 326 | extern bool is_early_ioremap_ptep(pte_t *ptep); |
325 | 327 | ||
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index cc0f17c5ad9f..07cd46a8f30a 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c | |||
@@ -172,6 +172,10 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr, | |||
172 | prot = __pgprot(pgprot_val(prot) | | 172 | prot = __pgprot(pgprot_val(prot) | |
173 | cachemode2protval(_PAGE_CACHE_MODE_WC)); | 173 | cachemode2protval(_PAGE_CACHE_MODE_WC)); |
174 | break; | 174 | break; |
175 | case _PAGE_CACHE_MODE_WT: | ||
176 | prot = __pgprot(pgprot_val(prot) | | ||
177 | cachemode2protval(_PAGE_CACHE_MODE_WT)); | ||
178 | break; | ||
175 | case _PAGE_CACHE_MODE_WB: | 179 | case _PAGE_CACHE_MODE_WB: |
176 | break; | 180 | break; |
177 | } | 181 | } |
@@ -297,6 +301,23 @@ void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size) | |||
297 | } | 301 | } |
298 | EXPORT_SYMBOL(ioremap_wc); | 302 | EXPORT_SYMBOL(ioremap_wc); |
299 | 303 | ||
304 | /** | ||
305 | * ioremap_wt - map memory into CPU space write through | ||
306 | * @phys_addr: bus address of the memory | ||
307 | * @size: size of the resource to map | ||
308 | * | ||
309 | * This version of ioremap ensures that the memory is marked write through. | ||
310 | * Write through stores data into memory while keeping the cache up-to-date. | ||
311 | * | ||
312 | * Must be freed with iounmap. | ||
313 | */ | ||
314 | void __iomem *ioremap_wt(resource_size_t phys_addr, unsigned long size) | ||
315 | { | ||
316 | return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WT, | ||
317 | __builtin_return_address(0)); | ||
318 | } | ||
319 | EXPORT_SYMBOL(ioremap_wt); | ||
320 | |||
300 | void __iomem *ioremap_cache(resource_size_t phys_addr, unsigned long size) | 321 | void __iomem *ioremap_cache(resource_size_t phys_addr, unsigned long size) |
301 | { | 322 | { |
302 | return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WB, | 323 | return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WB, |
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 90ccba7f9f9a..f56094cfdeff 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h | |||
@@ -785,8 +785,17 @@ static inline void __iomem *ioremap_wc(phys_addr_t offset, size_t size) | |||
785 | } | 785 | } |
786 | #endif | 786 | #endif |
787 | 787 | ||
788 | #ifndef ioremap_wt | ||
789 | #define ioremap_wt ioremap_wt | ||
790 | static inline void __iomem *ioremap_wt(phys_addr_t offset, size_t size) | ||
791 | { | ||
792 | return ioremap_nocache(offset, size); | ||
793 | } | ||
794 | #endif | ||
795 | |||
788 | #ifndef iounmap | 796 | #ifndef iounmap |
789 | #define iounmap iounmap | 797 | #define iounmap iounmap |
798 | |||
790 | static inline void iounmap(void __iomem *addr) | 799 | static inline void iounmap(void __iomem *addr) |
791 | { | 800 | { |
792 | } | 801 | } |
diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h index 1b41011643a5..d8f8622fa044 100644 --- a/include/asm-generic/iomap.h +++ b/include/asm-generic/iomap.h | |||
@@ -66,6 +66,10 @@ extern void ioport_unmap(void __iomem *); | |||
66 | #define ioremap_wc ioremap_nocache | 66 | #define ioremap_wc ioremap_nocache |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #ifndef ARCH_HAS_IOREMAP_WT | ||
70 | #define ioremap_wt ioremap_nocache | ||
71 | #endif | ||
72 | |||
69 | #ifdef CONFIG_PCI | 73 | #ifdef CONFIG_PCI |
70 | /* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */ | 74 | /* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */ |
71 | struct pci_dev; | 75 | struct pci_dev; |