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

x86/mm/pat: Remove pat_enabled() checks

Now that we emulate a PAT table when PAT is disabled, there's no
need for those checks anymore as the PAT abstraction will handle
those cases too.

Based on a conglomerate patch from Toshi Kani.

Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Toshi Kani <toshi.kani@hp.com>
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-4-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Borislav Petkov and committed by
Ingo Molnar
7202fdb1 9cd25aac

+10 -23
+6 -6
arch/x86/mm/iomap_32.c
··· 77 77 iomap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot) 78 78 { 79 79 /* 80 - * For non-PAT systems, promote PAGE_KERNEL_WC to PAGE_KERNEL_UC_MINUS. 81 - * PAGE_KERNEL_WC maps to PWT, which translates to uncached if the 82 - * MTRR is UC or WC. UC_MINUS gets the real intention, of the 83 - * user, which is "WC if the MTRR is WC, UC if you can't do that." 80 + * For non-PAT systems, translate non-WB request to UC- just in 81 + * case the caller set the PWT bit to prot directly without using 82 + * pgprot_writecombine(). UC- translates to uncached if the MTRR 83 + * is UC or WC. UC- gets the real intention, of the user, which is 84 + * "WC if the MTRR is WC, UC if you can't do that." 84 85 */ 85 - if (!pat_enabled() && pgprot_val(prot) == 86 - (__PAGE_KERNEL | cachemode2protval(_PAGE_CACHE_MODE_WC))) 86 + if (!pat_enabled() && pgprot2cachemode(prot) != _PAGE_CACHE_MODE_WB) 87 87 prot = __pgprot(__PAGE_KERNEL | 88 88 cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS)); 89 89
+1 -4
arch/x86/mm/ioremap.c
··· 292 292 */ 293 293 void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size) 294 294 { 295 - if (pat_enabled()) 296 - return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WC, 295 + return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WC, 297 296 __builtin_return_address(0)); 298 - else 299 - return ioremap_nocache(phys_addr, size); 300 297 } 301 298 EXPORT_SYMBOL(ioremap_wc); 302 299
-3
arch/x86/mm/pageattr.c
··· 1572 1572 { 1573 1573 int ret; 1574 1574 1575 - if (!pat_enabled()) 1576 - return set_memory_uc(addr, numpages); 1577 - 1578 1575 ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE, 1579 1576 _PAGE_CACHE_MODE_WC, NULL); 1580 1577 if (ret)
+3 -10
arch/x86/mm/pat.c
··· 438 438 439 439 if (!pat_enabled()) { 440 440 /* This is identical to page table setting without PAT */ 441 - if (new_type) { 442 - if (req_type == _PAGE_CACHE_MODE_WC) 443 - *new_type = _PAGE_CACHE_MODE_UC_MINUS; 444 - else 445 - *new_type = req_type; 446 - } 441 + if (new_type) 442 + *new_type = req_type; 447 443 return 0; 448 444 } 449 445 ··· 943 947 944 948 pgprot_t pgprot_writecombine(pgprot_t prot) 945 949 { 946 - if (pat_enabled()) 947 - return __pgprot(pgprot_val(prot) | 950 + return __pgprot(pgprot_val(prot) | 948 951 cachemode2protval(_PAGE_CACHE_MODE_WC)); 949 - else 950 - return pgprot_noncached(prot); 951 952 } 952 953 EXPORT_SYMBOL_GPL(pgprot_writecombine); 953 954