mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 00:34:52 +00:00

Instead of flushing cache per update_mmu_cache() called, we use flush_dcache_page to reduce the frequency of flashing the cache. As abiv2 cpus are all PIPT for icache & dcache, we needn't handle dcache aliasing problem. But their icache can't snoop dcache, so we still need sync_icache_dcache in update_mmu_cache(). Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
30 lines
665 B
C
30 lines
665 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
|
|
|
|
#include <linux/cache.h>
|
|
#include <linux/highmem.h>
|
|
#include <linux/mm.h>
|
|
#include <asm/cache.h>
|
|
|
|
void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
|
|
pte_t *pte)
|
|
{
|
|
unsigned long addr;
|
|
struct page *page;
|
|
|
|
page = pfn_to_page(pte_pfn(*pte));
|
|
if (page == ZERO_PAGE(0))
|
|
return;
|
|
|
|
if (test_and_set_bit(PG_dcache_clean, &page->flags))
|
|
return;
|
|
|
|
addr = (unsigned long) kmap_atomic(page);
|
|
|
|
dcache_wb_range(addr, addr + PAGE_SIZE);
|
|
|
|
if (vma->vm_flags & VM_EXEC)
|
|
icache_inv_range(addr, addr + PAGE_SIZE);
|
|
|
|
kunmap_atomic((void *) addr);
|
|
}
|