Guo Ren | 00a9730 | 2018-09-05 14:25:10 +0800 | [diff] [blame] | 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 | |
Guo Ren | 00a9730 | 2018-09-05 14:25:10 +0800 | [diff] [blame] | 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; |
Guo Ren | 00a9730 | 2018-09-05 14:25:10 +0800 | [diff] [blame] | 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 | |
Guo Ren | 981bbf2 | 2019-04-10 10:55:07 +0800 | [diff] [blame] | 23 | addr = (unsigned long) kmap_atomic(page); |
Guo Ren | 00a9730 | 2018-09-05 14:25:10 +0800 | [diff] [blame] | 24 | |
| 25 | cache_wbinv_range(addr, addr + PAGE_SIZE); |
| 26 | |
Guo Ren | 981bbf2 | 2019-04-10 10:55:07 +0800 | [diff] [blame] | 27 | kunmap_atomic((void *) addr); |
Guo Ren | 00a9730 | 2018-09-05 14:25:10 +0800 | [diff] [blame] | 28 | } |