Skip to content

Commit d838270

Browse files
Toshi Kaniingomolnar
authored andcommitted
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>
1 parent ecb2feb commit d838270

5 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎Documentation/x86/pat.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ virtual addresses.
1212

1313
PAT allows for different types of memory attributes. The most commonly used
1414
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.
1616

1717

1818
PAT APIs
@@ -40,6 +40,8 @@ ioremap_nocache | -- | UC- | UC- |
4040
| | | |
4141
ioremap_wc | -- | -- | WC |
4242
| | | |
43+
ioremap_wt | -- | -- | WT |
44+
| | | |
4345
set_memory_uc | UC- | -- | -- |
4446
set_memory_wb | | | |
4547
| | | |

‎arch/x86/include/asm/io.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*/
3636

3737
#define ARCH_HAS_IOREMAP_WC
38+
#define ARCH_HAS_IOREMAP_WT
3839

3940
#include <linux/string.h>
4041
#include <linux/compiler.h>
@@ -320,6 +321,7 @@ extern void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
320321
extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
321322
enum page_cache_mode pcm);
322323
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);
323325

324326
extern bool is_early_ioremap_ptep(pte_t *ptep);
325327

‎arch/x86/mm/ioremap.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
172172
prot = __pgprot(pgprot_val(prot) |
173173
cachemode2protval(_PAGE_CACHE_MODE_WC));
174174
break;
175+
case _PAGE_CACHE_MODE_WT:
176+
prot = __pgprot(pgprot_val(prot) |
177+
cachemode2protval(_PAGE_CACHE_MODE_WT));
178+
break;
175179
case _PAGE_CACHE_MODE_WB:
176180
break;
177181
}
@@ -297,6 +301,23 @@ void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size)
297301
}
298302
EXPORT_SYMBOL(ioremap_wc);
299303

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+
300321
void __iomem *ioremap_cache(resource_size_t phys_addr, unsigned long size)
301322
{
302323
return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WB,

‎include/asm-generic/io.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,17 @@ static inline void __iomem *ioremap_wc(phys_addr_t offset, size_t size)
785785
}
786786
#endif
787787

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+
788796
#ifndef iounmap
789797
#define iounmap iounmap
798+
790799
static inline void iounmap(void __iomem *addr)
791800
{
792801
}

‎include/asm-generic/iomap.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ extern void ioport_unmap(void __iomem *);
6666
#define ioremap_wc ioremap_nocache
6767
#endif
6868

69+
#ifndef ARCH_HAS_IOREMAP_WT
70+
#define ioremap_wt ioremap_nocache
71+
#endif
72+
6973
#ifdef CONFIG_PCI
7074
/* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */
7175
struct pci_dev;

0 commit comments

Comments
 (0)