[DNM] adsp: add configuration to adsp virtual regions#91666
[DNM] adsp: add configuration to adsp virtual regions#91666marcinszkudlinski wants to merge 1 commit intozephyrproject-rtos:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds Kconfig-driven controls for virtual memory regions in Intel ADSP, replacing hard-coded sizes and enabling per-core, shared, and opportunistic regions.
- Introduce new enable/size Kconfig options for per-core, shared, and opportunistic regions
- Update
adsp_memory_regions.hto computeVIRTUAL_REGION_COUNTfrom those options - Refactor
mm_drv_intel_adsp_regions.cto size and initialize regions using the new config macros
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| soc/intel/intel_adsp/ace/include/adsp_memory_regions.h | Compute region counts and attributes from Kconfig instead of hard codes |
| drivers/mm/mm_drv_intel_adsp_regions.c | Resize region array and update append_region calls to use config |
| drivers/mm/Kconfig | Add Kconfig options for enabling and sizing each virtual memory region |
Comments suppressed due to low confidence (3)
drivers/mm/mm_drv_intel_adsp_regions.c:47
- Using
i - 1wheni == 0(e.g., if per-core regions are disabled) can underflow the index and access out-of-bounds. Consider tracking the last region address viatotal_sizeor ensurei > 0before usingi - 1.
append_region((void *)((uintptr_t)virtual_memory_regions[i - 1].addr +
drivers/mm/mm_drv_intel_adsp_regions.c:61
- Typo in comment: 'Apending' should be 'Appending'.
/* Apending last region as 0 so iterators know where table is over
soc/intel/intel_adsp/ace/include/adsp_memory_regions.h:12
- Typo in comment: 'Attribiutes' should be 'Attributes'.
/* Attribiutes for memory regions */
| bool "Support for opportunstic virtual memory region" | ||
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | ||
| default y | ||
| help | ||
| This config enables opportunstic virtual memory region | ||
|
|
||
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | ||
| hex "Size in bytes of opportunstic virtual memory region" | ||
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | ||
| default 0x100000 | ||
| help | ||
| This config defines size of opportunstic virtual memory region |
There was a problem hiding this comment.
Typo in menu prompt: 'opportunstic' should be 'opportunistic'.
| bool "Support for opportunstic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | |
| default y | |
| help | |
| This config enables opportunstic virtual memory region | |
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | |
| hex "Size in bytes of opportunstic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | |
| default 0x100000 | |
| help | |
| This config defines size of opportunstic virtual memory region | |
| bool "Support for opportunistic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | |
| default y | |
| help | |
| This config enables opportunistic virtual memory region | |
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | |
| hex "Size in bytes of opportunistic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | |
| default 0x100000 | |
| help | |
| This config defines size of opportunistic virtual memory region |
| bool "Support for opportunstic virtual memory region" | ||
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | ||
| default y | ||
| help | ||
| This config enables opportunstic virtual memory region | ||
|
|
||
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | ||
| hex "Size in bytes of opportunstic virtual memory region" | ||
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | ||
| default 0x100000 | ||
| help | ||
| This config defines size of opportunstic virtual memory region |
There was a problem hiding this comment.
Typo in help text: 'opportunstic' should be 'opportunistic'.
| bool "Support for opportunstic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | |
| default y | |
| help | |
| This config enables opportunstic virtual memory region | |
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | |
| hex "Size in bytes of opportunstic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | |
| default 0x100000 | |
| help | |
| This config defines size of opportunstic virtual memory region | |
| bool "Support for opportunistic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | |
| default y | |
| help | |
| This config enables opportunistic virtual memory region | |
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | |
| hex "Size in bytes of opportunistic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | |
| default 0x100000 | |
| help | |
| This config defines size of opportunistic virtual memory region |
| bool "Support for opportunstic virtual memory region" | ||
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | ||
| default y | ||
| help | ||
| This config enables opportunstic virtual memory region | ||
|
|
||
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | ||
| hex "Size in bytes of opportunstic virtual memory region" | ||
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | ||
| default 0x100000 | ||
| help | ||
| This config defines size of opportunstic virtual memory region |
There was a problem hiding this comment.
Typo in prompt: 'opportunstic' should be 'opportunistic'.
| bool "Support for opportunstic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | |
| default y | |
| help | |
| This config enables opportunstic virtual memory region | |
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | |
| hex "Size in bytes of opportunstic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | |
| default 0x100000 | |
| help | |
| This config defines size of opportunstic virtual memory region | |
| bool "Support for opportunistic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_MTL_TLB | |
| default y | |
| help | |
| This config enables opportunistic virtual memory region | |
| config MM_DRV_INTEL_ADSP_TLB_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION_SIZE | |
| hex "Size in bytes of opportunistic virtual memory region" | |
| depends on MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_OPPORTUNISTIC_REGION | |
| default 0x100000 | |
| help | |
| This config defines size of opportunistic virtual memory region |
virtual region feature in intel ADSP has no config options There's always a region per-core, a shared and an opportunistic region. All regions have a hard-coded sizes. There's also a defect: shared region gets its size from CORE_HEAP_SIZE macro This commit adds kconfig options that allow enabling of each regions separately, as well as adjusting their sizes Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
30413f0 to
b96d265
Compare
|
| #endif | ||
|
|
||
| #if CONFIG_MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_SHARED_REGION | ||
| append_region((void *)((uintptr_t)virtual_memory_regions[i - 1].addr + |
There was a problem hiding this comment.
Hey! If CONFIG_MM_DRV_INTEL_ADSP_TLB_USE_PER_CORE_VIRTUAL_MEMORY_REGIONS is not active, then i will have value 0 and it will reference to element -1 of the virtual_memory_regions array.
softwarecki
left a comment
There was a problem hiding this comment.
In my opinion the entire calculate_memory_regions function is unnecessary, and the sys_mm_drv_query_memory_regions array can be statically initialized (for cores heap use the LISTIFY macro).
BTW: The append_region function adds the size to a pointer instead of to the total_size variable value. @dabekjakub
| #define VIRTUAL_REGION_COUNT_PER_CORE CONFIG_MP_MAX_NUM_CPUS | ||
| #define MEM_REG_ATTR_CORE_HEAP 1U | ||
| #else | ||
| #define VIRTUAL_REGION_COUNT_PER_CORE 0 |
There was a problem hiding this comment.
if selected, this option would break SOF - both with and without thesofproject/sof#10044
|
Added [DNM] - we need to sync with SOF |



virtual region feature in intel ADSP has no config options There's always a region per-core, a shared and
an opportunistic region.
All regions have a hard-coded sizes. There's also a defect: shared region gets its size from CORE_HEAP_SIZE macro
This commit adds kconfig options that allow enabling of each regions separately, as well as adjusting their sizes