From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerry Van Baren Date: Fri, 06 Feb 2009 08:59:53 -0500 Subject: [U-Boot] powerpc flush_cache() roll over bug In-Reply-To: <9EFEF05A-9413-4DF9-9C0F-D6A2D77A401D@kernel.crashing.org> References: <9EFEF05A-9413-4DF9-9C0F-D6A2D77A401D@kernel.crashing.org> Message-ID: <498C4259.2080904@ge.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Kumar Gala wrote: > My brian stopped working but I figured I'd send my issue and hopefully > I'll wake up and someone will have a solution for me. Talk about sweet dreams! :-D > The problem is we can call flush_cache(0xfffff000, 0x1000) which will > never exit the loop: > > void flush_cache(ulong start_addr, ulong size) > { > #ifndef CONFIG_5xx > ulong addr, start; > u64 end; > > start = start_addr & ~(CONFIG_SYS_CACHELINE_SIZE - 1); > end = start_addr + size - 1; > > for (addr = start; addr <= end; addr += > CONFIG_SYS_CACHELINE_SIZE) { > asm volatile("dcbst 0,%0" : : "r" (addr) : "memory"); > WATCHDOG_RESET(); > } > ... > > since end = 0xffffffff. There are some other situations (like > flush_cache(0, 0)) that cause similar issues, but less concerned about > that. > > Any suggestions on how to best to re-write the code to correctly > handle flush_cache(0xfffff000, 0x1000) are welcome. You could do a range check between start and end: for (addr = start; (addr <= end) && (addr >= start); addr += CONFIG_SYS_CACHELINE_SIZE) { Best regards, gvb