Skip to content

memory: new memory layout - #1483

Merged
jajanusz merged 7 commits into
thesofproject:masterfrom
abonislawski:memory_r2
Jun 11, 2019
Merged

jajanusz merged 7 commits into
thesofproject:masterfrom
abonislawski:memory_r2

Conversation

@abonislawski

@abonislawski abonislawski commented May 28, 2019 •

Copy link
Copy Markdown
Member

It introduces two significant optimizations:

Separate the memory (heaps, stack) by cores so if we will turn off a specific core we can also turn off all memory of this core.
Remove fixed defines and gaps, previously stack was at fixed position - end of memory and buffer heap was everything between stack and fw. Now everything will be packed at sof_fw memory segment and takes only this memory which is really needed, everything else we can turn off.

BSS section now includes heaps and stack
Removed many heap fixed position defines
Removed gap before fw text section in CNL
memmap init is using real linker positions for heaps
Temporary stack for boot_ldr placed in heap_hp_buffer (safe)
use linker stack position in boot entry
use linker heap position in sanity check
sof fw max_size limited to memory configured by memory banks count

Using new macro to stack init per core
Stack is no longer a one big block for all cores (core_count*stack_size)
System_runtime_heap and system_heap are no longer a one big block for all cores

Memory layout for every slave core aligned to hw memory bank:

--align to memory bank--
system_heap
system_runtime_heap
stack
--align to memory bank--
next slave core..

So if we will turn off a specific core then we are also able to turn off memory "connected" to this core

Similar layout applies to master core

Signed-off-by: Adrian Bonislawski adrian.bonislawski@linux.intel.com

@dbaluta

dbaluta commented May 28, 2019

Copy link
Copy Markdown
Collaborator

@abonislawski none of the commits explain why do we need a new memory layout and what's wrong with the existing one. Please fix this.

@lgirdwood

Copy link
Copy Markdown
Member

@abonislawski also this breaks CI.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core 0 doesn't need to be master core - that's why we have PLATFORM_MASTER_CORE_ID.

