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>
14 #include <asm/tlbflush.h>
16 #define PG_dcache_clean PG_arch_1
18 void flush_dcache_folio(struct folio *folio)
20 struct address_space *mapping;
22 if (is_zero_pfn(folio_pfn(folio)))
25 mapping = folio_flush_mapping(folio);
27 if (mapping && !folio_mapped(folio))
28 clear_bit(PG_dcache_clean, &folio->flags);
33 set_bit(PG_dcache_clean, &folio->flags);
36 EXPORT_SYMBOL(flush_dcache_folio);
38 void flush_dcache_page(struct page *page)
40 flush_dcache_folio(page_folio(page));
42 EXPORT_SYMBOL(flush_dcache_page);
44 void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
45 unsigned long addr, pte_t *ptep, unsigned int nr)
47 unsigned long pfn = pte_pfn(*ptep);
50 flush_tlb_page(vma, addr);
58 folio = page_folio(pfn_to_page(pfn));
59 if (!test_and_set_bit(PG_dcache_clean, &folio->flags))
62 if (folio_flush_mapping(folio)) {
63 if (vma->vm_flags & VM_EXEC)
68 void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
73 if (vma->vm_flags & VM_EXEC)