diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-06-30 11:29:12 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-07-18 07:29:04 -0400 |
commit | 6ebbf2ce437b33022d30badd49dc94d33ecfa498 (patch) | |
tree | bc015e35b456a28bb0e501803a454dc0c0d3291a /arch/arm/mm/proc-arm920.S | |
parent | af040ffc9ba1e079ee4c0748aff64fa3d4716fa5 (diff) |
ARM: convert all "mov.* pc, reg" to "bx reg" for ARMv6+
ARMv6 and greater introduced a new instruction ("bx") which can be used
to return from function calls. Recent CPUs perform better when the
"bx lr" instruction is used rather than the "mov pc, lr" instruction,
and this sequence is strongly recommended to be used by the ARM
architecture manual (section A.4.1.1).
We provide a new macro "ret" with all its variants for the condition
code which will resolve to the appropriate instruction.
Rather than doing this piecemeal, and miss some instances, change all
the "mov pc" instances to use the new macro, with the exception of
the "movs" instruction and the kprobes code. This allows us to detect
the "mov pc, lr" case and fix it up - and also gives us the possibility
of deploying this for other registers depending on the CPU selection.
Reported-by: Will Deacon <will.deacon@arm.com>
Tested-by: Stephen Warren <swarren@nvidia.com> # Tegra Jetson TK1
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr> # mioa701_bootresume.S
Tested-by: Andrew Lunn <andrew@lunn.ch> # Kirkwood
Tested-by: Shawn Guo <shawn.guo@freescale.com>
Tested-by: Tony Lindgren <tony@atomide.com> # OMAPs
Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com> # Armada XP, 375, 385
Acked-by: Sekhar Nori <nsekhar@ti.com> # DaVinci
Acked-by: Christoffer Dall <christoffer.dall@linaro.org> # kvm/hyp
Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com> # PXA3xx
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> # Xen
Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> # ARMv7M
Tested-by: Simon Horman <horms+renesas@verge.net.au> # Shmobile
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/proc-arm920.S')
-rw-r--r-- | arch/arm/mm/proc-arm920.S | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S index 549557df6d57..22bf8dde4f84 100644 --- a/arch/arm/mm/proc-arm920.S +++ b/arch/arm/mm/proc-arm920.S | |||
@@ -63,7 +63,7 @@ | |||
63 | * cpu_arm920_proc_init() | 63 | * cpu_arm920_proc_init() |
64 | */ | 64 | */ |
65 | ENTRY(cpu_arm920_proc_init) | 65 | ENTRY(cpu_arm920_proc_init) |
66 | mov pc, lr | 66 | ret lr |
67 | 67 | ||
68 | /* | 68 | /* |
69 | * cpu_arm920_proc_fin() | 69 | * cpu_arm920_proc_fin() |
@@ -73,7 +73,7 @@ ENTRY(cpu_arm920_proc_fin) | |||
73 | bic r0, r0, #0x1000 @ ...i............ | 73 | bic r0, r0, #0x1000 @ ...i............ |
74 | bic r0, r0, #0x000e @ ............wca. | 74 | bic r0, r0, #0x000e @ ............wca. |
75 | mcr p15, 0, r0, c1, c0, 0 @ disable caches | 75 | mcr p15, 0, r0, c1, c0, 0 @ disable caches |
76 | mov pc, lr | 76 | ret lr |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * cpu_arm920_reset(loc) | 79 | * cpu_arm920_reset(loc) |
@@ -97,7 +97,7 @@ ENTRY(cpu_arm920_reset) | |||
97 | bic ip, ip, #0x000f @ ............wcam | 97 | bic ip, ip, #0x000f @ ............wcam |
98 | bic ip, ip, #0x1100 @ ...i...s........ | 98 | bic ip, ip, #0x1100 @ ...i...s........ |
99 | mcr p15, 0, ip, c1, c0, 0 @ ctrl register | 99 | mcr p15, 0, ip, c1, c0, 0 @ ctrl register |
100 | mov pc, r0 | 100 | ret r0 |
101 | ENDPROC(cpu_arm920_reset) | 101 | ENDPROC(cpu_arm920_reset) |
102 | .popsection | 102 | .popsection |
103 | 103 | ||
@@ -107,7 +107,7 @@ ENDPROC(cpu_arm920_reset) | |||
107 | .align 5 | 107 | .align 5 |
108 | ENTRY(cpu_arm920_do_idle) | 108 | ENTRY(cpu_arm920_do_idle) |
109 | mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt | 109 | mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt |
110 | mov pc, lr | 110 | ret lr |
111 | 111 | ||
112 | 112 | ||
113 | #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH | 113 | #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH |
@@ -120,7 +120,7 @@ ENTRY(cpu_arm920_do_idle) | |||
120 | ENTRY(arm920_flush_icache_all) | 120 | ENTRY(arm920_flush_icache_all) |
121 | mov r0, #0 | 121 | mov r0, #0 |
122 | mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache | 122 | mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache |
123 | mov pc, lr | 123 | ret lr |
124 | ENDPROC(arm920_flush_icache_all) | 124 | ENDPROC(arm920_flush_icache_all) |
125 | 125 | ||
126 | /* | 126 | /* |
@@ -151,7 +151,7 @@ __flush_whole_cache: | |||
151 | tst r2, #VM_EXEC | 151 | tst r2, #VM_EXEC |
152 | mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache | 152 | mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache |
153 | mcrne p15, 0, ip, c7, c10, 4 @ drain WB | 153 | mcrne p15, 0, ip, c7, c10, 4 @ drain WB |
154 | mov pc, lr | 154 | ret lr |
155 | 155 | ||
156 | /* | 156 | /* |
157 | * flush_user_cache_range(start, end, flags) | 157 | * flush_user_cache_range(start, end, flags) |
@@ -177,7 +177,7 @@ ENTRY(arm920_flush_user_cache_range) | |||
177 | blo 1b | 177 | blo 1b |
178 | tst r2, #VM_EXEC | 178 | tst r2, #VM_EXEC |
179 | mcrne p15, 0, ip, c7, c10, 4 @ drain WB | 179 | mcrne p15, 0, ip, c7, c10, 4 @ drain WB |
180 | mov pc, lr | 180 | ret lr |
181 | 181 | ||
182 | /* | 182 | /* |
183 | * coherent_kern_range(start, end) | 183 | * coherent_kern_range(start, end) |
@@ -211,7 +211,7 @@ ENTRY(arm920_coherent_user_range) | |||
211 | blo 1b | 211 | blo 1b |
212 | mcr p15, 0, r0, c7, c10, 4 @ drain WB | 212 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
213 | mov r0, #0 | 213 | mov r0, #0 |
214 | mov pc, lr | 214 | ret lr |
215 | 215 | ||
216 | /* | 216 | /* |
217 | * flush_kern_dcache_area(void *addr, size_t size) | 217 | * flush_kern_dcache_area(void *addr, size_t size) |
@@ -231,7 +231,7 @@ ENTRY(arm920_flush_kern_dcache_area) | |||
231 | mov r0, #0 | 231 | mov r0, #0 |
232 | mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache | 232 | mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache |
233 | mcr p15, 0, r0, c7, c10, 4 @ drain WB | 233 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
234 | mov pc, lr | 234 | ret lr |
235 | 235 | ||
236 | /* | 236 | /* |
237 | * dma_inv_range(start, end) | 237 | * dma_inv_range(start, end) |
@@ -257,7 +257,7 @@ arm920_dma_inv_range: | |||
257 | cmp r0, r1 | 257 | cmp r0, r1 |
258 | blo 1b | 258 | blo 1b |
259 | mcr p15, 0, r0, c7, c10, 4 @ drain WB | 259 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
260 | mov pc, lr | 260 | ret lr |
261 | 261 | ||
262 | /* | 262 | /* |
263 | * dma_clean_range(start, end) | 263 | * dma_clean_range(start, end) |
@@ -276,7 +276,7 @@ arm920_dma_clean_range: | |||
276 | cmp r0, r1 | 276 | cmp r0, r1 |
277 | blo 1b | 277 | blo 1b |
278 | mcr p15, 0, r0, c7, c10, 4 @ drain WB | 278 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
279 | mov pc, lr | 279 | ret lr |
280 | 280 | ||
281 | /* | 281 | /* |
282 | * dma_flush_range(start, end) | 282 | * dma_flush_range(start, end) |
@@ -293,7 +293,7 @@ ENTRY(arm920_dma_flush_range) | |||
293 | cmp r0, r1 | 293 | cmp r0, r1 |
294 | blo 1b | 294 | blo 1b |
295 | mcr p15, 0, r0, c7, c10, 4 @ drain WB | 295 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
296 | mov pc, lr | 296 | ret lr |
297 | 297 | ||
298 | /* | 298 | /* |
299 | * dma_map_area(start, size, dir) | 299 | * dma_map_area(start, size, dir) |
@@ -316,7 +316,7 @@ ENDPROC(arm920_dma_map_area) | |||
316 | * - dir - DMA direction | 316 | * - dir - DMA direction |
317 | */ | 317 | */ |
318 | ENTRY(arm920_dma_unmap_area) | 318 | ENTRY(arm920_dma_unmap_area) |
319 | mov pc, lr | 319 | ret lr |
320 | ENDPROC(arm920_dma_unmap_area) | 320 | ENDPROC(arm920_dma_unmap_area) |
321 | 321 | ||
322 | .globl arm920_flush_kern_cache_louis | 322 | .globl arm920_flush_kern_cache_louis |
@@ -332,7 +332,7 @@ ENTRY(cpu_arm920_dcache_clean_area) | |||
332 | add r0, r0, #CACHE_DLINESIZE | 332 | add r0, r0, #CACHE_DLINESIZE |
333 | subs r1, r1, #CACHE_DLINESIZE | 333 | subs r1, r1, #CACHE_DLINESIZE |
334 | bhi 1b | 334 | bhi 1b |
335 | mov pc, lr | 335 | ret lr |
336 | 336 | ||
337 | /* =============================== PageTable ============================== */ | 337 | /* =============================== PageTable ============================== */ |
338 | 338 | ||
@@ -367,7 +367,7 @@ ENTRY(cpu_arm920_switch_mm) | |||
367 | mcr p15, 0, r0, c2, c0, 0 @ load page table pointer | 367 | mcr p15, 0, r0, c2, c0, 0 @ load page table pointer |
368 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs | 368 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs |
369 | #endif | 369 | #endif |
370 | mov pc, lr | 370 | ret lr |
371 | 371 | ||
372 | /* | 372 | /* |
373 | * cpu_arm920_set_pte(ptep, pte, ext) | 373 | * cpu_arm920_set_pte(ptep, pte, ext) |
@@ -382,7 +382,7 @@ ENTRY(cpu_arm920_set_pte_ext) | |||
382 | mcr p15, 0, r0, c7, c10, 1 @ clean D entry | 382 | mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
383 | mcr p15, 0, r0, c7, c10, 4 @ drain WB | 383 | mcr p15, 0, r0, c7, c10, 4 @ drain WB |
384 | #endif | 384 | #endif |
385 | mov pc, lr | 385 | ret lr |
386 | 386 | ||
387 | /* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ | 387 | /* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */ |
388 | .globl cpu_arm920_suspend_size | 388 | .globl cpu_arm920_suspend_size |
@@ -423,7 +423,7 @@ __arm920_setup: | |||
423 | mrc p15, 0, r0, c1, c0 @ get control register v4 | 423 | mrc p15, 0, r0, c1, c0 @ get control register v4 |
424 | bic r0, r0, r5 | 424 | bic r0, r0, r5 |
425 | orr r0, r0, r6 | 425 | orr r0, r0, r6 |
426 | mov pc, lr | 426 | ret lr |
427 | .size __arm920_setup, . - __arm920_setup | 427 | .size __arm920_setup, . - __arm920_setup |
428 | 428 | ||
429 | /* | 429 | /* |