.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * This file contains miscellaneous low-level functions. |
---|
3 | 4 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) |
---|
.. | .. |
---|
6 | 7 | * and Paul Mackerras. |
---|
7 | 8 | * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com) |
---|
8 | 9 | * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com) |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or |
---|
11 | | - * modify it under the terms of the GNU General Public License |
---|
12 | | - * as published by the Free Software Foundation; either version |
---|
13 | | - * 2 of the License, or (at your option) any later version. |
---|
14 | | - * |
---|
15 | 10 | */ |
---|
16 | 11 | |
---|
17 | 12 | #include <linux/sys.h> |
---|
.. | .. |
---|
32 | 27 | |
---|
33 | 28 | .text |
---|
34 | 29 | |
---|
35 | | -#ifndef CONFIG_PREEMPT_RT_FULL |
---|
| 30 | +#ifndef CONFIG_PREEMPT_RT |
---|
36 | 31 | _GLOBAL(call_do_softirq) |
---|
37 | 32 | mflr r0 |
---|
38 | 33 | std r0,16(r1) |
---|
.. | .. |
---|
54 | 49 | ld r1,0(r1) |
---|
55 | 50 | ld r0,16(r1) |
---|
56 | 51 | mtlr r0 |
---|
57 | | - blr |
---|
58 | | - |
---|
59 | | - .section ".toc","aw" |
---|
60 | | -PPC64_CACHES: |
---|
61 | | - .tc ppc64_caches[TC],ppc64_caches |
---|
62 | | - .section ".text" |
---|
63 | | - |
---|
64 | | -/* |
---|
65 | | - * Write any modified data cache blocks out to memory |
---|
66 | | - * and invalidate the corresponding instruction cache blocks. |
---|
67 | | - * |
---|
68 | | - * flush_icache_range(unsigned long start, unsigned long stop) |
---|
69 | | - * |
---|
70 | | - * flush all bytes from start through stop-1 inclusive |
---|
71 | | - */ |
---|
72 | | - |
---|
73 | | -_GLOBAL_TOC(flush_icache_range) |
---|
74 | | -BEGIN_FTR_SECTION |
---|
75 | | - PURGE_PREFETCHED_INS |
---|
76 | | - blr |
---|
77 | | -END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) |
---|
78 | | -/* |
---|
79 | | - * Flush the data cache to memory |
---|
80 | | - * |
---|
81 | | - * Different systems have different cache line sizes |
---|
82 | | - * and in some cases i-cache and d-cache line sizes differ from |
---|
83 | | - * each other. |
---|
84 | | - */ |
---|
85 | | - ld r10,PPC64_CACHES@toc(r2) |
---|
86 | | - lwz r7,DCACHEL1BLOCKSIZE(r10)/* Get cache block size */ |
---|
87 | | - addi r5,r7,-1 |
---|
88 | | - andc r6,r3,r5 /* round low to line bdy */ |
---|
89 | | - subf r8,r6,r4 /* compute length */ |
---|
90 | | - add r8,r8,r5 /* ensure we get enough */ |
---|
91 | | - lwz r9,DCACHEL1LOGBLOCKSIZE(r10) /* Get log-2 of cache block size */ |
---|
92 | | - srd. r8,r8,r9 /* compute line count */ |
---|
93 | | - beqlr /* nothing to do? */ |
---|
94 | | - mtctr r8 |
---|
95 | | -1: dcbst 0,r6 |
---|
96 | | - add r6,r6,r7 |
---|
97 | | - bdnz 1b |
---|
98 | | - sync |
---|
99 | | - |
---|
100 | | -/* Now invalidate the instruction cache */ |
---|
101 | | - |
---|
102 | | - lwz r7,ICACHEL1BLOCKSIZE(r10) /* Get Icache block size */ |
---|
103 | | - addi r5,r7,-1 |
---|
104 | | - andc r6,r3,r5 /* round low to line bdy */ |
---|
105 | | - subf r8,r6,r4 /* compute length */ |
---|
106 | | - add r8,r8,r5 |
---|
107 | | - lwz r9,ICACHEL1LOGBLOCKSIZE(r10) /* Get log-2 of Icache block size */ |
---|
108 | | - srd. r8,r8,r9 /* compute line count */ |
---|
109 | | - beqlr /* nothing to do? */ |
---|
110 | | - mtctr r8 |
---|
111 | | -2: icbi 0,r6 |
---|
112 | | - add r6,r6,r7 |
---|
113 | | - bdnz 2b |
---|
114 | | - isync |
---|
115 | | - blr |
---|
116 | | -_ASM_NOKPROBE_SYMBOL(flush_icache_range) |
---|
117 | | -EXPORT_SYMBOL(flush_icache_range) |
---|
118 | | - |
---|
119 | | -/* |
---|
120 | | - * Like above, but only do the D-cache. |
---|
121 | | - * |
---|
122 | | - * flush_dcache_range(unsigned long start, unsigned long stop) |
---|
123 | | - * |
---|
124 | | - * flush all bytes from start to stop-1 inclusive |
---|
125 | | - */ |
---|
126 | | -_GLOBAL_TOC(flush_dcache_range) |
---|
127 | | - |
---|
128 | | -/* |
---|
129 | | - * Flush the data cache to memory |
---|
130 | | - * |
---|
131 | | - * Different systems have different cache line sizes |
---|
132 | | - */ |
---|
133 | | - ld r10,PPC64_CACHES@toc(r2) |
---|
134 | | - lwz r7,DCACHEL1BLOCKSIZE(r10) /* Get dcache block size */ |
---|
135 | | - addi r5,r7,-1 |
---|
136 | | - andc r6,r3,r5 /* round low to line bdy */ |
---|
137 | | - subf r8,r6,r4 /* compute length */ |
---|
138 | | - add r8,r8,r5 /* ensure we get enough */ |
---|
139 | | - lwz r9,DCACHEL1LOGBLOCKSIZE(r10) /* Get log-2 of dcache block size */ |
---|
140 | | - srd. r8,r8,r9 /* compute line count */ |
---|
141 | | - beqlr /* nothing to do? */ |
---|
142 | | - mtctr r8 |
---|
143 | | -0: dcbst 0,r6 |
---|
144 | | - add r6,r6,r7 |
---|
145 | | - bdnz 0b |
---|
146 | | - sync |
---|
147 | | - blr |
---|
148 | | -EXPORT_SYMBOL(flush_dcache_range) |
---|
149 | | - |
---|
150 | | -_GLOBAL(flush_inval_dcache_range) |
---|
151 | | - ld r10,PPC64_CACHES@toc(r2) |
---|
152 | | - lwz r7,DCACHEL1BLOCKSIZE(r10) /* Get dcache block size */ |
---|
153 | | - addi r5,r7,-1 |
---|
154 | | - andc r6,r3,r5 /* round low to line bdy */ |
---|
155 | | - subf r8,r6,r4 /* compute length */ |
---|
156 | | - add r8,r8,r5 /* ensure we get enough */ |
---|
157 | | - lwz r9,DCACHEL1LOGBLOCKSIZE(r10)/* Get log-2 of dcache block size */ |
---|
158 | | - srd. r8,r8,r9 /* compute line count */ |
---|
159 | | - beqlr /* nothing to do? */ |
---|
160 | | - sync |
---|
161 | | - isync |
---|
162 | | - mtctr r8 |
---|
163 | | -0: dcbf 0,r6 |
---|
164 | | - add r6,r6,r7 |
---|
165 | | - bdnz 0b |
---|
166 | | - sync |
---|
167 | | - isync |
---|
168 | | - blr |
---|
169 | | - |
---|
170 | | - |
---|
171 | | -/* |
---|
172 | | - * Flush a particular page from the data cache to RAM. |
---|
173 | | - * Note: this is necessary because the instruction cache does *not* |
---|
174 | | - * snoop from the data cache. |
---|
175 | | - * |
---|
176 | | - * void __flush_dcache_icache(void *page) |
---|
177 | | - */ |
---|
178 | | -_GLOBAL(__flush_dcache_icache) |
---|
179 | | -/* |
---|
180 | | - * Flush the data cache to memory |
---|
181 | | - * |
---|
182 | | - * Different systems have different cache line sizes |
---|
183 | | - */ |
---|
184 | | - |
---|
185 | | -BEGIN_FTR_SECTION |
---|
186 | | - PURGE_PREFETCHED_INS |
---|
187 | | - blr |
---|
188 | | -END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) |
---|
189 | | - |
---|
190 | | -/* Flush the dcache */ |
---|
191 | | - ld r7,PPC64_CACHES@toc(r2) |
---|
192 | | - clrrdi r3,r3,PAGE_SHIFT /* Page align */ |
---|
193 | | - lwz r4,DCACHEL1BLOCKSPERPAGE(r7) /* Get # dcache blocks per page */ |
---|
194 | | - lwz r5,DCACHEL1BLOCKSIZE(r7) /* Get dcache block size */ |
---|
195 | | - mr r6,r3 |
---|
196 | | - mtctr r4 |
---|
197 | | -0: dcbst 0,r6 |
---|
198 | | - add r6,r6,r5 |
---|
199 | | - bdnz 0b |
---|
200 | | - sync |
---|
201 | | - |
---|
202 | | -/* Now invalidate the icache */ |
---|
203 | | - |
---|
204 | | - lwz r4,ICACHEL1BLOCKSPERPAGE(r7) /* Get # icache blocks per page */ |
---|
205 | | - lwz r5,ICACHEL1BLOCKSIZE(r7) /* Get icache block size */ |
---|
206 | | - mtctr r4 |
---|
207 | | -1: icbi 0,r3 |
---|
208 | | - add r3,r3,r5 |
---|
209 | | - bdnz 1b |
---|
210 | | - isync |
---|
211 | 52 | blr |
---|
212 | 53 | |
---|
213 | 54 | _GLOBAL(__bswapdi2) |
---|
.. | .. |
---|
491 | 332 | rlwimi r9,r10,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r9) */ |
---|
492 | 333 | |
---|
493 | 334 | /* Set up a temp identity mapping v:0 to p:0 and return to it. */ |
---|
494 | | -#if defined(CONFIG_SMP) || defined(CONFIG_PPC_E500MC) |
---|
495 | | -#define M_IF_NEEDED MAS2_M |
---|
496 | | -#else |
---|
497 | | -#define M_IF_NEEDED 0 |
---|
498 | | -#endif |
---|
499 | 335 | mtspr SPRN_MAS0,r9 |
---|
500 | 336 | |
---|
501 | 337 | lis r9,(MAS1_VALID|MAS1_IPROT)@h |
---|
502 | 338 | ori r9,r9,(MAS1_TSIZE(BOOK3E_PAGESZ_1GB))@l |
---|
503 | 339 | mtspr SPRN_MAS1,r9 |
---|
504 | 340 | |
---|
505 | | - LOAD_REG_IMMEDIATE(r9, 0x0 | M_IF_NEEDED) |
---|
| 341 | + LOAD_REG_IMMEDIATE(r9, 0x0 | MAS2_M_IF_NEEDED) |
---|
506 | 342 | mtspr SPRN_MAS2,r9 |
---|
507 | 343 | |
---|
508 | 344 | LOAD_REG_IMMEDIATE(r9, 0x0 | MAS3_SR | MAS3_SW | MAS3_SX) |
---|
.. | .. |
---|
531 | 367 | |
---|
532 | 368 | li r4,KEXEC_STATE_REAL_MODE |
---|
533 | 369 | stb r4,PACAKEXECSTATE(r13) |
---|
534 | | - SYNC |
---|
535 | 370 | |
---|
536 | 371 | b kexec_wait |
---|
537 | 372 | |
---|
.. | .. |
---|
578 | 413 | |
---|
579 | 414 | li r0,0 |
---|
580 | 415 | std r0,16(r1) |
---|
581 | | - |
---|
582 | | -BEGIN_FTR_SECTION |
---|
583 | | - /* |
---|
584 | | - * This is the best time to turn AMR/IAMR off. |
---|
585 | | - * key 0 is used in radix for supervisor<->user |
---|
586 | | - * protection, but on hash key 0 is reserved |
---|
587 | | - * ideally we want to enter with a clean state. |
---|
588 | | - * NOTE, we rely on r0 being 0 from above. |
---|
589 | | - */ |
---|
590 | | - mtspr SPRN_IAMR,r0 |
---|
591 | | -BEGIN_FTR_SECTION_NESTED(42) |
---|
592 | | - mtspr SPRN_AMOR,r0 |
---|
593 | | -END_FTR_SECTION_NESTED_IFSET(CPU_FTR_HVMODE, 42) |
---|
594 | | -END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300) |
---|
595 | 416 | |
---|
596 | 417 | /* save regs for local vars on new stack. |
---|
597 | 418 | * yes, we won't go back, but ... |
---|