-
Notifications
You must be signed in to change notification settings - Fork 349
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
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if CONFIG_VIRTUAL_HEAP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <sof/lib/regions_mm.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <zephyr/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| struct vmh_heap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| struct vmh_heap *virtual_buffers_heap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -288,8 +289,39 @@ static const struct vmh_heap_config static_hp_buffers = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* WA Stubs begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * in order to merge a PR that moves initialization of virtual regions from Zephyr to SOF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * we need to create weak stubs for 2 functions that will need to be called once the PR is merged | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| __weak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uintptr_t adsp_mm_get_unused_l2_start_aligned(void) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+297
to
+303
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| __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. | |
| */ |
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. | |
| */ |
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 */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,10 +49,7 @@ struct vmh_heap { | |
| */ | ||
| struct vmh_heap *vmh_init_heap(const struct vmh_heap_config *cfg, bool allocating_continuously) | ||
|
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. 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
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. 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.
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. @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
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.
Currently I cannot merge "proper solution" to Zephyr
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. 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. |
||
| { | ||
| const struct sys_mm_drv_region *virtual_memory_regions = | ||
| sys_mm_drv_query_memory_regions(); | ||
| int i; | ||
|
|
||
| struct vmh_heap *new_heap = | ||
| rzalloc(SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT, sizeof(*new_heap)); | ||
|
|
||
|
|
@@ -61,15 +58,14 @@ struct vmh_heap *vmh_init_heap(const struct vmh_heap_config *cfg, bool allocatin | |
|
|
||
| k_mutex_init(&new_heap->lock); | ||
| struct vmh_heap_config new_config = {0}; | ||
| const struct sys_mm_drv_region *region; | ||
|
|
||
| SYS_MM_DRV_MEMORY_REGION_FOREACH(virtual_memory_regions, region) { | ||
| if (region->attr == MEM_REG_ATTR_SHARED_HEAP) { | ||
| new_heap->virtual_region = region; | ||
| break; | ||
| } | ||
| } | ||
| if (!new_heap->virtual_region) | ||
| /* Workaround - use the very first virtual memory region because of virt addresses | ||
| * collision. | ||
| * Fix will be provided ASAP, but removing MEM_REG_ATTR_SHARED_HEAP from SOF is required | ||
| * to merge Zephyr changes | ||
| */ | ||
| new_heap->virtual_region = sys_mm_drv_query_memory_regions(); | ||
| if (!new_heap->virtual_region || !new_heap->virtual_region->size) | ||
| goto fail; | ||
|
|
||
| /* If no config was specified we will use default one */ | ||
|
|
||
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.