mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(spi_flash): integrate branch prediction control during cache operations
This commit is contained in:
committed by
Armando (Dou Yiwen)
parent
f91ec54912
commit
87e3dda66d
@@ -22,6 +22,7 @@
|
||||
#include "hal/cache_hal.h"
|
||||
#endif
|
||||
#include "esp_private/cache_utils.h"
|
||||
#include "esp_cpu.h"
|
||||
#include "esp_private/mspi_timing_tuning.h"
|
||||
#include "esp_private/mspi_timing_config.h"
|
||||
#include "esp_private/mspi_timing_by_mspi_delay.h"
|
||||
@@ -633,8 +634,21 @@ static void restore_cache(uint32_t cpuid, uint32_t saved_state)
|
||||
}
|
||||
#else // ESP_TEE_BUILD
|
||||
|
||||
#define disable_cache(cpuid, saved_state) spi_flash_disable_cache(cpuid, saved_state)
|
||||
#define restore_cache(cpuid, saved_state) spi_flash_restore_cache(cpuid, saved_state)
|
||||
static void disable_cache(uint32_t cpuid, uint32_t *saved_state)
|
||||
{
|
||||
#if SOC_BRANCH_PREDICTOR_SUPPORTED
|
||||
esp_cpu_branch_prediction_disable();
|
||||
#endif
|
||||
spi_flash_disable_cache(cpuid, saved_state);
|
||||
}
|
||||
|
||||
static void restore_cache(uint32_t cpuid, uint32_t saved_state)
|
||||
{
|
||||
spi_flash_restore_cache(cpuid, saved_state);
|
||||
#if SOC_BRANCH_PREDICTOR_SUPPORTED
|
||||
esp_cpu_branch_prediction_enable();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "esp_attr.h"
|
||||
#include "esp_cpu.h"
|
||||
#include "esp_rom_caps.h"
|
||||
#include "esp_macros.h"
|
||||
#include "esp_memory_utils.h"
|
||||
@@ -573,6 +574,9 @@ static void FORCE_IRAM_ATTR suspend_cache(void) {
|
||||
// If the access to external memory hits in the cache, it will not trigger a cache error. So in order to
|
||||
// fully check the access to external memory, writeback & invalidate is needed here.
|
||||
Cache_WriteBack_Invalidate_All(CACHE_MAP_MASK);
|
||||
#endif
|
||||
#if SOC_BRANCH_PREDICTOR_SUPPORTED
|
||||
esp_cpu_branch_prediction_disable();
|
||||
#endif
|
||||
spi_flash_disable_cache(esp_cpu_get_core_id(), &s_cache_state);
|
||||
}
|
||||
@@ -584,6 +588,9 @@ static void FORCE_IRAM_ATTR resume_cache(void) {
|
||||
assert(s_cache_suspend_cnt >= 0 && DRAM_STR("cache resume doesn't match suspend ops"));
|
||||
if (s_cache_suspend_cnt == 0) {
|
||||
spi_flash_restore_cache(esp_cpu_get_core_id(), s_cache_state);
|
||||
#if SOC_BRANCH_PREDICTOR_SUPPORTED
|
||||
esp_cpu_branch_prediction_enable();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user