Skip to content

[DNM] adsp: add configuration to adsp virtual regions#91666

Closed
marcinszkudlinski wants to merge 1 commit intozephyrproject-rtos:mainfrom
marcinszkudlinski:kconfig_virt_mem
Closed

[DNM] adsp: add configuration to adsp virtual regions#91666
marcinszkudlinski wants to merge 1 commit intozephyrproject-rtos:mainfrom
marcinszkudlinski:kconfig_virt_mem

Conversation

@marcinszkudlinski
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.h to compute VIRTUAL_REGION_COUNT from those options
  • Refactor mm_drv_intel_adsp_regions.c to 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 - 1 when i == 0 (e.g., if per-core regions are disabled) can underflow the index and access out-of-bounds. Consider tracking the last region address via total_size or ensure i > 0 before using i - 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 */

Comment thread drivers/mm/Kconfig Outdated
Comment on lines +76 to +87
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
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

Typo in menu prompt: 'opportunstic' should be 'opportunistic'.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread drivers/mm/Kconfig Outdated
Comment on lines +76 to +87
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
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

Typo in help text: 'opportunstic' should be 'opportunistic'.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread drivers/mm/Kconfig Outdated
Comment on lines +76 to +87
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
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

Typo in prompt: 'opportunstic' should be 'opportunistic'.

Suggested change
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

Copilot uses AI. Check for mistakes.
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>
@sonarqubecloud
Copy link
Copy Markdown

#endif

#if CONFIG_MM_DRV_INTEL_ADSP_TLB_USE_VIRTUAL_MEMORY_SHARED_REGION
append_region((void *)((uintptr_t)virtual_memory_regions[i - 1].addr +
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.

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.

Copy link
Copy Markdown
Contributor

@softwarecki softwarecki left a comment

Choose a reason for hiding this comment

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

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
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.

if selected, this option would break SOF - both with and without thesofproject/sof#10044

@marcinszkudlinski marcinszkudlinski changed the title adsp: add configuration to adsp virtual regions [DNM] adsp: add configuration to adsp virtual regions Jun 17, 2025
@marcinszkudlinski
Copy link
Copy Markdown
Contributor Author

Added [DNM] - we need to sync with SOF

@marcinszkudlinski marcinszkudlinski deleted the kconfig_virt_mem branch July 8, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants