mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/aes_dma_descriptor_setup_issue_v5.0' into 'release/v5.0'
fix(aes): correct the linking of the DMA descriptors (v5.0) See merge request espressif/esp-idf!25785
This commit is contained in:
commit
d2109f0527
@ -395,6 +395,10 @@ static int esp_aes_process_dma(esp_aes_context *ctx, const unsigned char *input,
|
||||
//Limit max inlink descriptor length to be 16 byte aligned, require for EDMA
|
||||
lldesc_setup_link_constrained(block_out_desc, output, block_bytes, LLDESC_MAX_NUM_PER_DESC_16B_ALIGNED, 0);
|
||||
|
||||
/* Setup in/out start descriptors */
|
||||
lldesc_append(&in_desc_head, block_in_desc);
|
||||
lldesc_append(&out_desc_head, block_out_desc);
|
||||
|
||||
out_desc_tail = &block_out_desc[lldesc_num - 1];
|
||||
}
|
||||
|
||||
@ -412,20 +416,13 @@ static int esp_aes_process_dma(esp_aes_context *ctx, const unsigned char *input,
|
||||
lldesc_setup_link(&s_stream_in_desc, s_stream_in, AES_BLOCK_BYTES, 0);
|
||||
lldesc_setup_link(&s_stream_out_desc, s_stream_out, AES_BLOCK_BYTES, 0);
|
||||
|
||||
if (block_bytes > 0) {
|
||||
/* Link with block descriptors*/
|
||||
block_in_desc[lldesc_num - 1].empty = (uint32_t)&s_stream_in_desc;
|
||||
block_out_desc[lldesc_num - 1].empty = (uint32_t)&s_stream_out_desc;
|
||||
}
|
||||
/* Link with block descriptors */
|
||||
lldesc_append(&in_desc_head, &s_stream_in_desc);
|
||||
lldesc_append(&out_desc_head, &s_stream_out_desc);
|
||||
|
||||
out_desc_tail = &s_stream_out_desc;
|
||||
}
|
||||
|
||||
// block buffers are sent to DMA first, unless there aren't any
|
||||
in_desc_head = (block_bytes > 0) ? block_in_desc : &s_stream_in_desc;
|
||||
out_desc_head = (block_bytes > 0) ? block_out_desc : &s_stream_out_desc;
|
||||
|
||||
|
||||
#if defined (CONFIG_MBEDTLS_AES_USE_INTERRUPT)
|
||||
/* Only use interrupt for long AES operations */
|
||||
if (len > AES_DMA_INTR_TRIG_LEN) {
|
||||
@ -485,6 +482,7 @@ cleanup:
|
||||
int esp_aes_process_dma_gcm(esp_aes_context *ctx, const unsigned char *input, unsigned char *output, size_t len, lldesc_t *aad_desc, size_t aad_len)
|
||||
{
|
||||
lldesc_t *in_desc_head = NULL, *out_desc_head = NULL, *len_desc = NULL;
|
||||
lldesc_t *out_desc_tail = NULL; /* pointer to the final output descriptor */
|
||||
lldesc_t stream_in_desc, stream_out_desc;
|
||||
lldesc_t *block_desc = NULL, *block_in_desc = NULL, *block_out_desc = NULL;
|
||||
size_t lldesc_num;
|
||||
@ -534,6 +532,8 @@ int esp_aes_process_dma_gcm(esp_aes_context *ctx, const unsigned char *input, un
|
||||
|
||||
lldesc_append(&in_desc_head, block_in_desc);
|
||||
lldesc_append(&out_desc_head, block_out_desc);
|
||||
|
||||
out_desc_tail = &block_out_desc[lldesc_num - 1];
|
||||
}
|
||||
|
||||
/* Any leftover bytes which are appended as an additional DMA list */
|
||||
@ -545,6 +545,8 @@ int esp_aes_process_dma_gcm(esp_aes_context *ctx, const unsigned char *input, un
|
||||
|
||||
lldesc_append(&in_desc_head, &stream_in_desc);
|
||||
lldesc_append(&out_desc_head, &stream_out_desc);
|
||||
|
||||
out_desc_tail = &stream_out_desc;
|
||||
}
|
||||
|
||||
|
||||
@ -583,7 +585,7 @@ int esp_aes_process_dma_gcm(esp_aes_context *ctx, const unsigned char *input, un
|
||||
|
||||
aes_hal_transform_dma_gcm_start(blocks);
|
||||
|
||||
esp_aes_dma_wait_complete(use_intr, out_desc_head);
|
||||
esp_aes_dma_wait_complete(use_intr, out_desc_tail);
|
||||
|
||||
aes_hal_transform_dma_finish();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user