Skip to content

Commit

Permalink
arm64: remove unnecessary cache flush at boot
Browse files Browse the repository at this point in the history
Currently we flush the entire dcache at boot within __cpu_setup, but
this is unnecessary as the booting protocol demands that the dcache is
invalid and off upon entering the kernel. The presence of the cache
flush only serves to hide bugs in bootloaders, and is not safe in the
presence of SMP.

In an SMP boot scenario the CPUs enter coherency outside of the kernel,
and the primary CPU enables its caches before bringing up secondary
CPUs. Therefore if any secondary CPU has an entry in its cache (in
violation of the boot protocol), the primary CPU might snoop it even if
the secondary CPU's cache is disabled. The boot-time cache flush only
serves to hide a firmware bug, and slows down a cpu boot unnecessarily.

This patch removes the unnecessary boot-time cache flush.

Signed-off-by: Mark Rutland <[email protected]>
Acked-by: Will Deacon <[email protected]>
[[email protected]: make __flush_dcache_all local only]
Signed-off-by: Catalin Marinas <[email protected]>
  • Loading branch information
Mark Rutland authored and ctmarinas committed Mar 4, 2014
1 parent addea9e commit bff7059
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/mm/cache.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* Corrupted registers: x0-x7, x9-x11
*/
ENTRY(__flush_dcache_all)
__flush_dcache_all:
dsb sy // ensure ordering with previous memory accesses
mrs x0, clidr_el1 // read clidr
and x3, x0, #0x7000000 // extract loc from clidr
Expand Down
6 changes: 0 additions & 6 deletions arch/arm64/mm/proc.S
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ ENDPROC(cpu_do_switch_mm)
* value of the SCTLR_EL1 register.
*/
ENTRY(__cpu_setup)
/*
* Preserve the link register across the function call.
*/
mov x28, lr
bl __flush_dcache_all
mov lr, x28
ic iallu // I+BTB cache invalidate
tlbi vmalle1is // invalidate I + D TLBs
dsb sy
Expand Down

0 comments on commit bff7059

Please sign in to comment.