diff --git a/src/library_manager/lib_manager.c b/src/library_manager/lib_manager.c index 4bd20a89a9c7..7d458b48982b 100644 --- a/src/library_manager/lib_manager.c +++ b/src/library_manager/lib_manager.c @@ -233,6 +233,9 @@ static void __sparse_cache *lib_manager_get_instance_bss_address(uint32_t module uint32_t instance_id, struct sof_man_module *mod) { + if (mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT) + return (void __sparse_cache *)mod->segment[SOF_MAN_SEGMENT_BSS].v_base_addr; + uint32_t instance_bss_size = mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count; uint32_t inst_offset = instance_bss_size * PAGE_SZ * instance_id; @@ -250,11 +253,15 @@ static void __sparse_cache *lib_manager_get_instance_bss_address(uint32_t module static int lib_manager_allocate_module_instance(uint32_t module_id, uint32_t instance_id, uint32_t is_pages, struct sof_man_module *mod) { - size_t bss_size = - (mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count) - * PAGE_SZ; void __sparse_cache *va_base = lib_manager_get_instance_bss_address(module_id, instance_id, mod); + size_t bss_size; + + if (mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT) + bss_size = mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length * PAGE_SZ; + else + bss_size = (mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / + mod->instance_max_count) * PAGE_SZ; if ((is_pages * PAGE_SZ) > bss_size) { tr_err(&lib_manager_tr, @@ -275,12 +282,16 @@ static int lib_manager_allocate_module_instance(uint32_t module_id, uint32_t ins static int lib_manager_free_module_instance(uint32_t module_id, uint32_t instance_id, struct sof_man_module *mod) { - size_t bss_size = - (mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count) - * PAGE_SZ; + size_t bss_size; void __sparse_cache *va_base = lib_manager_get_instance_bss_address(module_id, instance_id, mod); + if (mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT) + bss_size = mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length * PAGE_SZ; + else + bss_size = (mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / + mod->instance_max_count) * PAGE_SZ; + /* Unmap bss memory. */ return lib_manager_align_unmap(va_base, bss_size); }