mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +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:
@@ -422,7 +422,8 @@ static bool ppa_malloc_transaction(QueueHandle_t trans_elm_ptr_queue, uint32_t t
|
||||
assert(ppa_trans_desc_size != 0);
|
||||
size_t trans_elm_storage_size = sizeof(ppa_trans_t) + SIZEOF_DMA2D_TRANS_T + sizeof(dma2d_trans_config_t) + sizeof(ppa_dma2d_trans_on_picked_config_t) + ppa_trans_desc_size;
|
||||
for (int i = 0; i < trans_elm_num; i++) {
|
||||
void *trans_elm_storage = heap_caps_calloc(1, trans_elm_storage_size, PPA_MEM_ALLOC_CAPS);
|
||||
// always allocate memory from internal memory because the transaction storage embeds a dma2d_trans_t which contains atomic variable
|
||||
void *trans_elm_storage = heap_caps_calloc(1, trans_elm_storage_size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
SemaphoreHandle_t ppa_trans_sem = xSemaphoreCreateBinaryWithCaps(PPA_MEM_ALLOC_CAPS);
|
||||
|
||||
if (!trans_elm_storage || !ppa_trans_sem) {
|
||||
|
||||
Reference in New Issue
Block a user