1 // SPDX-License-Identifier: GPL-2.0-only
3 * Cache management functions for Hexagon
5 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
9 #include <asm/cacheflush.h>
10 #include <asm/hexagon_vm.h>
12 #define spanlines(start, end) \
13 (((end - (start & ~(LINESIZE - 1))) >> LINEBITS) + 1)
15 void flush_dcache_range(unsigned long start
, unsigned long end
)
17 unsigned long lines
= spanlines(start
, end
-1);
18 unsigned long i
, flags
;
20 start
&= ~(LINESIZE
- 1);
22 local_irq_save(flags
);
24 for (i
= 0; i
< lines
; i
++) {
25 __asm__
__volatile__ (
32 local_irq_restore(flags
);
35 void flush_icache_range(unsigned long start
, unsigned long end
)
37 unsigned long lines
= spanlines(start
, end
-1);
38 unsigned long i
, flags
;
40 start
&= ~(LINESIZE
- 1);
42 local_irq_save(flags
);
44 for (i
= 0; i
< lines
; i
++) {
45 __asm__
__volatile__ (
53 __asm__
__volatile__ (
56 local_irq_restore(flags
);
58 EXPORT_SYMBOL(flush_icache_range
);
60 void hexagon_clean_dcache_range(unsigned long start
, unsigned long end
)
62 unsigned long lines
= spanlines(start
, end
-1);
63 unsigned long i
, flags
;
65 start
&= ~(LINESIZE
- 1);
67 local_irq_save(flags
);
69 for (i
= 0; i
< lines
; i
++) {
70 __asm__
__volatile__ (
77 local_irq_restore(flags
);
80 void hexagon_inv_dcache_range(unsigned long start
, unsigned long end
)
82 unsigned long lines
= spanlines(start
, end
-1);
83 unsigned long i
, flags
;
85 start
&= ~(LINESIZE
- 1);
87 local_irq_save(flags
);
89 for (i
= 0; i
< lines
; i
++) {
90 __asm__
__volatile__ (
97 local_irq_restore(flags
);
104 * This is just really brutal and shouldn't be used anyways,
105 * especially on V2. Left here just in case.
107 void flush_cache_all_hexagon(void)
110 local_irq_save(flags
);
114 local_irq_restore(flags
);
118 void copy_to_user_page(struct vm_area_struct
*vma
, struct page
*page
,
119 unsigned long vaddr
, void *dst
, void *src
, int len
)
121 memcpy(dst
, src
, len
);
122 if (vma
->vm_flags
& VM_EXEC
) {
123 flush_icache_range((unsigned long) dst
,
124 (unsigned long) dst
+ len
);