4141
4242#if TU_CHECK_MCU (OPT_MCU_ESP32P4 )
4343#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
44+ #include "sdkconfig.h"
4445#include "hal/cache_hal.h"
4546#include "esp_cache.h"
4647#define DWC2_ENABLE_MEM_CACHE 1
@@ -106,7 +107,7 @@ TU_ATTR_ALWAYS_INLINE static inline void dwc2_phy_update(dwc2_regs_t* dwc2, uint
106107// MCU specific cache synchronization call
107108TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_sync_cache_to_memory (void * addr , size_t size ) {
108109#if DWC2_ENABLE_MEM_CACHE
109- ESP_EARLY_LOGW ("dwc2_esp32" , "cache to mem sync, addr 0x%" PRIx32 ", size %d" , (uintptr_t )addr , size );
110+ ESP_EARLY_LOGV ("dwc2_esp32" , "cache to mem sync, addr 0x%" PRIx32 ", size %d" , (uintptr_t )addr , size );
110111 int flags = ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED ;
111112 esp_err_t ret = esp_cache_msync (addr , size , flags );
112113 assert (ret == ESP_OK );
@@ -120,8 +121,9 @@ TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_sync_cache_to_memory(void *add
120121TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_sync_memory_to_cache (void * addr , size_t size ) {
121122#if DWC2_ENABLE_MEM_CACHE
122123 int flags = ESP_CACHE_MSYNC_FLAG_DIR_M2C ;
123- size = (size < 0x40 )? 0x40 : size ;
124- ESP_EARLY_LOGW ("dwc2" , "mem to cache sync, addr 0x%" PRIx32 ", size %d" , (uintptr_t )addr , size );
124+ ESP_EARLY_LOGV ("dwc2" , "mem to cache sync, addr 0x%" PRIx32 ", size %d" , (uintptr_t )addr , size );
125+ // TODO: size should be multiply of CONFIG_CACHE_L1_CACHE_LINE_SIZE?
126+ size = (size < CONFIG_CACHE_L1_CACHE_LINE_SIZE )? CONFIG_CACHE_L1_CACHE_LINE_SIZE : size ;
125127 esp_err_t ret = esp_cache_msync (addr , size , flags );
126128 assert (ret == ESP_OK );
127129#else
0 commit comments