[PATCH] [12/48] Suspend2 2.1.9.8 for 2.6.12: 402-mtrr-remove-sysdev.patch

Nigel Cunningham
2005-07-06T02:22:00Z

diff -ruNp 403-debug-pagealloc-support.patch-old/arch/i386/mm/pageattr.c 403-debug-pagealloc-support.patch-new/arch/i386/mm/pageattr.c
--- 403-debug-pagealloc-support.patch-old/arch/i386/mm/pageattr.c 2005-06-20 11:46:43.000000000 +1000
+++ 403-debug-pagealloc-support.patch-new/arch/i386/mm/pageattr.c 2005-07-04 23:14:19.000000000 +1000
@@ -217,5 +217,46 @@ void kernel_map_pages(struct page *page,
}
#endif

+#ifdef CONFIG_SUSPEND2
+#ifdef CONFIG_DEBUG_PAGEALLOC
+static int page_is_kernel_mapped(struct page * page)
+{
+ pte_t *kpte;
+ unsigned long address;
+
+ if (PageHighMem(page))
+ return 0;
+
+ address = (unsigned long)page_address(page);
+
+ kpte = lookup_address(address);
+ if (!kpte)
+ return 0;
+
+ if (pte_same(*kpte, mk_pte(page, PAGE_KERNEL)))
+ return 1;
+
+ return 0;
+}
+
+int suspend_map_kernel_page(struct page * page, int enable)
+{
+ int is_already_mapped = page_is_kernel_mapped(page);
+
+ if (enable == is_already_mapped)
+ return 1;
+
+ kernel_map_pages(page, 1, enable);
+
+ return 0;
+}
+#else
+int suspend_map_kernel_page(struct page * page, int enable)
+{
+ return (enable == 1);
+}
+#endif
+#endif
+
EXPORT_SYMBOL(change_page_attr);
EXPORT_SYMBOL(global_flush_tlb);