powerpc/32: define helpers to get L1 cache sizes.
This patch defines C helpers to retrieve the size of cache blocks and uses them in the cacheflush functions. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:

committed by
Michael Ellerman

parent
1cfb725fb1
commit
d98fc70fc1
@@ -67,11 +67,13 @@ static inline void __flush_dcache_icache_phys(unsigned long physaddr)
|
||||
*/
|
||||
static inline void flush_dcache_range(unsigned long start, unsigned long stop)
|
||||
{
|
||||
void *addr = (void *)(start & ~(L1_CACHE_BYTES - 1));
|
||||
unsigned long size = stop - (unsigned long)addr + (L1_CACHE_BYTES - 1);
|
||||
unsigned long shift = l1_cache_shift();
|
||||
unsigned long bytes = l1_cache_bytes();
|
||||
void *addr = (void *)(start & ~(bytes - 1));
|
||||
unsigned long size = stop - (unsigned long)addr + (bytes - 1);
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < size >> L1_CACHE_SHIFT; i++, addr += L1_CACHE_BYTES)
|
||||
for (i = 0; i < size >> shift; i++, addr += bytes)
|
||||
dcbf(addr);
|
||||
mb(); /* sync */
|
||||
}
|
||||
@@ -83,11 +85,13 @@ static inline void flush_dcache_range(unsigned long start, unsigned long stop)
|
||||
*/
|
||||
static inline void clean_dcache_range(unsigned long start, unsigned long stop)
|
||||
{
|
||||
void *addr = (void *)(start & ~(L1_CACHE_BYTES - 1));
|
||||
unsigned long size = stop - (unsigned long)addr + (L1_CACHE_BYTES - 1);
|
||||
unsigned long shift = l1_cache_shift();
|
||||
unsigned long bytes = l1_cache_bytes();
|
||||
void *addr = (void *)(start & ~(bytes - 1));
|
||||
unsigned long size = stop - (unsigned long)addr + (bytes - 1);
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < size >> L1_CACHE_SHIFT; i++, addr += L1_CACHE_BYTES)
|
||||
for (i = 0; i < size >> shift; i++, addr += bytes)
|
||||
dcbst(addr);
|
||||
mb(); /* sync */
|
||||
}
|
||||
@@ -100,11 +104,13 @@ static inline void clean_dcache_range(unsigned long start, unsigned long stop)
|
||||
static inline void invalidate_dcache_range(unsigned long start,
|
||||
unsigned long stop)
|
||||
{
|
||||
void *addr = (void *)(start & ~(L1_CACHE_BYTES - 1));
|
||||
unsigned long size = stop - (unsigned long)addr + (L1_CACHE_BYTES - 1);
|
||||
unsigned long shift = l1_cache_shift();
|
||||
unsigned long bytes = l1_cache_bytes();
|
||||
void *addr = (void *)(start & ~(bytes - 1));
|
||||
unsigned long size = stop - (unsigned long)addr + (bytes - 1);
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < size >> L1_CACHE_SHIFT; i++, addr += L1_CACHE_BYTES)
|
||||
for (i = 0; i < size >> shift; i++, addr += bytes)
|
||||
dcbi(addr);
|
||||
mb(); /* sync */
|
||||
}
|
||||
|
Reference in New Issue
Block a user