1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
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/kernel.h>
9 #include <linux/module.h>
10 #include <linux/sched.h>
11 #include <linux/mm.h>
12 
13 #include <asm/cacheflush.h>
14 
sys_cacheflush(void * addr,int bytes,int cache)15 asmlinkage int sys_cacheflush(void *addr, int bytes, int cache)
16 {
17 	/* This should flush more selectivly ...  */
18 	__flush_cache_all();
19 
20 	return 0;
21 }
22 
flush_dcache_page(struct page * page)23 void flush_dcache_page(struct page *page)
24 {
25 	unsigned long addr;
26 
27 	if (page->mapping && page->mapping->i_mmap == NULL &&
28 	    page->mapping->i_mmap_shared == NULL) {
29 		SetPageDcacheDirty(page);
30 
31 		return;
32 	}
33 
34 	/*
35 	 * We could delay the flush for the !page->mapping case too.  But that
36 	 * case is for exec env/arg pages and those are %99 certainly going to
37 	 * get faulted into the tlb (and thus flushed) anyways.
38 	 */
39 	addr = (unsigned long) page_address(page);
40 	flush_data_cache_page(addr);
41 }
42 
__update_cache(struct vm_area_struct * vma,unsigned long address,pte_t pte)43 void __update_cache(struct vm_area_struct *vma, unsigned long address,
44         pte_t pte)
45 {
46 	struct page *page = pte_page(pte);
47 	unsigned long addr;
48 
49 	if (VALID_PAGE(page) && page->mapping &&
50 	    (page->flags & (1UL << PG_dcache_dirty))) {
51 		if (pages_do_alias((unsigned long) page_address(page), address & PAGE_MASK)) {
52 			addr = (unsigned long) page_address(page);
53 			flush_data_cache_page(addr);
54 		}
55 
56 		ClearPageDcacheDirty(page);
57 	}
58 }
59 
60 EXPORT_SYMBOL(flush_dcache_page);
61