arm_cache:Disable clean/flush optimization in case of SMP restriction

In a multicore task scenario, there may be a situation where the task runs on different cores at different time slices (when the task is not bound to a particular core).
When the task calls cache clean/flush(range > cache size), depending on the optimization, clean_all, flush_all are called. however, at this point, there may be dirty data or incomplete data profiles in the cache on the kernel that is running the task, which may result in dirty data being flushed into memory or make the application think that the flushed data should be successfully flushed into memory, leading to unknown consequences.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1 2024-02-27 18:02:57 +08:00 committed by Xiang Xiao
parent 0c12fb9237
commit 91cf97ed84
5 changed files with 32 additions and 0 deletions

View File

@ -304,6 +304,9 @@ void up_invalidate_dcache_all(void)
void up_clean_dcache(uintptr_t start, uintptr_t end)
{
#ifdef CONFIG_SMP
cp15_clean_dcache(start, end);
#else
if ((end - start) < cp15_dcache_size())
{
cp15_clean_dcache(start, end);
@ -312,6 +315,7 @@ void up_clean_dcache(uintptr_t start, uintptr_t end)
{
cp15_clean_dcache_all();
}
#endif
l2cc_clean(start, end);
}
@ -368,6 +372,9 @@ void up_clean_dcache_all(void)
void up_flush_dcache(uintptr_t start, uintptr_t end)
{
#ifdef CONFIG_SMP
cp15_flush_dcache(start, end);
#else
if ((end - start) < cp15_dcache_size())
{
cp15_flush_dcache(start, end);
@ -376,6 +383,7 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
{
cp15_flush_dcache_all();
}
#endif
l2cc_flush(start, end);
}

View File

@ -814,10 +814,12 @@ void up_clean_dcache(uintptr_t start, uintptr_t end)
ssize = (1 << sshift);
#ifndef CONFIG_SMP
if ((end - start) >= ssize * (sets + 1) * (ways + 1))
{
return up_clean_dcache_all();
}
#endif
start &= ~(ssize - 1);
ARM_DSB();
@ -967,10 +969,12 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
ssize = (1 << sshift);
#ifndef CONFIG_SMP
if ((end - start) >= ssize * (sets + 1) * (ways + 1))
{
return up_flush_dcache_all();
}
#endif
start &= ~(ssize - 1);
ARM_DSB();

View File

@ -304,6 +304,9 @@ void up_invalidate_dcache_all(void)
void up_clean_dcache(uintptr_t start, uintptr_t end)
{
#ifdef CONFIG_SMP
cp15_clean_dcache(start, end);
#else
if ((end - start) < cp15_dcache_size())
{
cp15_clean_dcache(start, end);
@ -312,6 +315,7 @@ void up_clean_dcache(uintptr_t start, uintptr_t end)
{
cp15_clean_dcache_all();
}
#endif
l2cc_clean(start, end);
}
@ -368,6 +372,9 @@ void up_clean_dcache_all(void)
void up_flush_dcache(uintptr_t start, uintptr_t end)
{
#ifdef CONFIG_SMP
cp15_flush_dcache(start, end);
#else
if ((end - start) < cp15_dcache_size())
{
cp15_flush_dcache(start, end);
@ -376,6 +383,7 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
{
cp15_flush_dcache_all();
}
#endif
l2cc_flush(start, end);
}

View File

@ -814,10 +814,12 @@ void up_clean_dcache(uintptr_t start, uintptr_t end)
ssize = (1 << sshift);
#ifndef CONFIG_SMP
if ((end - start) >= ssize * (sets + 1) * (ways + 1))
{
return up_clean_dcache_all();
}
#endif
start &= ~(ssize - 1);
ARM_DSB();
@ -967,10 +969,12 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
ssize = (1 << sshift);
#ifndef CONFIG_SMP
if ((end - start) >= ssize * (sets + 1) * (ways + 1))
{
return up_flush_dcache_all();
}
#endif
start &= ~(ssize - 1);
ARM_DSB();

View File

@ -308,6 +308,9 @@ void up_invalidate_dcache_all(void)
void up_clean_dcache(uintptr_t start, uintptr_t end)
{
#ifdef CONFIG_SMP
cp15_clean_dcache(start, end);
#else
if ((end - start) < cp15_dcache_size())
{
cp15_clean_dcache(start, end);
@ -316,6 +319,7 @@ void up_clean_dcache(uintptr_t start, uintptr_t end)
{
cp15_clean_dcache_all();
}
#endif
l2cc_clean(start, end);
}
@ -372,6 +376,9 @@ void up_clean_dcache_all(void)
void up_flush_dcache(uintptr_t start, uintptr_t end)
{
#ifdef CONFIG_SMP
cp15_flush_dcache(start, end);
#else
if ((end - start) < cp15_dcache_size())
{
cp15_flush_dcache(start, end);
@ -380,6 +387,7 @@ void up_flush_dcache(uintptr_t start, uintptr_t end)
{
cp15_flush_dcache_all();
}
#endif
l2cc_flush(start, end);
}