lib_ppc: rework the flush_cache
A message that is not in the archive (sent off-list or not yet received): 79C363B768933F4FB918025FF7EB888856A042@zch01exm21.fsl.freescale.net
PATCH 1/1 lib_ppc: rework the flush_cache
Quoted 11 lines · Liu Dave
The
lib_ppcversion basically is as below.
voidflush_cache(ulongstart_addr, ulong size){ ulong addr, end_addr = start_addr + 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)); } }so, you are not completely right, the flush is from
start_addr.
Ah, right, the first addr assignment is just dead code.
Quoted 4 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ start = start_addr & ~(CONFIG_SYS_CACHELINE_SIZE - 1); + end = (start_addr + size) & ~(CONFIG_SYS_CACHELINE_SIZE - 1);end =
start_addr+ size - 1;
Quoted 8 lines
Quoted 6 lines
The rounding is unnecessary for end, and without the - 1, if
start_addr+ size is on a cacheline boundary, you'll flush one cache line too many (which might not be mapped, or might cause end to wrap around to zero if flushing at the end of the address space).I don't see what is the problem in my patch at here.
start_addr = 0
size = 0x1000
start will be 0
end will be 0x1000
The loop will flush the cache line at 0x1000, because it uses <= rather than <. That is outside the area that was requested to be flushed. Maybe it's not mapped. Or, maybe start + size = 0 and nothing gets flushed.
-Scott
PATCH 1/1 lib_ppc: rework the flush_cache
Quoted 8 lines
start_addr= 0
size =0x1000start will be 0
end will be0x1000The loop will flush the cache line at
0x1000, because it uses <= rather than <. That is outside the area that was requested to be
flushed.
Quoted 1 line
Maybe it's not mapped. Or, maybe start + size = 0 and > nothing gets
flushed.
thanks, I got it.
it was off-one error.