1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/kernel.h>
7 #include <linux/pagemap.h>
8 #include <linux/syscalls.h>
9 #include <linux/spinlock.h>
11 #include <asm/cache.h>
12 #include <asm/cacheflush.h>
13 #include <asm/cachectl.h>
15 #define PG_dcache_clean PG_arch_1
17 void flush_dcache_page(struct page *page)
19 struct address_space *mapping;
21 if (page == ZERO_PAGE(0))
24 mapping = page_mapping_file(page);
26 if (mapping && !page_mapcount(page))
27 clear_bit(PG_dcache_clean, &page->flags);
32 set_bit(PG_dcache_clean, &page->flags);
35 EXPORT_SYMBOL(flush_dcache_page);
37 void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
40 unsigned long pfn = pte_pfn(*ptep);
46 page = pfn_to_page(pfn);
47 if (page == ZERO_PAGE(0))
50 if (!test_and_set_bit(PG_dcache_clean, &page->flags))
53 if (page_mapping_file(page)) {
54 if (vma->vm_flags & VM_EXEC)
59 void flush_kernel_dcache_page(struct page *page)
61 struct address_space *mapping;
63 mapping = page_mapping_file(page);
65 if (!mapping || mapping_mapped(mapping))
68 EXPORT_SYMBOL(flush_kernel_dcache_page);
70 void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
75 if (vma->vm_flags & VM_EXEC)