arm64: Use PoU cache instr for I/D coherency
In systems with three levels of cache(PoU at L1 and PoC at L3), PoC cache flush instructions flushes L2 and L3 caches which could affect performance. For cache flushes for I and D coherency, PoU should suffice. So changing all I and D coherency related cache flushes to PoU. Introduced a new __clean_dcache_area_pou API for dcache flush till PoU and provided a common macro for __flush_dcache_area and __clean_dcache_area_pou. Also, now in __sync_icache_dcache, icache invalidation for non-aliasing VIPT icache is done only for that particular page instead of the earlier __flush_icache_all. Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Ashok Kumar <ashoks@broadcom.com> Signed-off-by: Will Deacon <will.deacon@arm.com> (cherry picked from commit 0a28714c53fd4f7aea709be7577dfbe0095c8c3e) Signed-off-by: Alex Shi <alex.shi@linaro.org> Conflicts: arch/arm64/mm/proc-macros.S
This commit is contained in:
parent
03fb711099
commit
b67b1ab417
4 changed files with 57 additions and 26 deletions
|
@ -68,6 +68,7 @@
|
||||||
extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
|
extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
|
||||||
extern void flush_icache_range(unsigned long start, unsigned long end);
|
extern void flush_icache_range(unsigned long start, unsigned long end);
|
||||||
extern void __flush_dcache_area(void *addr, size_t len);
|
extern void __flush_dcache_area(void *addr, size_t len);
|
||||||
|
extern void __clean_dcache_area_pou(void *addr, size_t len);
|
||||||
extern long __flush_cache_user_range(unsigned long start, unsigned long end);
|
extern long __flush_cache_user_range(unsigned long start, unsigned long end);
|
||||||
|
|
||||||
static inline void flush_cache_mm(struct mm_struct *mm)
|
static inline void flush_cache_mm(struct mm_struct *mm)
|
||||||
|
|
|
@ -81,25 +81,31 @@ ENDPROC(__flush_cache_user_range)
|
||||||
/*
|
/*
|
||||||
* __flush_dcache_area(kaddr, size)
|
* __flush_dcache_area(kaddr, size)
|
||||||
*
|
*
|
||||||
* Ensure that the data held in the page kaddr is written back to the
|
* Ensure that any D-cache lines for the interval [kaddr, kaddr+size)
|
||||||
* page in question.
|
* are cleaned and invalidated to the PoC.
|
||||||
*
|
*
|
||||||
* - kaddr - kernel address
|
* - kaddr - kernel address
|
||||||
* - size - size in question
|
* - size - size in question
|
||||||
*/
|
*/
|
||||||
ENTRY(__flush_dcache_area)
|
ENTRY(__flush_dcache_area)
|
||||||
dcache_line_size x2, x3
|
dcache_by_line_op civac, sy, x0, x1, x2, x3
|
||||||
add x1, x0, x1
|
|
||||||
sub x3, x2, #1
|
|
||||||
bic x0, x0, x3
|
|
||||||
1: dc civac, x0 // clean & invalidate D line / unified line
|
|
||||||
add x0, x0, x2
|
|
||||||
cmp x0, x1
|
|
||||||
b.lo 1b
|
|
||||||
dsb sy
|
|
||||||
ret
|
ret
|
||||||
ENDPIPROC(__flush_dcache_area)
|
ENDPIPROC(__flush_dcache_area)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* __clean_dcache_area_pou(kaddr, size)
|
||||||
|
*
|
||||||
|
* Ensure that any D-cache lines for the interval [kaddr, kaddr+size)
|
||||||
|
* are cleaned to the PoU.
|
||||||
|
*
|
||||||
|
* - kaddr - kernel address
|
||||||
|
* - size - size in question
|
||||||
|
*/
|
||||||
|
ENTRY(__clean_dcache_area_pou)
|
||||||
|
dcache_by_line_op cvau, ish, x0, x1, x2, x3
|
||||||
|
ret
|
||||||
|
ENDPROC(__clean_dcache_area_pou)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* __inval_cache_range(start, end)
|
* __inval_cache_range(start, end)
|
||||||
* - start - start address of region
|
* - start - start address of region
|
||||||
|
|
|
@ -34,19 +34,24 @@ void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
|
||||||
__flush_icache_all();
|
__flush_icache_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sync_icache_aliases(void *kaddr, unsigned long len)
|
||||||
|
{
|
||||||
|
unsigned long addr = (unsigned long)kaddr;
|
||||||
|
|
||||||
|
if (icache_is_aliasing()) {
|
||||||
|
__clean_dcache_area_pou(kaddr, len);
|
||||||
|
__flush_icache_all();
|
||||||
|
} else {
|
||||||
|
flush_icache_range(addr, addr + len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
|
static void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
|
||||||
unsigned long uaddr, void *kaddr,
|
unsigned long uaddr, void *kaddr,
|
||||||
unsigned long len)
|
unsigned long len)
|
||||||
{
|
{
|
||||||
if (vma->vm_flags & VM_EXEC) {
|
if (vma->vm_flags & VM_EXEC)
|
||||||
unsigned long addr = (unsigned long)kaddr;
|
sync_icache_aliases(kaddr, len);
|
||||||
if (icache_is_aliasing()) {
|
|
||||||
__flush_dcache_area(kaddr, len);
|
|
||||||
__flush_icache_all();
|
|
||||||
} else {
|
|
||||||
flush_icache_range(addr, addr + len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -74,13 +79,11 @@ void __sync_icache_dcache(pte_t pte, unsigned long addr)
|
||||||
if (!page_mapping(page))
|
if (!page_mapping(page))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!test_and_set_bit(PG_dcache_clean, &page->flags)) {
|
if (!test_and_set_bit(PG_dcache_clean, &page->flags))
|
||||||
__flush_dcache_area(page_address(page),
|
sync_icache_aliases(page_address(page),
|
||||||
PAGE_SIZE << compound_order(page));
|
PAGE_SIZE << compound_order(page));
|
||||||
|
else if (icache_is_aivivt())
|
||||||
__flush_icache_all();
|
__flush_icache_all();
|
||||||
} else if (icache_is_aivivt()) {
|
|
||||||
__flush_icache_all();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -74,3 +74,24 @@
|
||||||
msr pmuserenr_el0, xzr // Disable PMU access from EL0
|
msr pmuserenr_el0, xzr // Disable PMU access from EL0
|
||||||
9000:
|
9000:
|
||||||
.endm
|
.endm
|
||||||
|
/*
|
||||||
|
* Macro to perform a data cache maintenance for the interval
|
||||||
|
* [kaddr, kaddr + size)
|
||||||
|
*
|
||||||
|
* op: operation passed to dc instruction
|
||||||
|
* domain: domain used in dsb instruciton
|
||||||
|
* kaddr: starting virtual address of the region
|
||||||
|
* size: size of the region
|
||||||
|
* Corrupts: kaddr, size, tmp1, tmp2
|
||||||
|
*/
|
||||||
|
.macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2
|
||||||
|
dcache_line_size \tmp1, \tmp2
|
||||||
|
add \size, \kaddr, \size
|
||||||
|
sub \tmp2, \tmp1, #1
|
||||||
|
bic \kaddr, \kaddr, \tmp2
|
||||||
|
9998: dc \op, \kaddr
|
||||||
|
add \kaddr, \kaddr, \tmp1
|
||||||
|
cmp \kaddr, \size
|
||||||
|
b.lo 9998b
|
||||||
|
dsb \domain
|
||||||
|
.endm
|
||||||
|
|
Loading…
Add table
Reference in a new issue