Skip to content

Commit fbc91ea

Browse files
mem: add initialization of virt memory region for LLEXT modules
This commit adds initialization of virtual memory region dedicated for LLEXT loadable modules. Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent 806f0a3 commit fbc91ea

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

app/boards/intel_adsp_ace15_mtpm.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ CONFIG_WATCHDOG=y
8383
CONFIG_TIMESLICE_PER_THREAD=y
8484
CONFIG_THREAD_RUNTIME_STATS=y
8585
CONFIG_SCHED_THREAD_USAGE=y
86+
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
8687

8788
# Zephyr / device drivers
8889
CONFIG_CLOCK_CONTROL=y

app/boards/intel_adsp_ace20_lnl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CONFIG_LLEXT_STORAGE_WRITABLE=y
6363
CONFIG_LLEXT_EXPERIMENTAL=y
6464
CONFIG_MODULES=y
6565
CONFIG_TIMING_FUNCTIONS=y
66+
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
6667

6768
# Zephyr / device drivers
6869
CONFIG_CLOCK_CONTROL=y

app/boards/intel_adsp_ace30_ptl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CONFIG_LLEXT=y
6363
CONFIG_LLEXT_STORAGE_WRITABLE=y
6464
CONFIG_LLEXT_EXPERIMENTAL=y
6565
CONFIG_MODULES=y
66+
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
6667

6768
# Zephyr / device drivers
6869
CONFIG_CLOCK_CONTROL=y

app/boards/intel_adsp_ace30_wcl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ CONFIG_LLEXT=y
5050
CONFIG_LLEXT_STORAGE_WRITABLE=y
5151
CONFIG_LLEXT_EXPERIMENTAL=y
5252
CONFIG_MODULES=y
53+
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
5354

5455
# Zephyr / device drivers
5556
CONFIG_CLOCK_CONTROL=y

src/library_manager/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ config LIBRARY_BASE_ADDRESS
5858
automatically but the beginning of that area is platform-specific and
5959
should be set by this option.
6060

61+
config LIBRARY_REGION_SIZE
62+
hex "Size of memory region dedicated to loadable modules"
63+
default 0x100000
64+
help
65+
Size of the virtual memory region dedicated for loadable modules
66+
6167
endmenu

src/library_manager/llext_manager.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <rtos/spinlock.h>
2020
#include <sof/lib/cpu-clk-manager.h>
2121
#include <sof/lib_manager.h>
22+
#include <sof/lib/regions_mm.h>
2223
#include <sof/llext_manager.h>
2324
#include <sof/audio/module_adapter/module/generic.h>
2425
#include <sof/audio/module_adapter/module/modules.h>
@@ -35,6 +36,7 @@
3536
#include <rimage/sof/user/manifest.h>
3637
#include <module/module/api_ver.h>
3738

39+
#include <adsp_memory_regions.h>
3840
#include <errno.h>
3941
#include <stdbool.h>
4042
#include <stddef.h>
@@ -806,3 +808,18 @@ bool comp_is_llext(struct comp_dev *comp)
806808

807809
return mod && module_is_llext(mod);
808810
}
811+
812+
static int llext_memory_region_init(void)
813+
{
814+
int ret;
815+
816+
/* add a region for loadable libraries */
817+
ret = adsp_add_virtual_memory_region(CONFIG_LIBRARY_BASE_ADDRESS,
818+
CONFIG_LIBRARY_REGION_SIZE,
819+
VIRTUAL_REGION_LLEXT_LIBRARIES_ATTR);
820+
821+
return ret;
822+
}
823+
824+
825+
SYS_INIT(llext_memory_region_init, POST_KERNEL, 1);

zephyr/include/sof/lib/regions_mm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/* Attributes for memory regions */
2121
#define VIRTUAL_REGION_SHARED_HEAP_ATTR 1U /*< region dedicated for shared virtual heap */
22+
#define VIRTUAL_REGION_LLEXT_LIBRARIES_ATTR 2U /*< region dedicated for LLEXT libraries */
2223

2324
/* Dependency on ipc/topology.h created due to memory capability definitions
2425
* that are defined there

0 commit comments

Comments
 (0)