lib_ppc: rework the flush_cache
PATCH 1/1 lib_ppc: rework the flush_cache
- It is possible to miss flush/invalidate the last cache line, we fix it at here.
- add the volatile and memory clobber.
They are pointed by Scott Wood.
Signed-off-by Dave Liu <[email protected]>
--- lib_ppc/cache.c | 36 +++++++++++++++++------------------- 1 files changed, 17 insertions(+), 19 deletions(-)
lib_ppc/cache.c +17 -19
@@ -25,29 +25,27 @@#include <asm/cache.h> #include <watchdog.h> -void flush_cache (ulong start_addr,ulong size) +void flush_cache (ulong start_addr,ulong size) {#ifndef CONFIG_5xx -ulong addr, end_addr = start_addr + size; +ulong addr, start, end; -if (CONFIG_SYS_CACHELINE_SIZE ) { - addr = start_addr & (CONFIG_SYS_CACHELINE_SIZE -1 ); -for (addr = start_addr; - addr < end_addr; - addr +=CONFIG_SYS_CACHELINE_SIZE ) { - asm ("dcbst 0,%0" : :"r" (addr)); -WATCHDOG_RESET (); - } - asm ("sync" );/* Wait for all dcbst to complete on bus */ + start = start_addr & ~(CONFIG_SYS_CACHELINE_SIZE -1 ); + end = start_addr + size -1 ; -for (addr = start_addr; - addr < end_addr; - addr +=CONFIG_SYS_CACHELINE_SIZE ) { - asm ("icbi 0,%0" : :"r" (addr)); -WATCHDOG_RESET (); - } +for (addr = start; addr <= end; addr +=CONFIG_SYS_CACHELINE_SIZE ) { + asmvolatile ("dcbst 0,%0" : :"r" (addr) :"memory" ); +WATCHDOG_RESET (); } - asm ("sync" );/* Always flush prefetch queue in any case */ - asm ("isync" ); +/* wait for all dcbst to complete on bus */ + asmvolatile ("sync" : : :"memory" ); + +for (addr = start; addr <= end; addr +=CONFIG_SYS_CACHELINE_SIZE ) { + asmvolatile ("icbi 0,%0" : :"r" (addr) :"memory" ); +WATCHDOG_RESET (); + } + asmvolatile ("sync" : : :"memory" ); +/* flush prefetch queue */ + asmvolatile ("isync" : : :"memory" );#endif }
Signature · 1 line
1.5.4
Wolfgang Denk
AppliedPATCH 1/1 lib_ppc: rework the flush_cache
Dear Dave Liu,
Quoted 10 lines · In message <[email protected]> you wrote:
- It is possible to miss flush/invalidate the last cache line, we fix it at here.
- add the volatile and memory clobber.They are pointed by Scott Wood.
Signed-off-by Dave Liu <[email protected]>--- lib_ppc/cache.c | 36 +++++++++++++++++------------------- 1 files changed, 17 insertions(+), 19 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If I can have honesty, it's easier to overlook mistakes. -- Kirk, "Space Seed", stardate 3141.9