[PATCH 5/6] Use MTRR for write combining ioremap
From: Thomas Schlichter
Date: Sat Oct 17 2009 - 15:29:43 EST
If PAT is not enabled, set up write combining MTRR entries in ioremap().
Signed-off-by: Thomas Schlichter <thomas.schlichter@xxxxxx>
---
arch/x86/mm/ioremap.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 334e63c..abe40fa 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -21,6 +21,7 @@
#include <asm/tlbflush.h>
#include <asm/pgalloc.h>
#include <asm/pat.h>
+#include <asm/mtrr.h>
#include "physaddr.h"
@@ -268,11 +269,15 @@ EXPORT_SYMBOL(ioremap_nocache);
*/
void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size)
{
- if (pat_enabled)
- return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC,
- __builtin_return_address(0));
- else
- return ioremap_nocache(phys_addr, size);
+ if (!pat_enabled) {
+ void __iomem *ret = ioremap_nocache(phys_addr, size);
+ if (ret)
+ mtrr_add_unaligned(phys_addr, size,
+ MTRR_TYPE_WRCOMB, false);
+ return ret;
+ }
+ return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC,
+ __builtin_return_address(0));
}
EXPORT_SYMBOL(ioremap_wc);
--
1.6.5
--Boundary-00=_U+h2K2gddSw6RDO
Content-Type: text/x-patch;
charset="iso-8859-1";
name="0001-Add-new-mtrr_add_unaligned-function.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="0001-Add-new-mtrr_add_unaligned-function.patch"