• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#include <linux/linkage.h>
2
3#define ENDPIPROC(x)			\
4	.globl	__pi_##x;		\
5	.type 	__pi_##x, %function;	\
6	.set	__pi_##x, x;		\
7	.size	__pi_##x, . - x;	\
8	ENDPROC(x)
9
10/*
11 *	cedar_dma_flush_range(start, size)
12 *
13 *	clean & invalidate D / U line
14 *
15 *	- start   - virtual start address of region
16 *	- size    - size in question
17 */
18
19#if IS_ENABLED(CONFIG_ARM64)
20#if IS_ENABLED(CONFIG_ARM64_SW_TTBR0_PAN)
21SYM_FUNC_START(cedar_dma_flush_range)
22    mrs	x4, DAIF
23    msr	DAIFSet, #2
24    mrs	x2, SP_EL0
25    ldr	x2, [x2, #16]
26    mrs	x3, TTBR1_EL1
27    extr	x3, x3, x2, #48
28    ror	x3, x3, #16
29    msr	TTBR1_EL1, x3
30    isb
31    msr	TTBR0_EL1, x2
32    isb
33    msr	DAIF, x4
34    mrs	x3, CTR_EL0
35    nop
36    ubfx	x3, x3, #16, #4
37    mov	x2, #4
38    lsl	x2, x2, x3
39    add	x1, x0, x1
40    sub	x3, x2, #1
41    bic	x0, x0, x3
42    dc	civac, x0
43    add	x0, x0, x2
44    cmp	x0, x1
45    b.lo	#-12
46    dsb	sy
47    mrs	x2, DAIF
48    msr	DAIFSet, #2
49    mrs	x1, TTBR1_EL1
50    and	x1, x1, #0xffffffffffff
51    sub	x1, x1, #1, lsl #12
52    msr	TTBR0_EL1, x1
53    isb
54    add	x1, x1, #1, lsl #12
55    msr	TTBR1_EL1, x1
56    isb
57    msr	DAIF, x2
58    ret
59SYM_FUNC_END(cedar_dma_flush_range)
60#else
61SYM_FUNC_START(cedar_dma_flush_range)
62       mrs     x3, ctr_el0
63       nop
64       ubfx    x3, x3, #16, #4
65       mov     x2, #0x4                        // #4
66       lsl     x2, x2, x3
67       add     x1, x0, x1
68       sub     x3, x2, #0x1
69       bic     x0, x0, x3
70start:
71       dc      civac, x0
72       add     x0, x0, x2
73       cmp     x0, x1
74       b.cc start
75       dsb     sy
76       ret
77       nop
78       nop
79SYM_FUNC_END(cedar_dma_flush_range)
80#endif
81#endif
82