Skip to content

Commit

Permalink
lib_manager: llext_manager: Simplifying parameter list for free module
Browse files Browse the repository at this point in the history
Instead of a pointer to a component driver and ipc config, the
lib_manager_free_module and llext_manager_free_module functions now gets
component id.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
  • Loading branch information
softwarecki authored and kv2019i committed Mar 13, 2024
1 parent e0b6f5a commit 3c114b5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/audio/module_adapter/module/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ static int modules_free(struct processing_module *mod)
{
struct comp_dev *dev = mod->dev;
struct module_data *md = &mod->priv;
struct comp_ipc_config *config = &(mod->dev->ipc_config);
int ret;

comp_info(dev, "modules_free()");
Expand All @@ -314,7 +313,7 @@ static int modules_free(struct processing_module *mod)

if (!md->llext || !llext_unload(&md->llext)) {
/* Free module resources allocated in L2 memory. */
ret = lib_manager_free_module(mod, config);
ret = lib_manager_free_module(dev->ipc_config.id);
if (ret < 0)
comp_err(dev, "modules_free(), lib_manager_free_module() failed!");
}
Expand Down
8 changes: 3 additions & 5 deletions src/include/sof/lib_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,12 @@ uintptr_t lib_manager_allocate_module(struct processing_module *proc,
/*
* \brief Free module
*
* param[in] drv - component driver
* param[in] ipc_config - audio component base configuration from IPC at creation
* param[in] ipc_specific_config - ipc4 base configuration
* param[in] component_id - component id coming from ipc config. This function reguires valid
* lib_id and module_id fields of component id.
*
* Function is responsible to free module resources in HP memory.
*/
int lib_manager_free_module(struct processing_module *proc,
struct comp_ipc_config *ipc_config);
int lib_manager_free_module(const uint32_t component_id);
/*
* \brief Load library
*
Expand Down
4 changes: 2 additions & 2 deletions src/include/sof/llext_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct comp_ipc_config;
uintptr_t llext_manager_allocate_module(struct processing_module *proc,
struct comp_ipc_config *ipc_config,
const void *ipc_specific_config, const void **buildinfo);
int llext_manager_free_module(struct processing_module *proc,
struct comp_ipc_config *ipc_config);

int llext_manager_free_module(const uint32_t component_id);

#endif
14 changes: 6 additions & 8 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,21 @@ uintptr_t lib_manager_allocate_module(struct processing_module *proc,
return 0;
}

int lib_manager_free_module(struct processing_module *proc,
struct comp_ipc_config *ipc_config)
int lib_manager_free_module(const uint32_t component_id)
{
struct sof_man_fw_desc *desc;
struct sof_man_module *mod;
uint32_t module_id = IPC4_MOD_ID(ipc_config->id);
const uint32_t module_id = IPC4_MOD_ID(component_id);
uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id);
int ret;

tr_dbg(&lib_manager_tr, "lib_manager_free_module(): mod_id: %#x", ipc_config->id);
tr_dbg(&lib_manager_tr, "lib_manager_free_module(): mod_id: %#x", component_id);

desc = lib_manager_get_library_module_desc(module_id);
mod = (struct sof_man_module *)((char *)desc + SOF_MAN_MODULE_OFFSET(entry_index));

if (module_is_llext(mod))
return llext_manager_free_module(proc, ipc_config);
return llext_manager_free_module(component_id);

ret = lib_manager_unload_module(mod);
if (ret < 0)
Expand All @@ -423,7 +422,7 @@ int lib_manager_free_module(struct processing_module *proc,
return ret;
#endif /* CONFIG_LIBCODE_MODULE_SUPPORT */

ret = lib_manager_free_module_instance(module_id, IPC4_INST_ID(ipc_config->id), mod);
ret = lib_manager_free_module_instance(module_id, IPC4_INST_ID(component_id), mod);
if (ret < 0) {
tr_err(&lib_manager_tr,
"lib_manager_free_module(): free module instance failed: %d", ret);
Expand All @@ -445,8 +444,7 @@ uintptr_t lib_manager_allocate_module(struct processing_module *proc,
return 0;
}

int lib_manager_free_module(struct processing_module *proc,
struct comp_ipc_config *ipc_config)
int lib_manager_free_module(const uint32_t component_id)
{
/* Since we cannot allocate the freeing is not considered to be an error */
tr_warn(&lib_manager_tr,
Expand Down
7 changes: 3 additions & 4 deletions src/library_manager/llext_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,15 @@ uintptr_t llext_manager_allocate_module(struct processing_module *proc,
return mod_manifest->module.entry_point;
}

int llext_manager_free_module(struct processing_module *proc,
struct comp_ipc_config *ipc_config)
int llext_manager_free_module(const uint32_t component_id)
{
struct sof_man_fw_desc *desc;
struct sof_man_module *mod;
uint32_t module_id = IPC4_MOD_ID(ipc_config->id);
const uint32_t module_id = IPC4_MOD_ID(component_id);
uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id);
int ret;

tr_dbg(&lib_manager_tr, "llext_manager_free_module(): mod_id: %#x", ipc_config->id);
tr_dbg(&lib_manager_tr, "llext_manager_free_module(): mod_id: %#x", component_id);

desc = lib_manager_get_library_module_desc(module_id);
mod = (struct sof_man_module *)((char *)desc + SOF_MAN_MODULE_OFFSET(entry_index));
Expand Down

0 comments on commit 3c114b5

Please sign in to comment.