[patch 11/13] x86: PAT Add set_memory_wc() interface

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: venkatesh.pallipadi
Date: Tuesday, March 18, 2008 - 5:00 pm

Add a set_memory_wc interface(), similar to set_memory_uc interface.
Callers has to call set_memory_uc, set_memory_wb and
set_memory_wc, set_memory_wb as pairs.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>

Index: linux-2.6-x86.git/arch/x86/mm/pageattr.c
===================================================================
--- linux-2.6-x86.git.orig/arch/x86/mm/pageattr.c	2008-03-18 03:23:49.000000000 -0700
+++ linux-2.6-x86.git/arch/x86/mm/pageattr.c	2008-03-18 03:53:45.000000000 -0700
@@ -788,6 +788,25 @@
 }
 EXPORT_SYMBOL(set_memory_uc);
 
+int _set_memory_wc(unsigned long addr, int numpages)
+{
+	return change_page_attr_set(addr, numpages,
+				    __pgprot(_PAGE_CACHE_WC));
+}
+
+int set_memory_wc(unsigned long addr, int numpages)
+{
+	if (!pat_wc_enabled)
+		return set_memory_uc(addr, numpages);
+
+	if (reserve_memtype(addr, addr + numpages * PAGE_SIZE,
+		_PAGE_CACHE_WC, NULL))
+		return -EINVAL;
+
+	return _set_memory_wc(addr, numpages);
+}
+EXPORT_SYMBOL(set_memory_wc);
+
 int _set_memory_wb(unsigned long addr, int numpages)
 {
 	return change_page_attr_clear(addr, numpages,
Index: linux-2.6-x86.git/include/asm-x86/cacheflush.h
===================================================================
--- linux-2.6-x86.git.orig/include/asm-x86/cacheflush.h	2008-03-18 03:21:25.000000000 -0700
+++ linux-2.6-x86.git/include/asm-x86/cacheflush.h	2008-03-18 03:53:45.000000000 -0700
@@ -35,8 +35,10 @@
 int set_pages_rw(struct page *page, int numpages);
 
 int _set_memory_uc(unsigned long addr, int numpages);
+int _set_memory_wc(unsigned long addr, int numpages);
 int _set_memory_wb(unsigned long addr, int numpages);
 int set_memory_uc(unsigned long addr, int numpages);
+int set_memory_wc(unsigned long addr, int numpages);
 int set_memory_wb(unsigned long addr, int numpages);
 int set_memory_x(unsigned long addr, int numpages);
 int set_memory_nx(unsigned long addr, int numpages);

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 11/13] x86: PAT Add set_memory_wc() interface, venkatesh.pallipadi, (Tue Mar 18, 5:00 pm)