mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
fix(driver): allocate driver objects containing atomic variables from internal SRAM
Objects with atomic members must not be allocated to PSRAM, otherwise the ordering guarantee of atomic accesses is weakened due to a hardware behavior on ESP32 chips. Explicitly request MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT for: - i2c master bus object (atomic status/trans_idx) - i3c master bus object (atomic fsm) - ISP processor and AE/AF/AWB/HIST controllers (atomic fsm) - JPEG decoder/encoder dma2d transaction descriptors (atomic started) - PPA transaction storage embedding dma2d_trans_t - dma2d m2m test transaction embedding dma2d_trans_t
This commit is contained in:
@@ -119,7 +119,8 @@ esp_err_t jpeg_new_decoder_engine(const jpeg_decode_engine_cfg_t *dec_eng_cfg, j
|
||||
|
||||
ESP_GOTO_ON_ERROR(dma2d_acquire_pool(&dma2d_client_config, &decoder_engine->dma2d_group_handle), err, TAG, "dma2d client acquire failed");
|
||||
|
||||
decoder_engine->trans_desc = (dma2d_trans_t *)heap_caps_calloc(1, SIZEOF_DMA2D_TRANS_T, JPEG_MEM_ALLOC_CAPS);
|
||||
// always allocate memory from internal memory because the dma2d transaction descriptor contains atomic variable
|
||||
decoder_engine->trans_desc = (dma2d_trans_t *)heap_caps_calloc(1, SIZEOF_DMA2D_TRANS_T, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
ESP_GOTO_ON_FALSE(decoder_engine->trans_desc, ESP_ERR_NO_MEM, err, TAG, "No memory for dma2d descriptor");
|
||||
#if JPEG_USE_RETENTION_LINK
|
||||
if (dec_eng_cfg->flags.allow_pd != 0) {
|
||||
|
||||
@@ -147,7 +147,8 @@ esp_err_t jpeg_new_encoder_engine(const jpeg_encode_engine_cfg_t *enc_eng_cfg, j
|
||||
};
|
||||
ESP_ERROR_CHECK(dma2d_acquire_pool(&dma2d_group_config, &encoder_engine->dma2d_group_handle));
|
||||
|
||||
encoder_engine->trans_desc = (dma2d_trans_t *)heap_caps_calloc(1, SIZEOF_DMA2D_TRANS_T, JPEG_MEM_ALLOC_CAPS);
|
||||
// always allocate memory from internal memory because the dma2d transaction descriptor contains atomic variable
|
||||
encoder_engine->trans_desc = (dma2d_trans_t *)heap_caps_calloc(1, SIZEOF_DMA2D_TRANS_T, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
ESP_GOTO_ON_FALSE(encoder_engine->trans_desc, ESP_ERR_NO_MEM, err, TAG, "No memory for dma2d descriptor");
|
||||
|
||||
encoder_engine->header_info = (jpeg_enc_header_info_t*)heap_caps_calloc(1, sizeof(jpeg_enc_header_info_t), JPEG_MEM_ALLOC_CAPS);
|
||||
|
||||
Reference in New Issue
Block a user