Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Toshi Kani and committed by
Ingo Molnar
d838270e ecb2feba

+39 -1
+3 -1
Documentation/x86/pat.txt
··· 12 12 13 13 PAT allows for different types of memory attributes. The most commonly used 14 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 18 PAT APIs ··· 39 39 ioremap_nocache | -- | UC- | UC- | 40 40 | | | | 41 41 ioremap_wc | -- | -- | WC | 42 + | | | | 43 + ioremap_wt | -- | -- | WT | 42 44 | | | | 43 45 set_memory_uc | UC- | -- | -- | 44 46 set_memory_wb | | | |
+2
arch/x86/include/asm/io.h
··· 35 35 */ 36 36 37 37 #define ARCH_HAS_IOREMAP_WC 38 + #define ARCH_HAS_IOREMAP_WT 38 39 39 40 #include <linux/string.h> 40 41 #include <linux/compiler.h> ··· 321 320 extern int ioremap_change_attr(unsigned long vaddr, unsigned long size, 322 321 enum page_cache_mode pcm); 323 322 extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size); 323 + extern void __iomem *ioremap_wt(resource_size_t offset, unsigned long size); 324 324 325 325 extern bool is_early_ioremap_ptep(pte_t *ptep); 326 326
+21
arch/x86/mm/ioremap.c
··· 172 172 prot = __pgprot(pgprot_val(prot) | 173 173 cachemode2protval(_PAGE_CACHE_MODE_WC)); 174 174 break; 175 + case _PAGE_CACHE_MODE_WT: 176 + prot = __pgprot(pgprot_val(prot) | 177 + cachemode2protval(_PAGE_CACHE_MODE_WT)); 178 + break; 175 179 case _PAGE_CACHE_MODE_WB: 176 180 break; 177 181 } ··· 300 296 __builtin_return_address(0)); 301 297 } 302 298 EXPORT_SYMBOL(ioremap_wc); 299 + 300 + /** 301 + * ioremap_wt - map memory into CPU space write through 302 + * @phys_addr: bus address of the memory 303 + * @size: size of the resource to map 304 + * 305 + * This version of ioremap ensures that the memory is marked write through. 306 + * Write through stores data into memory while keeping the cache up-to-date. 307 + * 308 + * Must be freed with iounmap. 309 + */ 310 + void __iomem *ioremap_wt(resource_size_t phys_addr, unsigned long size) 311 + { 312 + return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WT, 313 + __builtin_return_address(0)); 314 + } 315 + EXPORT_SYMBOL(ioremap_wt); 303 316 304 317 void __iomem *ioremap_cache(resource_size_t phys_addr, unsigned long size) 305 318 {
+9
include/asm-generic/io.h
··· 785 785 } 786 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 796 #ifndef iounmap 789 797 #define iounmap iounmap 798 + 790 799 static inline void iounmap(void __iomem *addr) 791 800 { 792 801 }
+4
include/asm-generic/iomap.h
··· 66 66 #define ioremap_wc ioremap_nocache 67 67 #endif 68 68 69 + #ifndef ARCH_HAS_IOREMAP_WT 70 + #define ioremap_wt ioremap_nocache 71 + #endif 72 + 69 73 #ifdef CONFIG_PCI 70 74 /* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */ 71 75 struct pci_dev;