@@ -325,7 +325,7 @@ static inline void *aes_dma_calloc(size_t num, size_t size, uint32_t caps, size_
325325 return heap_caps_aligned_calloc (DMA_DESC_MEM_ALIGN_SIZE , num , size , caps | MALLOC_CAP_DMA | MALLOC_CAP_8BIT );
326326}
327327
328- static inline esp_err_t dma_desc_link (crypto_dma_desc_t * dmadesc , size_t crypto_dma_desc_num , size_t cache_line_size )
328+ static inline esp_err_t dma_desc_link (crypto_dma_desc_t * dmadesc , size_t crypto_dma_desc_num )
329329{
330330 esp_err_t ret = ESP_OK ;
331331 for (int i = 0 ; i < crypto_dma_desc_num ; i ++ ) {
@@ -334,7 +334,8 @@ static inline esp_err_t dma_desc_link(crypto_dma_desc_t *dmadesc, size_t crypto_
334334#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
335335 /* Write back both input buffers and output buffers to clear any cache dirty bit if set
336336 If we want to remove `ESP_CACHE_MSYNC_FLAG_UNALIGNED` aligned flag then we need to pass
337- cache msync size = ALIGN_UP(dma_desc.size, cache_line_size), instead of dma_desc.size
337+ cache msync size = ALIGN_UP(dma_desc.size, cache_line_size), where cache_line_size is the
338+ the cache line size coressponding to the buffer that is being synced, instead of dma_desc.size
338339 Keeping the `ESP_CACHE_MSYNC_FLAG_UNALIGNED` flag just because it should not look like
339340 we are syncing extra bytes due to ALIGN_UP'ed size but just the number of bytes that
340341 are needed in the operation. */
@@ -343,7 +344,7 @@ static inline esp_err_t dma_desc_link(crypto_dma_desc_t *dmadesc, size_t crypto_
343344 return ret ;
344345 }
345346 }
346- ret = esp_cache_msync (dmadesc , ALIGN_UP ( crypto_dma_desc_num * sizeof (crypto_dma_desc_t ), cache_line_size ), ESP_CACHE_MSYNC_FLAG_DIR_C2M );
347+ ret = esp_cache_msync (dmadesc , crypto_dma_desc_num * sizeof (crypto_dma_desc_t ), ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED );
347348#else
348349 }
349350#endif
@@ -470,7 +471,7 @@ static esp_err_t generate_descriptor_list(const uint8_t *buffer, const size_t le
470471 populated_dma_descs += (unaligned_end_bytes ? 1 : 0 );
471472 }
472473
473- if (dma_desc_link (dma_descriptors , dma_descs_needed , cache_line_size ) != ESP_OK ) {
474+ if (dma_desc_link (dma_descriptors , dma_descs_needed ) != ESP_OK ) {
474475 ESP_LOGE (TAG , "DMA descriptors cache sync C2M failed" );
475476 return ESP_FAIL ;
476477 }
0 commit comments