[MIPS] Implement flush_anon_page().

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

+29 -3
+15 -1
arch/mips/mm/cache.c
··· 3 * License. See the file "COPYING" in the main directory of this archive 4 * for more details. 5 * 6 - * Copyright (C) 1994 - 2003 by Ralf Baechle 7 */ 8 #include <linux/init.h> 9 #include <linux/kernel.h> ··· 88 } 89 90 EXPORT_SYMBOL(__flush_dcache_page); 91 92 void __update_cache(struct vm_area_struct *vma, unsigned long address, 93 pte_t pte)
··· 3 * License. See the file "COPYING" in the main directory of this archive 4 * for more details. 5 * 6 + * Copyright (C) 1994 - 2003, 07 by Ralf Baechle (ralf@linux-mips.org) 7 + * Copyright (C) 2007 MIPS Technologies, Inc. 8 */ 9 #include <linux/init.h> 10 #include <linux/kernel.h> ··· 87 } 88 89 EXPORT_SYMBOL(__flush_dcache_page); 90 + 91 + void __flush_anon_page(struct page *page, unsigned long vmaddr) 92 + { 93 + if (pages_do_alias((unsigned long)page_address(page), vmaddr)) { 94 + void *kaddr; 95 + 96 + kaddr = kmap_coherent(page, vmaddr); 97 + flush_data_cache_page((unsigned long)kaddr); 98 + kunmap_coherent(kaddr); 99 + } 100 + } 101 + 102 + EXPORT_SYMBOL(__flush_anon_page); 103 104 void __update_cache(struct vm_area_struct *vma, unsigned long address, 105 pte_t pte)
+2 -2
arch/mips/mm/init.c
··· 123 static inline void kmap_coherent_init(void) {} 124 #endif 125 126 - static inline void *kmap_coherent(struct page *page, unsigned long addr) 127 { 128 enum fixed_addresses idx; 129 unsigned long vaddr, flags, entrylo; ··· 177 178 #define UNIQUE_ENTRYHI(idx) (CKSEG0 + ((idx) << (PAGE_SHIFT + 1))) 179 180 - static inline void kunmap_coherent(struct page *page) 181 { 182 #ifndef CONFIG_MIPS_MT_SMTC 183 unsigned int wired;
··· 123 static inline void kmap_coherent_init(void) {} 124 #endif 125 126 + void *kmap_coherent(struct page *page, unsigned long addr) 127 { 128 enum fixed_addresses idx; 129 unsigned long vaddr, flags, entrylo; ··· 177 178 #define UNIQUE_ENTRYHI(idx) (CKSEG0 + ((idx) << (PAGE_SHIFT + 1))) 179 180 + void kunmap_coherent(struct page *page) 181 { 182 #ifndef CONFIG_MIPS_MT_SMTC 183 unsigned int wired;
+12
include/asm-mips/cacheflush.h
··· 48 #define flush_dcache_mmap_lock(mapping) do { } while (0) 49 #define flush_dcache_mmap_unlock(mapping) do { } while (0) 50 51 static inline void flush_icache_page(struct vm_area_struct *vma, 52 struct page *page) 53 { ··· 94 95 /* Run kernel code uncached, useful for cache probing functions. */ 96 unsigned long __init run_uncached(void *func); 97 98 #endif /* _ASM_CACHEFLUSH_H */
··· 48 #define flush_dcache_mmap_lock(mapping) do { } while (0) 49 #define flush_dcache_mmap_unlock(mapping) do { } while (0) 50 51 + #define ARCH_HAS_FLUSH_ANON_PAGE 52 + extern void __flush_anon_page(struct page *, unsigned long); 53 + static inline void flush_anon_page(struct vm_area_struct *vma, 54 + struct page *page, unsigned long vmaddr) 55 + { 56 + if (cpu_has_dc_aliases && PageAnon(page)) 57 + __flush_anon_page(page, vmaddr); 58 + } 59 + 60 static inline void flush_icache_page(struct vm_area_struct *vma, 61 struct page *page) 62 { ··· 85 86 /* Run kernel code uncached, useful for cache probing functions. */ 87 unsigned long __init run_uncached(void *func); 88 + 89 + extern void *kmap_coherent(struct page *page, unsigned long addr); 90 + extern void kunmap_coherent(struct page *page); 91 92 #endif /* _ASM_CACHEFLUSH_H */