Repository navigation
Conversation
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…try, query, and unload Remove all build-time per-codec #ifdef checks from get_codec_info() in base_fw.c and replace them with a build-time pre-allocated slot table updated 1-by-1 via sof_codec_info_add() / sof_codec_info_remove() under a spinlock (avoiding heap fragmentation across LLEXT load/unload cycles). Add IPC4_SOF_INFO_GET (37) and IPC4_SOF_LIBRARY_UNLOAD (38) along with IPC4_SOF_CAP_RUNTIME_SOF_INFO and IPC4_SOF_CAP_LIBRARY_UNLOAD under IPC4_SOF_CAPS so hosts can query updated codecs after library load/unload and purge idle dynamic libraries. Keep IPC4_FW_CONFIG emitting IPC4_SOF_CODEC_INFO and IPC4_SOF_CAPS for backwards compatibility. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> # Conflicts: # src/kernel/audio/base_fw.c
…brary unload Parse the optional ".sof_codec_info" ELF section when loading or DRAM-restoring an LLEXT library and register each codec item 1-by-1 with base_fw. Add lib_manager_unload_library() and llext_manager_remove_library() to reject unsupported library types (-ENOTSUP), free retained LLEXT inspection data before unloading, and unregister the library's codec entries. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
… LLEXT Move codec capability declarations out of base_fw.c into ffmpeg_dec, mfcc, and cadence_ipc4: embed ".sof_codec_info" tables in LLEXT builds and register built-in codec items 1-by-1 during SOF_MODULE_INIT via sof_codec_info_add_items(). Mark the init wrappers __maybe_unused for host library builds where SOF_MODULE_INIT is a no-op. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add NO_OFFSET_ADVANCE, TOP_DOWN, and --reset support to sof_llext_build(), llext_link_helper.py, and llext_offset_calc.py so mutually exclusive standalone LLEXTs can share the post-stock VMA slot or pack top-down from LIBRARY_REGION_SIZE end without advancing module_size. Also retain .module/.mod_buildinfo sections, add DEPENDS on uuid-registry.txt, and default CONFIG_LLEXT_HEAP_SIZE=32 for relocatable FFmpeg builds. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…one LLEXTs Split monolithic ffmpeg_dec LLEXT into 25 per-codec standalone LLEXT modules (12 decoders, 11 encoders, 2 audio filters) with dedicated UUIDs in uuid-registry.txt, each compiled with -fvisibility=hidden / -ffunction-sections / -fdata-sections and linked against per-module shim registration libraries so unused codecs and parsers are dead-stripped. Place encoders (ROLE enc) and ffmpeg_af_alimiter top-down inside LIBRARY_REGION_SIZE using NO_OFFSET_ADVANCE and TOP_DOWN while decoders share the post-stock VA slot, fitting within default 0x180000 in relocatable mode. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Route COMPR_FFMPEG (decoder) and COMPR_FFMPEG_ENC (encoder) pipelines to the per-codec standalone module UUIDs when COMPR_FFMPEG_LLEXT is enabled (default), keeping legacy monolithic UUID fallback when disabled, and pass COMPR_FFMPEG_ENC_CODEC for per-codec encoder topologies. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…ched heap perms Keep .cold/.coldrodata addresses until teardown completes in both LL and DP domains, release vpage reservations in llext_manager_remove_library(), and restore SYS_MM_MEM_PERM_RW (K_MEM_PERM_RW | K_MEM_CACHE_WB) on detached ELF pages when unmapping or rolling back so freeing back to l3_heap does not leave read-only pages that panic on subsequent library loads. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
12752f8 to
e9dc085
Compare
Address PR thesofproject#11519 review feedback: - base_fw.c: log invalid parameters and lib_manager_unload_library() failures with LOG_ERR() in basefw_library_unload(). - codec_info.h / base_fw.c: move sof_codec_info_add_items() implementation to base_fw.c alongside sof_codec_info_add() and sof_codec_info_remove() (with stub under #else), and log NULL items or sof_codec_info_add() failures with LOG_ERR(). - lib_manager.c: log failure paths in lib_manager_unload_library() with LOG_ERR() and switch the unload success log to LOG_INF(). - llext_manager.c: replace new tr_err()/tr_warn() calls in LLEXT codec registration and unload paths with Zephyr LOG_WRN()/LOG_ERR(). Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
Addressed review comments in 2721296:
|
…reset Internal/out-of-tree builds with a separate APPLICATION_SOURCE_DIR failed with 'llext_link_helper.py: error: unrecognized arguments: --reset' when building the first LLEXT target (e.g., drc) because sof_llext_build() computed SOF_BASE from APPLICATION_SOURCE_DIR/.. instead of the SOF module root, picking up an external copy of llext_link_helper.py that lacked --reset. Fix both: - Derive SOF_BASE in sof_llext_build() from CMAKE_CURRENT_FUNCTION_LIST_DIR/.. so SOF's own includes and LLEXT scripts are always used regardless of APPLICATION_SOURCE_DIR. - Reset module_size by removing the file with 'cmake -E rm -f' before the first stock LLEXT module rather than passing --reset to llext_link_helper.py and llext_offset_calc.py (both scripts already treat a missing size_file as size 0). Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
lgirdwood
left a comment
There was a problem hiding this comment.
In general needs a small one line inline comment for each code block, and a comment for each new function with doxygen for public functions. Alos not following why we have changes to llext build now that rlocatable llext is upstream
| switch (ret) { | ||
| case -EBUSY: | ||
| return IPC4_BUSY; | ||
| case -ENOTSUP: | ||
| return IPC4_UNAVAILABLE; | ||
| default: | ||
| return IPC4_ERROR_INVALID_PARAM; |
There was a problem hiding this comment.
can we LOG_ERR these to be helpful.
| for (i = 0; i < count; i++) { | ||
| int ret = sof_codec_info_add(owner, items[i]); | ||
|
|
||
| if (ret < 0) |
There was a problem hiding this comment.
if we fail let LOG_ERR
| ctx = _ext_lib->desc[lib_id]; | ||
| if (!ctx) | ||
| return -ENOENT; | ||
|
|
||
| module_id = LIB_MANAGER_PACK_LIB_ID(lib_id); | ||
| if (ctx->load_type == SOF_MAN_MOD_TYPE_LLEXT || | ||
| ctx->load_type == SOF_MAN_MOD_TYPE_LLEXT_AUX) { | ||
| ret = llext_manager_remove_library(module_id); | ||
| if (ret < 0) | ||
| return ret; | ||
| } else { | ||
| return -ENOTSUP; | ||
| } |
There was a problem hiding this comment.
lets LOG_ERR failures.
|
|
||
| ret = sof_codec_info_add_items(mctx, sec, sec_size / sizeof(uint32_t)); | ||
| if (ret < 0) | ||
| tr_warn(&lib_manager_tr, "failed to register codec info for mod %u: %d", |
There was a problem hiding this comment.
lets use Zephyr LOG APIs.
| tr_dbg(&lib_manager_tr, "remove %#zx @ %lx partition", part.size, part.start); | ||
| return k_mem_domain_remove_partition(domain, &part); | ||
| } | ||
|
|
There was a problem hiding this comment.
Lets add the use case and why this change fixes the use case in the commit message.
| #if defined(CONFIG_FFMPEG_DEC_APTX_HD) || defined(CONFIG_COMP_FFMPEG_DEC_STUB) | ||
| SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_APTX_HD, SOF_IPC_STREAM_PLAYBACK), | ||
| #endif | ||
| #if defined(CONFIG_FFMPEG_ENC_APTX_HD) | ||
| SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_APTX_HD, SOF_IPC_STREAM_CAPTURE), | ||
| #endif | ||
| #if defined(CONFIG_FFMPEG_DEC_G726) || defined(CONFIG_COMP_FFMPEG_DEC_STUB) | ||
| SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_G726, SOF_IPC_STREAM_PLAYBACK), | ||
| #endif | ||
| #if defined(CONFIG_FFMPEG_ENC_G726) | ||
| SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_G726, SOF_IPC_STREAM_CAPTURE), | ||
| #endif | ||
| #if defined(CONFIG_FFMPEG_DEC_ALAW) || defined(CONFIG_COMP_FFMPEG_DEC_STUB) | ||
| SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_ALAW, SOF_IPC_STREAM_PLAYBACK), | ||
| #endif | ||
| #if defined(CONFIG_FFMPEG_ENC_ALAW) | ||
| SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_ALAW, SOF_IPC_STREAM_CAPTURE), | ||
| #endif | ||
| #if defined(CONFIG_FFMPEG_DEC_MULAW) || defined(CONFIG_COMP_FFMPEG_DEC_STUB) | ||
| SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_MULAW, SOF_IPC_STREAM_PLAYBACK), | ||
| #endif | ||
| #if defined(CONFIG_FFMPEG_ENC_MULAW) | ||
| SOF_CODEC_INFO_ITEM(SND_AUDIOCODEC_MULAW, SOF_IPC_STREAM_CAPTURE), | ||
| #endif |
There was a problem hiding this comment.
this data must be runtime - I would expect to be able to load the ffmpeg llext mp3 decoder to any base firmware build. Yes we can split the ffmpeg-commo.llext from ffmpeg-mp3.llext and pull in the common as a dependecy for all ffmpeg modules.
| #ifdef CONFIG_MMU | ||
| size_t pre_pad_size = (uintptr_t)vma & (PAGE_SZ - 1); | ||
| void *aligned_vma = (__sparse_force uint8_t *)vma - pre_pad_size; | ||
| uint32_t k_flags = K_MEM_CACHE_WB; |
There was a problem hiding this comment.
commit message line wrapping is wrong.
|
|
||
| if (!size) | ||
| return; | ||
|
|
There was a problem hiding this comment.
we should explain why we do this in inline comment.
|
|
||
| static inline int sof_codec_info_add_items(const void *owner, const uint32_t *items, size_t count) | ||
| { | ||
| size_t i; |
There was a problem hiding this comment.
looks like this needs squashed into a previous patch in this PR.
| set(single_args LIB) | ||
| cmake_parse_arguments(PARSE_ARGV 1 SOF_LLEXT "${options}" "${single_args}" "${multi_args}") | ||
|
|
||
| cmake_path(SET SOF_BASE NORMALIZE ${APPLICATION_SOURCE_DIR}/..) |
There was a problem hiding this comment.
another patch that needs squashed.
Summary
Split the monolithic
ffmpeg_dec.llextarchive module into 25 standalone per-codec LLEXT modules (12 decoders, 11 encoders, and 2 audio filters), each with a dedicated UUID inuuid-registry.txtand<UUID>.binsymlink, keeping stock SOF openmodules insof-<plat>-openmodules.ri:ffmpeg_dec_{flac,aac,opus,mp3,alac,sbc,g722,aptx,aptx_hd,g726,alaw,mulaw}ffmpeg_enc_{mp3,aac,flac,alac,sbc,g722,aptx,aptx_hd,g726,alaw,mulaw}ffmpeg_af_{afftdn,alimiter}Each module compiles with
-fvisibility=hidden -ffunction-sections -fdata-sectionsand links a generated tiny codec/parser/filter shim registration archive againstlibavcodec_noco.a/libavfilter_noco.a/libswresample.a/libavutil.a/libnewlib_m.a(+libshine/libvo-aacencwhere selected) so unused FFmpeg codecs and parsers are dead-stripped.LLEXT VMA & Loading Infrastructure
NO_OFFSET_ADVANCE,TOP_DOWN, and--resetsupport tosof_llext_build(),scripts/llext_link_helper.py, andscripts/llext_offset_calc.pyso standalone per-codec decoders share the post-stock VMA slot (0xa0709000on PTL relocatable builds) while encoders (ROLE enc) andffmpeg_af_alimiterpack top-down fromCONFIG_LIBRARY_BASE_ADDRESS + CONFIG_LIBRARY_REGION_SIZEwithout advancingmodule_size.SOF_LLEXT_RETAIN(__attribute__((__retain__))) on.moduleand.mod_buildinfoso--gc-sectionsdoes not discard LLEXT manifests.CONFIG_LLEXT_HEAP_SIZE=32whenCOMP_FFMPEG_DEC=mandLLEXT_TYPE_ELF_RELOCATABLE=yso large relocatable LLEXT symbol tables (e.g.ffmpeg_dec_aac,ffmpeg_enc_mp3,ffmpeg_dec_opus) fit at load time.DEPENDS ${TOPDIR}/uuid-registry.txtinscripts/cmake/uuid-registry.cmakesouuid-registry.hregenerates automatically when UUIDs are added.Topology2
compr-ffmpeg.conf(COMPR_FFMPEG_LLEXT=true, default) andcompr-capture-ffmpeg.confto per-codec standalone module UUIDs, keeping monolithic UUID fallback whenCOMPR_FFMPEG_LLEXT=false.Dependencies
topic/runtime-codec-info, commits cherry-picked here for CI build/testing; will drop on rebase once ipc4: base_fw: runtime codec capability discovery for built-in and LLEXT modules #11472 merges, plus one include path fix inllext_manager_dram.cforsof/kernel/llext_manager.h)..sof_codec_inforefresh on runtime LLEXT load (andIPC4_COPIER_MODULE_CFG_PARAM_DRAIN_BYTESfor clean compressDRAINEOS).Testing
CONFIG_LLEXT_TYPE_ELF_RELOCATABLE=y(withCONFIG_VIRTUAL_HEAP=nandCONFIG_SOF_ZEPHYR_HEAP_SIZE=0x80000/0xc0000for compress PCM/FFmpeg buffer headroom):ffmpeg_dec_mp3.llext: loaded alongsidesof-ptl-openmodules.ri, openedlibavcodec (mp3), decodedtest_short.mp3.ffmpeg_dec_flac.llext(tested at0xc0000heap): extracted 34-byteSTREAMINFO, openedlibavcodec (flac), decodedtest.flac.ffmpeg_dec_aac.llext: loaded, openedlibavcodec (aac_fixed), decodedtest.aac.ffmpeg_enc_mp3.llext: loaded top-down, captured 16 KiB valid MPEG-1 Layer III frames (0xfffb9404...).ffmpeg_enc_aac.llext: loaded top-down, captured 16 KiB valid MPEG-2 ADTS AAC-LC frames (0xfff94c80...).intel_adsp/ace30/ptlwithCONFIG_LLEXT_TYPE_ELF_RELOCATABLE=y(VMA range0xa0688000..0xa0807c40, within0x180000).intel_adsp/ace30/ptlwithCONFIG_LLEXT_TYPE_ELF_SHAREDLIB=y(zero missing dynamic symbols across all 25 LLEXTs;rimagesigned).intel_adsp/ace30/ptlwithCONFIG_COMP_FFMPEG_DEC=m+CONFIG_COMP_FFMPEG_DEC_STUB=y, andCONFIG_COMP_FFMPEG_DEC=y(built-in).topology2_dev_sof-hda-generic-ffmpeg-*.tplgtargets validated withalsatplg(0 errors).Next Steps (Follow-up)