summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2019-02-15 12:19:41 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-02-19 22:15:29 -0800
commit869f0477a16c7a41fb3e6128cf8c852cee0dd59a (patch)
treed6433b8e1a82fd731a91029764950151137a1e97
parent06c7c1bff3705fd5e8c8c0bb20a89bbd54d95bb8 (diff)
downloadchrome-ec-869f0477a16c7a41fb3e6128cf8c852cee0dd59a.tar.gz
mt_scp: Add functions to clean/invalidated selected lines of D-cache
For performance reasons, we want to be able to flush/invalidate only specific cache lines/addresses. BRANCH=none BUG=b:123676508 TEST=fill; flush; fill to generate incoherent DRAM/cache content: cached: 10000000: 89905d00 89905d01 89905d02 89905d03 89905d04 89905d05 89905d06 89905d07 10000020: 89905d08 89905d09 89905d0a 89905d0b 89905d0c 89905d0d 89905d0e 89905d0f direct: 30000000: 3848c300 3848c301 3848c302 3848c303 3848c304 3848c305 3848c306 3848c307 30000020: 3848c308 3848c309 3848c30a 3848c30b 3848c30c 3848c30d 3848c30e 3848c30f => Then clean a cache line > flush 0x10000000 c Clean cached: 10000000: 89905d00 89905d01 89905d02 89905d03 89905d04 89905d05 89905d06 89905d07 10000020: 89905d08 89905d09 89905d0a 89905d0b 89905d0c 89905d0d 89905d0e 89905d0f direct: 30000000: 89905d00 89905d01 89905d02 89905d03 89905d04 89905d05 89905d06 89905d07 30000020: 3848c308 3848c309 3848c30a 3848c30b 3848c30c 3848c30d 3848c30e 3848c30f => memory is updated => Then invalidate a cache line > flush 0x10000020 i Inval 10000020 cached: 10000000: 89905d00 89905d01 89905d02 89905d03 89905d04 89905d05 89905d06 89905d07 10000020: 3848c308 3848c309 3848c30a 3848c30b 3848c30c 3848c30d 3848c30e 3848c30f direct: 30000000: 89905d00 89905d01 89905d02 89905d03 89905d04 89905d05 89905d06 89905d07 30000020: 3848c308 3848c309 3848c30a 3848c30b 3848c30c 3848c30d 3848c30e 3848c30f => cache content is thrown away, and matches memory Change-Id: I5dbcc366236fef56f7cb048ce313247cf3d51276 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1475092 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Yilun Lin <yllin@chromium.org>
-rw-r--r--chip/mt_scp/memmap.c19
-rw-r--r--core/cortex-m/cpu.h5
2 files changed, 24 insertions, 0 deletions
diff --git a/chip/mt_scp/memmap.c b/chip/mt_scp/memmap.c
index 83322d493a..ef86c175c9 100644
--- a/chip/mt_scp/memmap.c
+++ b/chip/mt_scp/memmap.c
@@ -73,6 +73,14 @@ void cpu_invalidate_dcache(void)
asm volatile("dsb;");
}
+void cpu_invalidate_dcache_address(uintptr_t address)
+{
+ SCP_CACHE_OP(CACHE_DCACHE) = (address & SCP_CACHE_OP_TADDR_MASK);
+ SCP_CACHE_OP(CACHE_DCACHE) |=
+ OP_INVALIDATE_ONE_LINE_BY_ADDRESS | SCP_CACHE_OP_EN;
+ asm volatile("dsb;");
+}
+
void cpu_clean_invalidate_dcache(void)
{
SCP_CACHE_OP(CACHE_DCACHE) &= ~SCP_CACHE_OP_OP_MASK;
@@ -84,6 +92,17 @@ void cpu_clean_invalidate_dcache(void)
asm volatile("dsb;");
}
+void cpu_clean_invalidate_dcache_address(uintptr_t address)
+{
+ SCP_CACHE_OP(CACHE_DCACHE) = (address & SCP_CACHE_OP_TADDR_MASK);
+ SCP_CACHE_OP(CACHE_DCACHE) |=
+ OP_CACHE_FLUSH_ONE_LINE_BY_ADDRESS | SCP_CACHE_OP_EN;
+ SCP_CACHE_OP(CACHE_DCACHE) = (address & SCP_CACHE_OP_TADDR_MASK);
+ SCP_CACHE_OP(CACHE_DCACHE) |=
+ OP_INVALIDATE_ONE_LINE_BY_ADDRESS | SCP_CACHE_OP_EN;
+ asm volatile("dsb;");
+}
+
static void scp_cache_init(void)
{
int c;
diff --git a/core/cortex-m/cpu.h b/core/cortex-m/cpu.h
index a6029e2e7e..7f91b33179 100644
--- a/core/cortex-m/cpu.h
+++ b/core/cortex-m/cpu.h
@@ -71,4 +71,9 @@ void cpu_invalidate_dcache(void);
/* Clean and Invalidate the D-cache to the Point of Coherency */
void cpu_clean_invalidate_dcache(void);
+/* Invalidate a single address of the D-cache */
+void cpu_invalidate_dcache_address(uintptr_t address);
+/* Clean and Invalidate a single address of the D-cache */
+void cpu_clean_invalidate_dcache_address(uintptr_t address);
+
#endif /* __CROS_EC_CPU_H */