diff --git a/rimage b/rimage index 48777207f..4ce79b152 160000 --- a/rimage +++ b/rimage @@ -1 +1 @@ -Subproject commit 48777207f5fdc49314dd4709d660e891c48d5ba9 +Subproject commit 4ce79b152e23c7b3937a09ef57cdd69d125a9214 diff --git a/zephyr/lib/regions_mm.c b/zephyr/lib/regions_mm.c index 636041b2f..d0d91b9e5 100644 --- a/zephyr/lib/regions_mm.c +++ b/zephyr/lib/regions_mm.c @@ -6,10 +6,13 @@ */ #include +#include /* list of vmh_heap objects created */ static struct list_item vmh_list; +LOG_MODULE_REGISTER(vmh, CONFIG_SOF_LOG_LEVEL); + /** * @brief Initialize new heap * @@ -258,13 +261,21 @@ void *vmh_alloc(struct vmh_heap *heap, uint32_t alloc_size) /* calculate block count needed to allocate for current * mem_block. */ + if (!heap->physical_blocks_allocators[mem_block_iterator]) { + LOG_ERR("NULL allocator #%d", mem_block_iterator); + return NULL; + } block_size = 1 << heap->physical_blocks_allocators[mem_block_iterator]->blk_sz_shift; block_count = SOF_DIV_ROUND_UP((uint64_t)alloc_size, (uint64_t)block_size); if (block_count > - heap->physical_blocks_allocators[mem_block_iterator]->num_blocks) + heap->physical_blocks_allocators[mem_block_iterator]->num_blocks) { + LOG_INF("insufficient blocks %d of %d vs. %d", + heap->physical_blocks_allocators[mem_block_iterator]->num_blocks, + block_size, block_count); continue; + } /* Try span alloc on first available mem_block for non span * check if block size is sufficient. */ @@ -277,6 +288,7 @@ void *vmh_alloc(struct vmh_heap *heap, uint32_t alloc_size) heap->physical_blocks_allocators[mem_block_iterator], block_count, &ptr); } + /* Save allocation data for purpose of freeing correctly * afterwards should be changed to a implementation in mem_blocks * that keeps alloc data there. @@ -321,7 +333,11 @@ void *vmh_alloc(struct vmh_heap *heap, uint32_t alloc_size) sys_bitarray_set_region(heap->allocation_sizes[mem_block_iterator], block_count - 1, allocation_bitarray_position); break; - } + } else + LOG_ERR("error %d allocating %d of %d of size %d", + allocation_error_code, block_count, + heap->physical_blocks_allocators[mem_block_iterator]->num_blocks, + block_size); } /* If ptr is NULL it means we did not allocate anything and we should