From 13c30981b9fe14bf9e3978468b301798826e48da Mon Sep 17 00:00:00 2001 From: Armando Date: Tue, 13 Aug 2024 18:23:32 +0800 Subject: [PATCH] fix(cache): disable branch predictor before disable cache branch predictor will start cache request --- components/spi_flash/cache_utils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/spi_flash/cache_utils.c b/components/spi_flash/cache_utils.c index f4cb5c18fd..153a2c3670 100644 --- a/components/spi_flash/cache_utils.c +++ b/components/spi_flash/cache_utils.c @@ -371,12 +371,19 @@ void IRAM_ATTR spi_flash_enable_cache(uint32_t cpuid) void IRAM_ATTR spi_flash_disable_cache(uint32_t cpuid, uint32_t *saved_state) { +#if SOC_BRANCH_PREDICTOR_SUPPORTED + //branch predictor will start cache request as well + esp_cpu_branch_prediction_disable(); +#endif cache_hal_suspend(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL); } void IRAM_ATTR spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_state) { cache_hal_resume(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL); +#if SOC_BRANCH_PREDICTOR_SUPPORTED + esp_cpu_branch_prediction_enable(); +#endif } bool IRAM_ATTR spi_flash_cache_enabled(void)