From bb4d710d62e926d4bebef7f028d78847f21f9da1 Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Wed, 28 Feb 2024 11:42:17 +0800 Subject: [PATCH] xtensa_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 --- arch/xtensa/src/common/xtensa_cache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/xtensa/src/common/xtensa_cache.c b/arch/xtensa/src/common/xtensa_cache.c index 930c96a759e..d64804e1d36 100644 --- a/arch/xtensa/src/common/xtensa_cache.c +++ b/arch/xtensa/src/common/xtensa_cache.c @@ -498,10 +498,12 @@ void up_clean_dcache(uintptr_t start, uintptr_t end) start &= ~(XCHAL_DCACHE_LINESIZE - 1); +#ifndef CONFIG_SMP if ((end - start) >= XCHAL_DCACHE_SIZE) { return up_clean_dcache_all(); } +#endif for (; start < end; start += XCHAL_DCACHE_LINESIZE) { @@ -580,10 +582,12 @@ void up_flush_dcache(uintptr_t start, uintptr_t end) start &= ~(XCHAL_DCACHE_LINESIZE - 1); +#ifndef CONFIG_SMP if ((end - start) >= XCHAL_DCACHE_SIZE) { return up_clean_dcache_all(); } +#endif for (; start < end; start += XCHAL_DCACHE_LINESIZE) {