Skip to content

Commit 25caf94

Browse files
committed
llext: call llext_unload() internally
Currently lib_manager_module_free() first checks, if an LLEXT module is being freed. If so, it first calls llext_unload() and then - if the use-count is reported as zero, calls llext_manager_free_module(). Simplify this process by just calling llext_manager_free_module() and letting it handle llext_unload() internally. Signed-off-by: Guennadi Liakhovetski <[email protected]>
1 parent c22bd4c commit 25caf94

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/library_manager/lib_manager.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,18 +556,15 @@ static void lib_manager_module_free(struct comp_dev *dev)
556556
struct processing_module *mod = comp_mod(dev);
557557
const struct comp_ipc_config *const config = &mod->dev->ipc_config;
558558
const uint32_t module_id = config->id;
559-
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id);
560559
int ret;
561560

562561
/* This call invalidates dev, mod and config pointers! */
563562
module_adapter_free(dev);
564563

565-
if (!ctx->llext || !llext_unload(&ctx->llext)) {
566-
/* Free module resources allocated in L2 memory. */
567-
ret = lib_manager_free_module(module_id);
568-
if (ret < 0)
569-
comp_err(dev, "modules_free(), lib_manager_free_module() failed!");
570-
}
564+
/* Free module resources allocated in L2 memory. */
565+
ret = lib_manager_free_module(module_id);
566+
if (ret < 0)
567+
comp_err(dev, "modules_free(), lib_manager_free_module() failed!");
571568
}
572569

573570
static void lib_manager_prepare_module_adapter(struct comp_driver *drv, const struct sof_uuid *uuid)

src/library_manager/llext_manager.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,19 @@ int llext_manager_free_module(const uint32_t component_id)
352352
const uint32_t module_id = IPC4_MOD_ID(component_id);
353353
const unsigned int base_module_id = LIB_MANAGER_GET_LIB_ID(module_id) <<
354354
LIB_MANAGER_LIB_ID_SHIFT;
355+
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(base_module_id);
355356

356357
tr_dbg(&lib_manager_tr, "mod_id: %#x", component_id);
357358

359+
if (!ctx->llext) {
360+
tr_err(&lib_manager_tr, "NULL llext: ID %#x ctx %p", component_id, ctx);
361+
return -ENOENT;
362+
}
363+
364+
if (llext_unload(&ctx->llext))
365+
/* More users are active */
366+
return 0;
367+
358368
mod = lib_manager_get_module_manifest(base_module_id);
359369

360370
return llext_manager_unload_module(base_module_id, mod);

0 commit comments

Comments
 (0)