@abonislawski abonislawski May 30, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a real scenario or just a theoretical option? I can branch in this macro if core is not a PLATFORM_MASTER_CORE_ID but it will work correctly only if it is 0 (this define), just like in memmap in memory.c - it is designed for master at 0 (without my changes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real scenario as there is already HW with master core != 0 (although currently not supported by SOF). I know it probably won't work due to some historical assumptions, but better not to limit the new code.

@mmaka1 mmaka1 May 31, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should not assume master == 0 in the generic xtensa arch code since the ID of the core must be unique and that is it, the actual value depends on how the cores are integrated.

We may assume it temporarily (better not, however safe atm) in the cavs platform code since we know how the cores are integrated in there.

@abonislawski
abonislawski force-pushed the memory_r2 branch 4 times, most recently from 5f26c25 to aa91c8c Compare June 3, 2019 12:19
@abonislawski
abonislawski force-pushed the memory_r2 branch 2 times, most recently from 42e86c0 to a900a74 Compare June 4, 2019 08:31
@abonislawski abonislawski changed the title [WIP] memory: new memory layout memory: new memory layout Jun 4, 2019
Comment thread test/cmocka/include/mock_memory.h Resolved
@jajanusz

jajanusz commented Jun 5, 2019

Copy link
Copy Markdown
Contributor

Doesn't it break git bisect? I didn't look into details, but by looking at commit titles commits like new memory layout should be squashed with minimal commit that changes what layout is needed. Otherwise it will not build for other platforms, for few commits, making git bisect not so useful.

@abonislawski

Copy link
Copy Markdown
Member Author

@jajanusz all memory layout commits squashed.

One more thing, please check intel licence note in xtos-internal.h, it should be added like this? Should I add author note? And it should be also added to boot_entry.S and crt1-boards.S If I have changed only 1 line in these files?

@abonislawski

Copy link
Copy Markdown
Member Author

Because of recent changes on master this PR will work again when #1522 will be merged

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why you are making these changes are there are no commit messages and the PR description fails to explain why each change is needed.

@abonislawski

Copy link
Copy Markdown
Member Author

No idea why you are making these changes are there are no commit messages and the PR description fails to explain why each change is needed.

"This will optimize memory usage, remove fixed position defines and allow to
power down all memory of a specified core" + changelog

I will add more info to commit messages if thats not enough

It introduces two significant optimizations:

  1. Separate the memory (heaps, stack) by cores so if we will turn off a specific core we can also turn off all memory of this core.
  2. Remove fixed defines and gaps, previously stack was at fixed position - end of memory and buffer heap was everything between stack and fw. Now everything will be packed at sof_fw memory segment and takes only this memory which is really needed, everything else we can turn off.

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are overall a good new feature, but can someone explain the programming differences (if any) between CAVS platforms and other platforms wrt buffer and other memory allocations.

Comment thread src/platform/intel/cavs/memory.c Resolved
This will allow to use real stack position instead of a fixed define

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
It will fix symbol overwriting _system_heap_start was already used in system_heap section

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
It will fix symbol overwriting, _system_heap_start was already used in system_heap section

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
@abonislawski
abonislawski force-pushed the memory_r2 branch 2 times, most recently from 7dcf7f7 to 95864f6 Compare June 6, 2019 13:44

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abonislawski thanks, I see what you are doing now. It also looks like these changes need to be reflected in memory.h where we have ASCII descriptions of the memory map.
I think the baytrail/haswell linker script changes will also need applied to imx8 linker script ?
@dbaluta fyi

It will fix symbol overwriting, _system_heap_start was already used in system_heap section

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
This will replace a fixed position define with a real linker position, which allows to set heap position by linker

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
This will add new macro to setup stack with a new memory layout when memory is separated by core

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
@abonislawski

Copy link
Copy Markdown
Member Author

@lgirdwood sure, good point. I have updated ASCII descriptions of the memory map.

Also added one commit for imx8 linker so all of them will get fix

This will optimize memory usage and introduces two significant optimizations:

> Separate the memory (heaps, stack) by cores so if we will turn off a specific core we can also turn off all memory of this core.
> Remove fixed defines and gaps, previously stack was at fixed position: end of memory and buffer heap was everything between stack and fw. Now everything will be packed at sof_fw memory segment and takes only this memory which is really needed, everything else we can turn off.

Changelog:
BSS section now includes heaps and stack
Removed many heap fixed position defines
Removed gap before fw text section
memmap init is using real linker positions for heaps
Temporary stack for boot_ldr placed in heap_hp_buffer (safe)
sof fw max_size and segment limited to memory configured by memory banks count

Using new macro to stack init per core
Stack is no longer a one big block for all cores (core_count*stack_size)
System_runtime_heap and system_heap are no longer a one big block for all cores

For suecreek memory it will also introduce similar changes previously introduced
in other platforms
(One shared memory block SOF_FW for SOF_TEXT, SOF_DATA and SOF_BSS sections
Moved fw_ready near to .rodata and .data)

Memory layout for every slave core aligned to hw memory bank:
--align to memory bank--
system_heap
system_runtime_heap
stack
--align to memory bank--
next slave core..

Similar layout applies to master core

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
@abonislawski

Copy link
Copy Markdown
Member Author

Force pushed because of QB issue, no changes today. Please finish your reviews @tlauda @jajanusz @mmaka1 @dbaluta

@jajanusz
jajanusz merged commit f1fe783 into thesofproject:master Jun 11, 2019
@lyakh

lyakh commented Jun 14, 2019 •

Copy link
Copy Markdown
Collaborator

@jajanusz @abonislawski @lgirdwood this broke Sue Creek.

@jajanusz

Copy link
Copy Markdown
Contributor

@lyakh Sorry we have no suecreek here and we just try to not cause CI regression.
@lgirdwood Can we add something more than just building for suecreek in CI?

@abonislawski

Copy link
Copy Markdown
Member Author

@lyakh I cannot test it without platforms but PR #1567 will probably fix it, please let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants