SAM3/4 CMCC: if region to be invalidate is bigger than that cache, then invalidate all

This commit is contained in:
Gregory Nutt 2014-03-25 14:25:22 -06:00
parent 99f9239a00
commit 9b5e800cc0

View File

@ -146,8 +146,27 @@ void sam_cmcc_invalidate(uintptr_t start, uintptr_t end)
uint32_t regval;
uint32_t way
uint32_t index;
size_t size;
int nlines;
/* Get the aligned addresses and size for the memory region to be
* invalidated.
*/
start = ALIGN_DOWN(start);
end = ALIGN_up(end);
size = end - start;
/* If this is a large region (as big as the cache), then just invalidate
* the entire cache the easy way.
*/
if (size >= (CMCC_CACHE_SIZE / CMCC_CACHE_LINE_SIZE / CMCC_NWAYS)
{
sam_cmcc_invalidateall();
return;
}
/* "When an invalidate by line command is issued the cache controller resets
* the valid bit information of the decoded cache line. As the line is no
* longer valid the replacement counter points to that line.
@ -170,9 +189,6 @@ void sam_cmcc_invalidate(uintptr_t start, uintptr_t end)
/* Invalidate the address region */
start = ALIGN_DOWN(start);
end = ALIGN_up(end);
index = (start >> CMCC_SHIFT)
nlines = ((end - start) >> CMCC_SHIFT);