Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
lib_manager: llext_manager: Add const to variables and function parameters cleanup#8898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
2150489c79af9fd00db64cf6e031fdbe2a048870295950a18File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -728,7 +728,7 @@ int ipc4_chain_manager_create(struct ipc4_chain_dma *cdma) | ||
| const struct comp_driver *drv; | ||
| struct comp_dev *dev; | ||
| drv = ipc4_get_drv((uint8_t *)&uuid); | ||
| drv = ipc4_get_drv((const uint8_t *)&uuid); | ||
| if (!drv) | ||
| return -EINVAL; | ||
| @@ -864,7 +864,7 @@ int ipc4_process_on_core(uint32_t core, bool blocking) | ||
| return IPC4_SUCCESS; | ||
| } | ||
| const struct comp_driver *ipc4_get_drv(uint8_t *uuid) | ||
| const struct comp_driver *ipc4_get_drv(const uint8_t *uuid) | ||
| { | ||
| struct comp_driver_list *drivers = comp_drivers_get(); | ||
| struct list_item *clist; | ||
| @@ -934,7 +934,7 @@ static const struct comp_driver *ipc4_library_get_drv(int module_id) | ||
| mod_uuid = &uuid_map[i]; | ||
| if (mod_uuid->module_id == module_id) | ||
| return ipc4_get_drv((uint8_t *)&mod_uuid->uuid); | ||
| return ipc4_get_drv((const uint8_t *)&mod_uuid->uuid); | ||
| } | ||
| tr_err(&comp_tr, "ipc4_library_get_drv(): Unsupported module ID %#x\n", module_id); | ||
| @@ -990,7 +990,7 @@ const struct comp_driver *ipc4_get_comp_drv(int module_id) | ||
| #if CONFIG_LIBRARY_MANAGER | ||
| if (!drv) { | ||
| /* New module not registered yet. */ | ||
| lib_manager_register_module(desc, module_id); | ||
| lib_manager_register_module(module_id); | ||
softwarecki marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| drv = ipc4_get_drv(mod->uuid); | ||
| } | ||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -279,7 +279,7 @@ static int lib_manager_unload_libcode_modules(const uint32_t module_id, | ||
| static void __sparse_cache *lib_manager_get_instance_bss_address(uint32_t module_id, | ||
| uint32_t instance_id, | ||
| struct sof_man_module *mod) | ||
| const struct sof_man_module *mod) | ||
| { | ||
| uint32_t instance_bss_size = | ||
| mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count; | ||
| @@ -296,7 +296,7 @@ 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) | ||
| uint32_t is_pages, const struct sof_man_module *mod) | ||
| { | ||
| uint32_t bss_size = | ||
| (mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count) | ||
| @@ -324,7 +324,7 @@ 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) | ||
| const struct sof_man_module *mod) | ||
| { | ||
| uint32_t bss_size = | ||
| (mod->segment[SOF_MAN_SEGMENT_BSS].flags.r.length / mod->instance_max_count) | ||
| @@ -337,17 +337,17 @@ static int lib_manager_free_module_instance(uint32_t module_id, uint32_t instanc | ||
| return sys_mm_drv_unmap_region((__sparse_force void *)va_base, bss_size); | ||
| } | ||
| static bool module_is_llext(struct sof_man_module *mod) | ||
| static inline bool module_is_llext(const struct sof_man_module *mod) | ||
| { | ||
| return mod->type.load_type == SOF_MAN_MOD_TYPE_LLEXT; | ||
| } | ||
| uintptr_t lib_manager_allocate_module(struct processing_module *proc, | ||
| struct comp_ipc_config *ipc_config, | ||
| const struct comp_ipc_config *ipc_config, | ||
| const void *ipc_specific_config, const void **buildinfo) | ||
| { | ||
| struct sof_man_fw_desc *desc; | ||
| struct sof_man_module *mod; | ||
| const struct sof_man_module *mod; | ||
| const struct ipc4_base_module_cfg *base_cfg = ipc_specific_config; | ||
| int ret; | ||
| uint32_t module_id = IPC4_MOD_ID(ipc_config->id); | ||
| @@ -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) | ||
softwarecki marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| { | ||
| struct sof_man_fw_desc *desc; | ||
| struct sof_man_module *mod; | ||
| uint32_t module_id = IPC4_MOD_ID(ipc_config->id); | ||
| const struct sof_man_module *mod; | ||
| 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); | ||
softwarecki marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| 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) | ||
| @@ -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); | ||
| @@ -437,16 +436,15 @@ int lib_manager_free_module(struct processing_module *proc, | ||
| #define PAGE_SZ 4096 /* equals to MAN_PAGE_SIZE used by rimage */ | ||
| uintptr_t lib_manager_allocate_module(struct processing_module *proc, | ||
| struct comp_ipc_config *ipc_config, | ||
| const struct comp_ipc_config *ipc_config, | ||
| const void *ipc_specific_config, const void **buildinfo) | ||
| { | ||
| tr_err(&lib_manager_tr, | ||
| "lib_manager_allocate_module(): Dynamic module allocation is not supported"); | ||
| 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, | ||
| @@ -487,15 +485,28 @@ static void lib_manager_update_sof_ctx(void *base_addr, uint32_t lib_id) | ||
| } | ||
| #if CONFIG_INTEL_MODULES | ||
| int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id) | ||
| int lib_manager_register_module(const uint32_t component_id) | ||
softwarecki marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| { | ||
| uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id); | ||
| /* allocate new comp_driver_info */ | ||
| const struct lib_manager_mod_ctx *const ctx = lib_manager_get_mod_ctx(component_id); | ||
| const uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(component_id); | ||
| const struct sof_man_fw_desc *desc; | ||
| struct comp_driver_info *new_drv_info; | ||
| struct comp_driver *drv = NULL; | ||
| struct sof_man_module *mod; | ||
| int ret; | ||
| /* Get library manifest based on component_id */ | ||
| if (!ctx || !ctx->base_addr) | ||
| return -ENOENT; | ||
| desc = (const struct sof_man_fw_desc *)((const char *)ctx->base_addr + | ||
| SOF_MAN_ELF_TEXT_OFFSET); | ||
softwarecki marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (entry_index >= desc->header.num_module_entries) { | ||
| tr_err(&lib_manager_tr, "Entry index %d out of bounds.", entry_index); | ||
| return -ENOENT; | ||
| } | ||
| /* allocate new comp_driver_info */ | ||
| new_drv_info = rmalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, | ||
| SOF_MEM_CAPS_RAM | SOF_MEM_FLAG_COHERENT, | ||
| sizeof(struct comp_driver_info)); | ||
| @@ -520,7 +531,7 @@ int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id) | ||
| /* Fill the new_drv_info structure with already known parameters */ | ||
| /* Check already registered components */ | ||
| mod = (struct sof_man_module *)((uint8_t *)desc + SOF_MAN_MODULE_OFFSET(entry_index)); | ||
| struct sof_uuid *uid = (struct sof_uuid *)&mod->uuid[0]; | ||
| const struct sof_uuid *uid = (struct sof_uuid *)&mod->uuid[0]; | ||
| declare_dynamic_module_adapter(drv, SOF_COMP_MODULE_ADAPTER, uid, &lib_manager_tr); | ||
| @@ -539,7 +550,7 @@ int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id) | ||
| } | ||
| #else /* CONFIG_INTEL_MODULES */ | ||
| int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id) | ||
| int lib_manager_register_module(const uint32_t component_id) | ||
| { | ||
| tr_err(&lib_manager_tr, | ||
| "lib_manager_register_module(): Dynamic module loading is not supported"); | ||
| @@ -689,15 +700,25 @@ static void __sparse_cache *lib_manager_allocate_store_mem(uint32_t size, | ||
| } | ||
| static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext, | ||
| void __sparse_cache *man_buffer, | ||
| const void __sparse_cache *man_buffer, | ||
| uint32_t lib_id) | ||
| { | ||
| void __sparse_cache *library_base_address; | ||
| struct sof_man_fw_desc *man_desc = (struct sof_man_fw_desc *) | ||
| const struct sof_man_fw_desc *man_desc = (struct sof_man_fw_desc *) | ||
| ((__sparse_force uint8_t *)man_buffer + SOF_MAN_ELF_TEXT_OFFSET); | ||
| uint32_t preload_size = man_desc->header.preload_page_count * PAGE_SZ; | ||
| int ret; | ||
| /* | ||
| * The module manifest structure always has its maximum size regardless of | ||
| * the actual size of the manifest. | ||
| */ | ||
| if (preload_size < MAN_MAX_SIZE_V1_8) { | ||
softwarecki marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| tr_err(&lib_manager_tr, "Invalid preload_size value %x.", preload_size); | ||
| return -EINVAL; | ||
| } | ||
| /* Prepare storage memory, note: it is never freed, library unloading is unsupported */ | ||
| /* | ||
| * Prepare storage memory, note: it is never freed, it is assumed, that this | ||
| * memory is abundant, so we store all loaded modules there permanently | ||
| @@ -711,7 +732,7 @@ static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext, | ||
| #if CONFIG_LIBRARY_AUTH_SUPPORT | ||
| /* AUTH_PHASE_FIRST - checks library manifest only. */ | ||
| ret = lib_manager_auth_proc((__sparse_force void *)man_buffer, | ||
| ret = lib_manager_auth_proc((__sparse_force const void *)man_buffer, | ||
| MAN_MAX_SIZE_V1_8, AUTH_PHASE_FIRST); | ||
| if (ret < 0) { | ||
| rfree((__sparse_force void *)library_base_address); | ||
| @@ -721,7 +742,7 @@ static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext, | ||
| /* Copy data from temp_mft_buf to destination memory (pointed by library_base_address) */ | ||
| memcpy_s((__sparse_force void *)library_base_address, MAN_MAX_SIZE_V1_8, | ||
| (__sparse_force void *)man_buffer, MAN_MAX_SIZE_V1_8); | ||
| (__sparse_force const void *)man_buffer, MAN_MAX_SIZE_V1_8); | ||
| /* Copy remaining library part into storage buffer */ | ||
| ret = lib_manager_store_data(dma_ext, (uint8_t __sparse_cache *)library_base_address + | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.