blob: 4a674db4e1fa5eae93b7a09b851c530d721d5815 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
Olivier Deprez157378f2022-04-04 15:47:50 +02002#ifndef _ASM_GENERIC_CACHEFLUSH_H
3#define _ASM_GENERIC_CACHEFLUSH_H
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00004
Olivier Deprez157378f2022-04-04 15:47:50 +02005struct mm_struct;
6struct vm_area_struct;
7struct page;
8struct address_space;
David Brazdil0f672f62019-12-10 10:32:29 +00009
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000010/*
11 * The cache doesn't need to be flushed when TLB entries change when
12 * the cache is mapped to physical memory, not virtual memory
13 */
Olivier Deprez0e641232021-09-23 10:07:05 +020014#ifndef flush_cache_all
David Brazdil0f672f62019-12-10 10:32:29 +000015static inline void flush_cache_all(void)
16{
17}
Olivier Deprez0e641232021-09-23 10:07:05 +020018#endif
David Brazdil0f672f62019-12-10 10:32:29 +000019
Olivier Deprez0e641232021-09-23 10:07:05 +020020#ifndef flush_cache_mm
David Brazdil0f672f62019-12-10 10:32:29 +000021static inline void flush_cache_mm(struct mm_struct *mm)
22{
23}
Olivier Deprez0e641232021-09-23 10:07:05 +020024#endif
David Brazdil0f672f62019-12-10 10:32:29 +000025
Olivier Deprez0e641232021-09-23 10:07:05 +020026#ifndef flush_cache_dup_mm
David Brazdil0f672f62019-12-10 10:32:29 +000027static inline void flush_cache_dup_mm(struct mm_struct *mm)
28{
29}
Olivier Deprez0e641232021-09-23 10:07:05 +020030#endif
David Brazdil0f672f62019-12-10 10:32:29 +000031
Olivier Deprez0e641232021-09-23 10:07:05 +020032#ifndef flush_cache_range
David Brazdil0f672f62019-12-10 10:32:29 +000033static inline void flush_cache_range(struct vm_area_struct *vma,
34 unsigned long start,
35 unsigned long end)
36{
37}
Olivier Deprez0e641232021-09-23 10:07:05 +020038#endif
David Brazdil0f672f62019-12-10 10:32:29 +000039
Olivier Deprez0e641232021-09-23 10:07:05 +020040#ifndef flush_cache_page
David Brazdil0f672f62019-12-10 10:32:29 +000041static inline void flush_cache_page(struct vm_area_struct *vma,
42 unsigned long vmaddr,
43 unsigned long pfn)
44{
45}
Olivier Deprez0e641232021-09-23 10:07:05 +020046#endif
David Brazdil0f672f62019-12-10 10:32:29 +000047
Olivier Deprez157378f2022-04-04 15:47:50 +020048#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
David Brazdil0f672f62019-12-10 10:32:29 +000049static inline void flush_dcache_page(struct page *page)
50{
51}
Olivier Deprez157378f2022-04-04 15:47:50 +020052#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
Olivier Deprez0e641232021-09-23 10:07:05 +020053#endif
David Brazdil0f672f62019-12-10 10:32:29 +000054
Olivier Deprez157378f2022-04-04 15:47:50 +020055
Olivier Deprez0e641232021-09-23 10:07:05 +020056#ifndef flush_dcache_mmap_lock
David Brazdil0f672f62019-12-10 10:32:29 +000057static inline void flush_dcache_mmap_lock(struct address_space *mapping)
58{
59}
Olivier Deprez0e641232021-09-23 10:07:05 +020060#endif
David Brazdil0f672f62019-12-10 10:32:29 +000061
Olivier Deprez0e641232021-09-23 10:07:05 +020062#ifndef flush_dcache_mmap_unlock
David Brazdil0f672f62019-12-10 10:32:29 +000063static inline void flush_dcache_mmap_unlock(struct address_space *mapping)
64{
65}
Olivier Deprez0e641232021-09-23 10:07:05 +020066#endif
David Brazdil0f672f62019-12-10 10:32:29 +000067
Olivier Deprez0e641232021-09-23 10:07:05 +020068#ifndef flush_icache_range
David Brazdil0f672f62019-12-10 10:32:29 +000069static inline void flush_icache_range(unsigned long start, unsigned long end)
70{
71}
Olivier Deprez0e641232021-09-23 10:07:05 +020072#endif
David Brazdil0f672f62019-12-10 10:32:29 +000073
Olivier Deprez157378f2022-04-04 15:47:50 +020074#ifndef flush_icache_user_range
75#define flush_icache_user_range flush_icache_range
76#endif
77
Olivier Deprez0e641232021-09-23 10:07:05 +020078#ifndef flush_icache_page
David Brazdil0f672f62019-12-10 10:32:29 +000079static inline void flush_icache_page(struct vm_area_struct *vma,
80 struct page *page)
81{
82}
Olivier Deprez0e641232021-09-23 10:07:05 +020083#endif
David Brazdil0f672f62019-12-10 10:32:29 +000084
Olivier Deprez157378f2022-04-04 15:47:50 +020085#ifndef flush_icache_user_page
86static inline void flush_icache_user_page(struct vm_area_struct *vma,
David Brazdil0f672f62019-12-10 10:32:29 +000087 struct page *page,
88 unsigned long addr, int len)
89{
90}
Olivier Deprez0e641232021-09-23 10:07:05 +020091#endif
David Brazdil0f672f62019-12-10 10:32:29 +000092
Olivier Deprez0e641232021-09-23 10:07:05 +020093#ifndef flush_cache_vmap
David Brazdil0f672f62019-12-10 10:32:29 +000094static inline void flush_cache_vmap(unsigned long start, unsigned long end)
95{
96}
Olivier Deprez0e641232021-09-23 10:07:05 +020097#endif
David Brazdil0f672f62019-12-10 10:32:29 +000098
Olivier Deprez0e641232021-09-23 10:07:05 +020099#ifndef flush_cache_vunmap
David Brazdil0f672f62019-12-10 10:32:29 +0000100static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
101{
102}
Olivier Deprez0e641232021-09-23 10:07:05 +0200103#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000104
Olivier Deprez0e641232021-09-23 10:07:05 +0200105#ifndef copy_to_user_page
106#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000107 do { \
108 memcpy(dst, src, len); \
Olivier Deprez157378f2022-04-04 15:47:50 +0200109 flush_icache_user_page(vma, page, vaddr, len); \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000110 } while (0)
Olivier Deprez0e641232021-09-23 10:07:05 +0200111#endif
112
113#ifndef copy_from_user_page
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000114#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
115 memcpy(dst, src, len)
Olivier Deprez0e641232021-09-23 10:07:05 +0200116#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000117
Olivier Deprez157378f2022-04-04 15:47:50 +0200118#endif /* _ASM_GENERIC_CACHEFLUSH_H */