llext: check whether the first instance is initialised

We need to tell Zephyr whether or not to perform local relocations.
Check persistent library data to distinguish the first instantiation
from the following ones.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2024-04-10 15:16:03 +02:00 committed by Liam Girdwood
parent 9dca9832d8
commit 132fdafbf4
2 changed files with 3 additions and 2 deletions

View File

@ -464,7 +464,7 @@ static void lib_manager_update_sof_ctx(void *base_addr, uint32_t lib_id)
{ {
struct ext_library *_ext_lib = ext_lib_get(); struct ext_library *_ext_lib = ext_lib_get();
/* Never freed, will panic if fails */ /* Never freed, will panic if fails */
struct lib_manager_mod_ctx *ctx = rmalloc(SOF_MEM_ZONE_SYS, 0, SOF_MEM_CAPS_RAM, struct lib_manager_mod_ctx *ctx = rzalloc(SOF_MEM_ZONE_SYS, 0, SOF_MEM_CAPS_RAM,
sizeof(*ctx)); sizeof(*ctx));
ctx->base_addr = base_addr; ctx->base_addr = base_addr;

View File

@ -176,8 +176,9 @@ static int llext_manager_link(struct sof_man_fw_desc *desc, struct sof_man_modul
struct llext_buf_loader ebl = LLEXT_BUF_LOADER((uint8_t *)desc - struct llext_buf_loader ebl = LLEXT_BUF_LOADER((uint8_t *)desc -
SOF_MAN_ELF_TEXT_OFFSET + 0x8000, SOF_MAN_ELF_TEXT_OFFSET + 0x8000,
mod_size); mod_size);
struct llext_load_param ldr_parm = {false};
struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id); struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id);
/* Identify if this is the first time loading this module */
struct llext_load_param ldr_parm = {!ctx->segment_size[SOF_MAN_SEGMENT_TEXT]};
int ret = llext_load(&ebl.loader, mod->name, &md->llext, &ldr_parm); int ret = llext_load(&ebl.loader, mod->name, &md->llext, &ldr_parm);
if (ret < 0) if (ret < 0)