arm-m: Check the dcache status before enabling dcache

If the cache is already enabled before NuttX starts up,
enabling the cache in NuttX will cause the cache to be
re-invalidated, then resulting in data that is already
in the cache being flushed out.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
zhangyuan21 2023-07-01 06:05:37 +08:00 committed by Alin Jerpelea
parent 427e574bd1
commit c6f32f4363
2 changed files with 16 additions and 0 deletions

View File

@ -496,6 +496,14 @@ void up_enable_dcache(void)
uint32_t sets;
uint32_t ways;
/* If dcache is already enabled, disable it first. */
ccr = getreg32(NVIC_CFGCON);
if ((ccr & NVIC_CFGCON_DC) != 0)
{
up_disable_dcache();
}
/* Get the characteristics of the D-Cache */
ccsidr = getreg32(NVIC_CCSIDR);

View File

@ -496,6 +496,14 @@ void up_enable_dcache(void)
uint32_t sets;
uint32_t ways;
/* If dcache is already enabled, disable it first. */
ccr = getreg32(NVIC_CFGCON);
if ((ccr & NVIC_CFGCON_DC) != 0)
{
up_disable_dcache();
}
/* Get the characteristics of the D-Cache */
ccsidr = getreg32(NVIC_CCSIDR);