Merge branch 'fix/dualcore_branch_predictor_cache_race' into 'master'

fix(spi_flash): disable branch prediction on the parked core during flash ops

See merge request espressif/esp-idf!50871
This commit is contained in:
Jiang Jiang Jian
2026-08-24 19:46:44 +08:00
7 changed files with 93 additions and 23 deletions
@@ -13,9 +13,6 @@
#include "soc/spi_mem_reg.h"
#endif
#if SOC_BRANCH_PREDICTOR_SUPPORTED
#include "riscv/rv_utils.h"
#endif
#include "esp_rom_spiflash.h"
#define SPI_IDX 1
@@ -800,10 +797,6 @@ void esp_rom_spiflash_cache_mode_config(esp_rom_spiflash_read_mode_t mode, const
extern void rom_spi_flash_disable_cache(uint32_t cpuid, uint32_t *saved_state);
void spi_flash_disable_cache(uint32_t cpuid, uint32_t *saved_state)
{
#if SOC_BRANCH_PREDICTOR_SUPPORTED
//branch predictor will start cache request as well
rv_utils_dis_branch_predictor();
#endif
rom_spi_flash_disable_cache(cpuid, saved_state);
}
@@ -811,8 +804,5 @@ extern void rom_spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_state);
void spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_state)
{
rom_spi_flash_restore_cache(cpuid, saved_state);
#if SOC_BRANCH_PREDICTOR_SUPPORTED
rv_utils_en_branch_predictor();
#endif
}
#endif