-
Notifications
You must be signed in to change notification settings - Fork 347
mem: workaround - remove MEM_REG_ATTR_SHARED_HEAP from SOF #10144
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
mem: workaround - remove MEM_REG_ATTR_SHARED_HEAP from SOF #10144
Conversation
5820dfa to
b20596b
Compare
|
Internal CI was green before update I needed to add a commit allowing SOF to work without and with zephyr changes from zephyrproject-rtos/zephyr#93334 |
This PR forces buffers location in the very first memory region, preventing from conflict of virtual addresses with loadable modules in case of 5 cores platforms Signed-off-by: Marcin Szkudlinski <[email protected]>
b20596b to
6dcc67c
Compare
|
...and incorrect commit description fix Please review and merge ASAP |
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.
Pull Request Overview
This PR implements a workaround to resolve virtual address conflicts with loadable modules on 5-core platforms by removing dependency on MEM_REG_ATTR_SHARED_HEAP and forcing buffer allocation in the first memory region.
- Removes the search for
MEM_REG_ATTR_SHARED_HEAPregions and uses the first available virtual memory region instead - Adds weak function stubs for future Zephyr integration compatibility
- Introduces a new configuration option for virtual heap region size
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| zephyr/lib/regions_mm.c | Replaces heap region search logic with direct assignment to first virtual memory region |
| zephyr/lib/alloc.c | Adds weak stubs and virtual memory region initialization logic |
| zephyr/include/sof/lib/regions_mm.h | Defines new attribute constant for shared heap regions |
| zephyr/Kconfig | Adds configuration option for virtual heap region size |
zephyr/lib/alloc.c
Outdated
| #include <sof/audio/pipeline.h> | ||
| #include <sof/audio/component_ext.h> | ||
| #include <sof/trace/trace.h> | ||
| #include <zephyr/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h> |
Copilot
AI
Jul 30, 2025
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.
Including a platform-specific driver header in generic allocation code reduces portability. Consider moving this include to a platform-specific file or using a more generic interface.
| #include <zephyr/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h> | |
| // Platform-specific header moved to a dedicated file for Intel ADSP MTL-specific logic. |
| }, | ||
| }; | ||
|
|
||
| /* WA Stubs begin |
Copilot
AI
Jul 30, 2025
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.
The abbreviation 'WA' should be spelled out as 'Workaround' for clarity in the comment.
| /* WA Stubs begin | |
| /* Workaround Stubs begin |
| { | ||
| return 0; | ||
| } | ||
| /* WA Stubs end */ |
Copilot
AI
Jul 30, 2025
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.
The abbreviation 'WA' should be spelled out as 'Workaround' for clarity in the comment.
| /* WA Stubs end */ | |
| /* Workaround Stubs end */ |
|
|
||
| __weak | ||
| uintptr_t adsp_mm_get_unused_l2_start_aligned(void) | ||
| { | ||
| return 0; | ||
| } | ||
|
|
Copilot
AI
Jul 30, 2025
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.
The weak stub function lacks documentation explaining its purpose, expected behavior when the real implementation is available, and return value meaning.
| __weak | |
| uintptr_t adsp_mm_get_unused_l2_start_aligned(void) | |
| { | |
| return 0; | |
| } | |
| /** | |
| * @brief Weak stub for retrieving the start address of unused L2 memory, aligned. | |
| * | |
| * This function is a placeholder and should be overridden by a platform-specific | |
| * implementation. It is expected to return the starting address of unused L2 memory, | |
| * aligned to the required boundary. | |
| * | |
| * @return uintptr_t The aligned start address of unused L2 memory. Returns 0 if | |
| * no implementation is provided. | |
| */ | |
| __weak | |
| uintptr_t adsp_mm_get_unused_l2_start_aligned(void) | |
| { | |
| return 0; | |
| } | |
| /** | |
| * @brief Weak stub for adding a virtual memory region. | |
| * | |
| * This function is a placeholder and should be overridden by a platform-specific | |
| * implementation. It is expected to add a virtual memory region with the specified | |
| * address, size, and attributes. | |
| * | |
| * @param region_address The starting address of the virtual memory region. | |
| * @param region_size The size of the virtual memory region in bytes. | |
| * @param attr Attributes for the virtual memory region (e.g., access permissions). | |
| * | |
| * @return int Returns 0 if successful, or an error code if the operation fails. | |
| */ |
| { | ||
| return 0; | ||
| } | ||
|
|
Copilot
AI
Jul 30, 2025
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.
The weak stub function lacks documentation explaining its parameters, return values, and expected behavior when the real implementation becomes available.
| /** | |
| * @brief Add a virtual memory region to the system. | |
| * | |
| * This weak stub function is a placeholder for adding a virtual memory region. | |
| * It is expected to be overridden by a real implementation in the future. | |
| * | |
| * @param region_address The starting address of the memory region. | |
| * @param region_size The size of the memory region in bytes. | |
| * @param attr Attributes for the memory region (e.g., access permissions). | |
| * | |
| * @return 0 on success, or an error code indicating failure. | |
| */ |
This commit add creation of virtual memory region for heap Called functions are not yet present in Zephyr (Zephyr is creating regions by itself now), so the commit also contains weaked aliases of zephyr functions. Signed-off-by: Marcin Szkudlinski <[email protected]>
6dcc67c to
189b654
Compare
|
fix for compilation when CONFIG_VIRTUAL_HEAP=0 (TGL) |
| * @retval ptr to a new heap if successful. | ||
| * @retval NULL on creation failure. | ||
| */ | ||
| struct vmh_heap *vmh_init_heap(const struct vmh_heap_config *cfg, bool allocating_continuously) |
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.
could you please explain - do you mean that VMH and LLEXT attempt to use the same addresses on PTL? Don't we have enough address space, cannot we just adjust CONFIG_LIBRARY_BASE_ADDRESS?
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.
sure it would work too. Yet I also want to make the whole system more resistant to such problem in a future, and this commit is making 2 steps at the same time - 1) a workaround 2) removing circular dependency from Zephyr.
Both can be done by getting the 1st range from the table with no questions ask, and than - when Zephyr is ready - creating zones by call from SOF (instead of hard-coded zones in Zephyr as it is now) and checking if any mapping fits into dedicated zone.
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.
@marcinszkudlinski well, I was just wondering - why create a somewhat complicated workaround to be later replaced with a proper solution, if we can fix the problem by just changing an address in platform configuration, while also still working on a proper solution
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.
- removing circular dependency from Zephyr.
Currently I cannot merge "proper solution" to Zephyr
https://github.com/zephyrproject-rtos/zephyr/actions/runs/16593737908/job/46935880948?pr=93334
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.
Ack @marcinszkudlinski . So it would this is the way to go, this PR removes MEM_REG_ATTR_CORE_HEAP, Marcin can update SOF in Zephyr manifest, then do the change in Zephyr (zephyrproject-rtos/zephyr#93334), and then update Zephyr in SOF. Good to go @lyakh ? We have failures in quickbuild as long as we have this open.
|
can we proceed? This defect is blocking PTL CI |
This PR does 2 things: