xref: /openbmc/linux/arch/csky/abiv2/cacheflush.c (revision a1176734)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3 
4 #include <linux/cache.h>
5 #include <linux/highmem.h>
6 #include <linux/mm.h>
7 #include <asm/cache.h>
8 
9 void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
10 		      pte_t *pte)
11 {
12 	unsigned long addr, pfn;
13 	struct page *page;
14 
15 	pfn = pte_pfn(*pte);
16 	if (unlikely(!pfn_valid(pfn)))
17 		return;
18 
19 	page = pfn_to_page(pfn);
20 	if (page == ZERO_PAGE(0))
21 		return;
22 
23 	addr = (unsigned long) kmap_atomic(page);
24 
25 	cache_wbinv_range(addr, addr + PAGE_SIZE);
26 
27 	kunmap_atomic((void *) addr);
28 }
29