Repository navigation
Memory cleanup - #1023
Memory cleanup#1023
Conversation
There was a problem hiding this comment.
This is a great first step towards compact fw memory footprint that would not require manual adjustments. However there are some sections still defined statically, i.e. heaps and stack.
This is the linker and rimage output for the default apl configuration (w/ dmic on):
18 0xbe010400 0xbe02a156 105814 TEXT .text
20 0xbe02b000 0xbe040d1c 89372 DATA .rodata
21 0xbe040d40 0xbe043898 11096 DATA .data
22 0xbe043898 0xbe043904 108 DATA .fw_ready
23 0xbe044000 0xbe045108 4360 BSS .bss
33 0xbe051000 0xbe05e000 53248 HEAP .system_heap
34 0xbe05e000 0xbe064800 26624 HEAP .system_runtime_heap
35 0xbe064800 0xbe072800 57344 HEAP .runtime_heap
36 0xbe072800 0xbe07f000 51200 HEAP .buffer_heap
37 0xbe07f000 0xbe080000 4096 HEAP .sof_stack
38 0x20000000 0x2000e4bc 58556 NOTE .static_log_entries
...
Totals Start End Size
TEXT 0xbe010000 0xbe02a156 0x1a156
DATA 0xbe02b000 0xbe043904 0x18904
BSS 0xbe044000 0xbe045108 0x1108
And this is the output w/o dmic:
18 0xbe010400 0xbe028486 98438 TEXT .text
20 0xbe029000 0xbe03d69c 83612 DATA .rodata
21 0xbe03d6c0 0xbe040058 10648 DATA .data
22 0xbe040058 0xbe0400c4 108 DATA .fw_ready
23 0xbe041000 0xbe0420f8 4344 BSS .bss
33 0xbe051000 0xbe05e000 53248 HEAP .system_heap
...
As you can see, rodata+data and the bss is automatically adjusted while the system_heap stays @ 0xbe051000. Heaps are followed by the stack and location of the latter determines the SOF_MEMORY_SIZE which is used by the memory power management code in the cnl boot_loader.
So there are a couple of things to do in order to save on memory power in cnl/icl/...:
- Let the linker pack heaps and stacks into the large hpsram segment as well. This will require to use similar 'start' and 'end' linker variables for the heap initialization code as in case of the bss writeback on smp.
- Make sure the third segment (called bss) in the fw manifest includes heaps and stacks as well.
- Adjust the boot loader code to compute the set of memory banks powered based on the manifest content (see parse_module()) instead of using static SOF_MEMORY_SIZE. Note: easier way may be to add another linker variable at the end of the stack segment and use this one as the SOF_MEMORY_SIZE replacement. With the latter approach (2) is not required but still nice to have and could be done in the next iteration anyway to be able to determine actual sram occupation directly from the manifest.
b143ddc to
19994ab
Compare
lgirdwood
left a comment
There was a problem hiding this comment.
Good PR, but please add more detail in the commit messages. I'd expect to see details why and what is being changed. Does SueCreek need this too ?
19994ab to
eae7b94
Compare
|
@mmaka1 thanks, very good ideas. I have extended commits with this. All 3 steps are done, latest one just not commited (need to make sure that the current changes are good enough and fix problems). |
lgirdwood
left a comment
There was a problem hiding this comment.
Overall good, just have minor comments. My only outstanding larger change is that the CNL changes should be duplicated for SUE.
| } >sof_fw :sof_fw_phdr | ||
|
|
||
| .rodata : ALIGN(4) | ||
| .rodata : ALIGN(4096) |
There was a problem hiding this comment.
What's the reasoning behind the section alignment to 4K (others also be aligned to 4k too) ?
There was a problem hiding this comment.
@lgirdwood The FW manifest assumes that its "segments" are aligned, so every section that begins that FW manifest "segment" (text/rodata/bss) is aligned. It is historically connected with the virtual mem address space management (via TLB).
Regarding SUE, yes this is a good idea that SUE follows the CNL approach. Once it is done and tested for CNL which is the first iteration goal, should be very easy to replicate by a SUE developer.
| #define SOF_FW_START (HP_SRAM_VECBASE_RESET + 0x400) | ||
| #define SOF_FW_BASE (SOF_FW_START) | ||
| #define SOF_FW_SIZE (0x41000 - 0x400) | ||
| #define SOF_FW_SIZE (0x90000 - 0x400) |
There was a problem hiding this comment.
Can we have a macro for the 0x90000 ? I'm assuming it's maximum possible size for text ?? It would also be good to have macro for 0x400 offset too if you have time.
There was a problem hiding this comment.
It is a max size for all var-size sections (text/rodata/bss). All "fixed" size sections (stacks, heaps) are moved to the beginning of the mem space (right after mem windows and other fixed size elements) and followed by one large sof_fw_size area defined for linker so it packs everything var-size like .text, .rodata, .data, .bss into that one (with the alignment you noticed that is preserved for the fw manifest representation).
There was a problem hiding this comment.
@mmaka1 ok, makes sense, but we need to call it something like SOF_FW_MAX_SIZE with a comment e.g.
/* max size for all var-size sections (text/rodata/bss) */
#define SOF_FW_MAX_SIZE 0x90000
There was a problem hiding this comment.
@lgirdwood yes, in the next update I will introduce new section for fixed-size things (heaps, stack) and this sof_fw will be for var-size sections. I will include proper comments like in your example.
0505354 to
56ee9a3
Compare
One shared memory block SOF_FW for SOF_TEXT, SOF_DATA and SOF_BSS sections. Moved fw_ready near to .rodata and .data Removed setting of .text_size for APL manifes Updated rom.x.in (SOF_BSS_DATA_START is no longer in use) Used linker symbols to obtain real BSS size in alloc.h Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
56ee9a3 to
871462e
Compare
|
Let's do the fixed part (heaps+stacks) move in the next iteration. This would require some changes to the memory initialization routine as the current use of stack by the boot loader is a bit unreliable (will be submitting a PR for that soon...). The buffer heap should be more dynamic in the next iter of implementation to make bigger difference on the power consumed (small one at the beginning, adjusted at run-time + mem pwr bank management on demand). |
Memory cleanup.
One shared memory block SOF_FW for SOF_TEXT, SOF_DATA and SOF_BSS sections.
Moved fw_ready near to .rodata and .data
Used linker symbols to obtain real BSS size in alloc.h
Removed setting of .text_size for APL manifes