fix(cache): fixed cache sync ops concurrent call issue

Closes https://github.com/espressif/esp-idf/issues/18023
This commit is contained in:
armando
2025-12-25 10:01:08 +08:00
parent 3faeb94681
commit 80a7d826b5
4 changed files with 25 additions and 0 deletions
+10
View File
@@ -26,6 +26,16 @@ static const char *TAG = "cache";
DEFINE_CRIT_SECTION_LOCK_STATIC(s_spinlock);
void esp_cache_sync_ops_enter_critical_section(void)
{
esp_os_enter_critical_safe(&s_spinlock);
}
void esp_cache_sync_ops_exit_critical_section(void)
{
esp_os_exit_critical_safe(&s_spinlock);
}
esp_err_t esp_cache_msync(void *addr, size_t size, int flags)
{
ESP_RETURN_ON_FALSE_ISR(addr, ESP_ERR_INVALID_ARG, TAG, "null pointer");
+2
View File
@@ -403,7 +403,9 @@ static void IRAM_ATTR NOINLINE_ATTR s_do_cache_invalidate(uint32_t vaddr_start,
*/
cache_sync();
#else //Other chips
esp_cache_sync_ops_enter_critical_section();
cache_hal_invalidate_addr(vaddr_start, size);
esp_cache_sync_ops_exit_critical_section();
#endif // CONFIG_IDF_TARGET_ESP32
}
@@ -159,6 +159,16 @@ esp_err_t esp_cache_aligned_calloc(size_t n, size_t size, uint32_t heap_caps, vo
__attribute__((deprecated("Use 'heap_caps_calloc' with MALLOC_CAP_CACHE_ALIGNED caps instead")))
esp_err_t esp_cache_aligned_calloc_prefer(size_t n, size_t size, void **out_ptr, size_t *actual_size, size_t flag_nums, ...);
/**
* @brief Enter critical section for cache sync operations
*/
void esp_cache_sync_ops_enter_critical_section(void);
/**
* @brief Exit critical section for cache sync operations
*/
void esp_cache_sync_ops_exit_critical_section(void);
/**
* @brief Get Cache alignment requirement for data
*