treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / csky / abiv1 / cacheflush.c
blob9f1fe80cc8473663b8a5556ab82b3cda592d91a8
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/kernel.h>
5 #include <linux/mm.h>
6 #include <linux/fs.h>
7 #include <linux/syscalls.h>
8 #include <linux/spinlock.h>
9 #include <asm/page.h>
10 #include <asm/cache.h>
11 #include <asm/cacheflush.h>
12 #include <asm/cachectl.h>
14 #define PG_dcache_clean PG_arch_1
16 void flush_dcache_page(struct page *page)
18 struct address_space *mapping;
20 if (page == ZERO_PAGE(0))
21 return;
23 mapping = page_mapping_file(page);
25 if (mapping && !page_mapcount(page))
26 clear_bit(PG_dcache_clean, &page->flags);
27 else {
28 dcache_wbinv_all();
29 if (mapping)
30 icache_inv_all();
31 set_bit(PG_dcache_clean, &page->flags);
34 EXPORT_SYMBOL(flush_dcache_page);
36 void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
37 pte_t *ptep)
39 unsigned long pfn = pte_pfn(*ptep);
40 struct page *page;
42 if (!pfn_valid(pfn))
43 return;
45 page = pfn_to_page(pfn);
46 if (page == ZERO_PAGE(0))
47 return;
49 if (!test_and_set_bit(PG_dcache_clean, &page->flags))
50 dcache_wbinv_all();
52 if (page_mapping_file(page)) {
53 if (vma->vm_flags & VM_EXEC)
54 icache_inv_all();
58 void flush_kernel_dcache_page(struct page *page)
60 struct address_space *mapping;
62 mapping = page_mapping_file(page);
64 if (!mapping || mapping_mapped(mapping))
65 dcache_wbinv_all();
67 EXPORT_SYMBOL(flush_kernel_dcache_page);
69 void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
70 unsigned long end)
72 dcache_wbinv_all();
74 if (vma->vm_flags & VM_EXEC)
75 icache_inv_all();