Skip to content

Commit 60e7a0a

Browse files
lyakhkv2019i
authored andcommitted
llext: avoid reloading libraries during resume
Currently when resuming from D3 we lose the complete LLEXT context, which forces SOF to reload all the libraries, which costs time. This isn't necessary, because the libraries are stored in DRAM, which preserves its contents across DSP reset. Instead of reloading save LLEXT context before power down and reload it when resuming. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 70bfd54 commit 60e7a0a

11 files changed

Lines changed: 386 additions & 1 deletion

File tree

app/boards/intel_adsp_ace15_mtpm.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=y
7676
CONFIG_HEAP_MEM_POOL_SIZE=8192
7777
CONFIG_LLEXT=y
7878
CONFIG_LLEXT_STORAGE_WRITABLE=y
79+
CONFIG_LLEXT_EXPERIMENTAL=y
7980
CONFIG_MODULES=y
8081
CONFIG_TIMING_FUNCTIONS=y
8182
CONFIG_WATCHDOG=y

app/boards/intel_adsp_ace20_lnl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ CONFIG_COUNTER=y
6060
CONFIG_HEAP_MEM_POOL_SIZE=8192
6161
CONFIG_LLEXT=y
6262
CONFIG_LLEXT_STORAGE_WRITABLE=y
63+
CONFIG_LLEXT_EXPERIMENTAL=y
6364
CONFIG_MODULES=y
6465
CONFIG_TIMING_FUNCTIONS=y
6566

app/boards/intel_adsp_ace30_ptl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ CONFIG_HEAP_MEM_POOL_SIZE=8192
6161
CONFIG_L3_HEAP=y
6262
CONFIG_LLEXT=y
6363
CONFIG_LLEXT_STORAGE_WRITABLE=y
64+
CONFIG_LLEXT_EXPERIMENTAL=y
6465
CONFIG_MODULES=y
6566

6667
# Zephyr / device drivers

app/boards/intel_adsp_ace30_wcl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ CONFIG_HEAP_MEM_POOL_SIZE=8192
4848
CONFIG_L3_HEAP=y
4949
CONFIG_LLEXT=y
5050
CONFIG_LLEXT_STORAGE_WRITABLE=y
51+
CONFIG_LLEXT_EXPERIMENTAL=y
5152
CONFIG_MODULES=y
5253

5354
# Zephyr / device drivers

src/include/ipc4/notification.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ enum sof_ipc4_resource_type {
114114
(((SOF_IPC4_NOTIFY_FW_READY) << (SOF_IPC4_GLB_NOTIFY_TYPE_SHIFT)) |\
115115
((SOF_IPC4_GLB_NOTIFICATION) << (SOF_IPC4_GLB_NOTIFY_MSG_TYPE_SHIFT)))
116116

117+
#define SOF_IPC4_FW_READY_LIB_RESTORED BIT(15)
118+
117119
#define SOF_IPC4_NOTIF_HEADER(notif_type) \
118120
((notif_type) << (SOF_IPC4_GLB_NOTIFY_TYPE_SHIFT) | \
119121
((SOF_IPC4_GLB_NOTIFICATION) << (SOF_IPC4_GLB_NOTIFY_MSG_TYPE_SHIFT)))

src/include/sof/llext_manager.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ bool comp_is_llext(struct comp_dev *comp);
3838
#define comp_is_llext(comp) false
3939
#endif
4040

41+
#if CONFIG_LLEXT_EXPERIMENTAL && !CONFIG_ADSP_IMR_CONTEXT_SAVE
42+
int llext_manager_store_to_dram(void);
43+
int llext_manager_restore_from_dram(void);
44+
#else
45+
#define llext_manager_store_to_dram() 0
46+
#define llext_manager_restore_from_dram() -ENOSYS
47+
#endif
48+
4149
#endif

src/ipc/ipc4/handler.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <sof/lib/mailbox.h>
2424
#include <sof/lib/memory.h>
2525
#include <sof/lib/pm_runtime.h>
26+
#include <sof/llext_manager.h>
2627
#include <sof/math/numbers.h>
2728
#include <sof/tlv.h>
2829
#include <sof/trace/trace.h>
@@ -1485,6 +1486,17 @@ __cold static int ipc4_module_process_dx(struct ipc4_message_request *ipc4)
14851486
return IPC4_BUSY;
14861487
}
14871488

1489+
#if !CONFIG_ADSP_IMR_CONTEXT_SAVE
1490+
ret = llext_manager_store_to_dram();
1491+
if (ret < 0)
1492+
ipc_cmd_err(&ipc_tr, "Error %d saving LLEXT context. Resume might fail.",
1493+
ret);
1494+
1495+
#if CONFIG_L3_HEAP
1496+
l3_heap_save();
1497+
#endif
1498+
#endif
1499+
14881500
#if defined(CONFIG_PM)
14891501
ipc_get()->task_mask |= IPC_TASK_POWERDOWN;
14901502
#endif

src/library_manager/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ if(CONFIG_LIBRARY_MANAGER)
55

66
if (CONFIG_MM_DRV AND CONFIG_LLEXT)
77
add_local_sources(sof llext_manager.c)
8+
if(CONFIG_LLEXT_EXPERIMENTAL AND NOT CONFIG_ADSP_IMR_CONTEXT_SAVE)
9+
add_local_sources_ifdef(CONFIG_L3_HEAP sof llext_manager_dram.c)
10+
endif()
811
endif()
912
endif()

0 commit comments

Comments
 (0)