arch/armv7-ar: flush dcache when addr is not aligned with cache line

When invalidate address is not aligned with cache line,
must align address and flush the cache line.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
zhangyuan21 2023-01-16 11:36:29 +08:00 committed by Xiang Xiao
parent 4bb155db64
commit 806a2a8b8d
2 changed files with 36 additions and 4 deletions

View File

@ -94,16 +94,32 @@ static void cp15_dcache_op_mva(uintptr_t start, uintptr_t end, int op)
uint32_t line; uint32_t line;
line = cp15_cache_get_info(NULL, NULL); line = cp15_cache_get_info(NULL, NULL);
start &= ~(line - 1);
ARM_DSB(); ARM_DSB();
if ((start & (line - 1)) != 0)
{
start &= ~(line - 1);
if (op == CP15_CACHE_INVALIDATE)
{
cp15_cleaninvalidate_dcacheline_bymva(start);
start += line;
}
}
while (start < end) while (start < end)
{ {
switch (op) switch (op)
{ {
case CP15_CACHE_INVALIDATE: case CP15_CACHE_INVALIDATE:
if (start + line <= end)
{
cp15_invalidate_dcacheline_bymva(start); cp15_invalidate_dcacheline_bymva(start);
}
else
{
cp15_cleaninvalidate_dcacheline_bymva(start);
}
break; break;
case CP15_CACHE_CLEAN: case CP15_CACHE_CLEAN:
cp15_clean_dcache_bymva(start); cp15_clean_dcache_bymva(start);

View File

@ -94,16 +94,32 @@ static void cp15_dcache_op_mva(uintptr_t start, uintptr_t end, int op)
uint32_t line; uint32_t line;
line = cp15_cache_get_info(NULL, NULL); line = cp15_cache_get_info(NULL, NULL);
start &= ~(line - 1);
ARM_DSB(); ARM_DSB();
if ((start & (line - 1)) != 0)
{
start &= ~(line - 1);
if (op == CP15_CACHE_INVALIDATE)
{
cp15_cleaninvalidate_dcacheline_bymva(start);
start += line;
}
}
while (start < end) while (start < end)
{ {
switch (op) switch (op)
{ {
case CP15_CACHE_INVALIDATE: case CP15_CACHE_INVALIDATE:
if (start + line <= end)
{
cp15_invalidate_dcacheline_bymva(start); cp15_invalidate_dcacheline_bymva(start);
}
else
{
cp15_cleaninvalidate_dcacheline_bymva(start);
}
break; break;
case CP15_CACHE_CLEAN: case CP15_CACHE_CLEAN:
cp15_clean_dcache_bymva(start); cp15_clean_dcache_bymva(start);