-
Notifications
You must be signed in to change notification settings - Fork 349
Heap refinement Part 2 -- make full use of HPSRAM in buffer zone #4735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,12 +112,12 @@ static SHARED_DATA struct block_map rt_shared_heap_map[] = { | |
| #endif | ||
|
|
||
| /* Heap blocks for buffers */ | ||
| static SHARED_DATA struct block_hdr buf_block[HEAP_BUFFER_COUNT]; | ||
| static SHARED_DATA struct block_hdr buf_block[HEAP_BUFFER_COUNT_MAX]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you have an idea how much RAM this is wasting?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I talked this with @lgirdwood , it is 8B/256B about 3%here. There are some waste, the percentage is up to how much of it is inevitable: e.g. I previously has some calculation to improve it for small SRAM platforms, like This could help to bring back about 5KB memory for us, we can do this kind of fine tune incrementally. |
||
| static SHARED_DATA struct block_hdr lp_buf_block[HEAP_LP_BUFFER_COUNT]; | ||
|
|
||
| /* Heap memory map for buffers */ | ||
| static SHARED_DATA struct block_map buf_heap_map[] = { | ||
| BLOCK_DEF(HEAP_BUFFER_BLOCK_SIZE, HEAP_BUFFER_COUNT, | ||
| BLOCK_DEF(HEAP_BUFFER_BLOCK_SIZE, HEAP_BUFFER_COUNT_MAX, | ||
| uncached_block_hdr(buf_block)), | ||
| }; | ||
|
|
||
|
|
@@ -130,8 +130,21 @@ static SHARED_DATA struct mm memmap; | |
|
|
||
| void platform_init_memmap(struct sof *sof) | ||
| { | ||
| uint32_t heap_buffer_size = SOF_FW_END - (uint32_t)&_buffer_heap; | ||
| uint32_t buffer_count; | ||
| int i; | ||
|
|
||
| /* calculate the buffer heap size */ | ||
| buffer_count = heap_buffer_size / HEAP_BUFFER_BLOCK_SIZE; | ||
| heap_buffer_size = buffer_count * HEAP_BUFFER_BLOCK_SIZE; | ||
|
|
||
| for (i = 0; i < ARRAY_SIZE(buf_heap_map); i++) { | ||
| buf_heap_map[i].count = buffer_count; | ||
| buf_heap_map[i].free_count = buffer_count; | ||
| } | ||
| dcache_writeback_region(buf_heap_map, | ||
| sizeof(struct block_map) * ARRAY_SIZE(buf_heap_map)); | ||
|
|
||
| /* access memory map through uncached region */ | ||
| sof->memory_map = cache_to_uncache(&memmap); | ||
|
|
||
|
|
@@ -216,11 +229,12 @@ void platform_init_memmap(struct sof *sof) | |
| sof->memory_map->buffer[0].blocks = ARRAY_SIZE(buf_heap_map); | ||
| sof->memory_map->buffer[0].map = uncached_block_map(buf_heap_map); | ||
| sof->memory_map->buffer[0].heap = (uintptr_t)&_buffer_heap; | ||
| sof->memory_map->buffer[0].size = HEAP_BUFFER_SIZE; | ||
| sof->memory_map->buffer[0].info.free = HEAP_BUFFER_SIZE; | ||
| sof->memory_map->buffer[0].size = heap_buffer_size; | ||
| sof->memory_map->buffer[0].info.free = heap_buffer_size; | ||
| sof->memory_map->buffer[0].caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_HP | | ||
| SOF_MEM_CAPS_CACHE | SOF_MEM_CAPS_DMA; | ||
|
|
||
| #if PLATFORM_HEAP_BUFFER >= 2 | ||
| /* heap lp buffer init */ | ||
| sof->memory_map->buffer[1].blocks = ARRAY_SIZE(lp_buf_heap_map); | ||
| sof->memory_map->buffer[1].map = uncached_block_map(lp_buf_heap_map); | ||
|
|
@@ -229,10 +243,11 @@ void platform_init_memmap(struct sof *sof) | |
| sof->memory_map->buffer[1].info.free = HEAP_LP_BUFFER_SIZE; | ||
| sof->memory_map->buffer[1].caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_LP | | ||
| SOF_MEM_CAPS_CACHE | SOF_MEM_CAPS_DMA; | ||
| #endif | ||
|
|
||
| /* .total init */ | ||
| sof->memory_map->total.free = HEAP_SYSTEM_T_SIZE + | ||
| HEAP_SYS_RUNTIME_T_SIZE + HEAP_RUNTIME_SIZE + HEAP_BUFFER_SIZE + | ||
| HEAP_SYS_RUNTIME_T_SIZE + HEAP_RUNTIME_SIZE + heap_buffer_size + | ||
| HEAP_LP_BUFFER_SIZE; | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SOF_FW_ENDis defined as(HP_SRAM_BASE + HP_SRAM_SIZE - 0x1000)andHP_SRAM_BASEis defined to0xbe000000, so, they both are absolute addresses._buffer_heap_startis also an absolute address, corresponding to the (relative) current address.. So,SOF_FW_END - _buffer_heap_startis the memory size from "here" to the end of HP SRAM, right? So the above line calculates the relative address ofSOF_FW_END. And below_buffer_heap_endis the respective absolute address again, i.e. it's just equal toSOF_FW_ENDisn't it? Wouldn't it be easier to just use_buffer_heap_end = SOF_FW_END?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, but we are using some common formats for each zone here:
xx_heap_start = ABSOLUTE(.);
. = . + XXX_SIZE;
xx_heap_end = ABSOLUTE(.);
With this format, we can change the "XXX_SIZE" easily and corresponding change to xx_heap_start/end is not needed.
OTOH, this is aligned with other non-Intel or non-cAVS platforms also, where there could be no definition of SOF_FW_END at all.