help, trying to invalidate entire icache on 970

Chris Friesen cfriesen at
Wed Apr 6 08:15:46 EST 2005

Linas Vepstas wrote:

> In general, the caches tend to be n-way set associative. So
> invalidating a given cache line will invalidate only one of 
> the n ways.  This might explain why you first attempt didn't work. 
> I don't know what n is for the 970.  Typically is 2 or 4 for this class
> of cpu. It tends to vary from one model to another.

The icache is direct mapped, but is indexed by four bits in the 
effective address such that a given physical address can be aliased to 
16 positions in the cache.

> Which "4 bits" are involved tends to vary from one core to another.
> Even if you found somethingthat worked on the 970, it might not work on
> the next generation, since the address lines would be wired differntly.
> Similar remarks apply for the assumption that theres only 16 or 32 cache
> blocks or lines or whatever ... 

Right.  This whole chunk of code is 970-specific.  We have other code 
for other cpus (the 74xx for instance can flash-invalidate the whole 
icache with one instruction).

> I'm not sure I know what en_icbi is (have never scanned the 970 docs).
> Maybe its invalidating all cache lines that alias to the same address
> tag.

Yep.  I'm trying to figure those aliasing patterns out so I can minimize 
the number of icbi calls needed.

> Why, again, is it that you can't just call icbi with the address of the
> instruction that has been changed? 

I have a pre-existing app that modifies itself and doesn't track the 
addresses.  All I get is the app telling me "I just modified something." 
  Thus, I have to flush the entire dcache, and invalidate the entire 
icache in order to ensure that the new code gets run.  It's horribly 
kludgy I know, but that's what I've got to deal with.


More information about the Linuxppc64-dev mailing list