Skip to content

Commit b17e512

Browse files
committed
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 e5ebed2 commit b17e512

File tree

10 files changed

+385
-1
lines changed

10 files changed

+385
-1
lines changed

app/boards/intel_adsp_ace15_mtpm.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=y
6868
CONFIG_HEAP_MEM_POOL_SIZE=8192
6969
CONFIG_LLEXT=y
7070
CONFIG_LLEXT_STORAGE_WRITABLE=y
71+
CONFIG_LLEXT_EXPERIMENTAL=y
7172
CONFIG_MODULES=y
7273
CONFIG_TIMING_FUNCTIONS=y
7374
CONFIG_WATCHDOG=y

app/boards/intel_adsp_ace20_lnl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ CONFIG_COUNTER=y
5252
CONFIG_HEAP_MEM_POOL_SIZE=8192
5353
CONFIG_LLEXT=y
5454
CONFIG_LLEXT_STORAGE_WRITABLE=y
55+
CONFIG_LLEXT_EXPERIMENTAL=y
5556
CONFIG_MODULES=y
5657
CONFIG_TIMING_FUNCTIONS=y
5758

app/boards/intel_adsp_ace30_ptl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ CONFIG_HEAP_MEM_POOL_SIZE=8192
5353
CONFIG_L3_HEAP=y
5454
CONFIG_LLEXT=y
5555
CONFIG_LLEXT_STORAGE_WRITABLE=y
56+
CONFIG_LLEXT_EXPERIMENTAL=y
5657
CONFIG_MODULES=y
5758

5859
# 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 && !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(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)