Skip to content

Commit 2da0845

Browse files
committed
userspace: proxy: Add support for llext modules
Add support for userspace llext loadable modules to the userspace proxy. Call lib_manager_start_agent unconditionally, even when the system agent is not used, as this function is responsible for creating the userspace module proxy. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent c51277d commit 2da0845

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

src/audio/module_adapter/library/userspace_proxy.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdint.h>
2727

2828
#include <sof/lib_manager.h>
29+
#include <sof/llext_manager.h>
2930
#include <sof/audio/component.h>
3031
#include <sof/schedule/dp_schedule.h>
3132
#include <rtos/userspace_helper.h>
@@ -163,6 +164,7 @@ static int user_work_item_init(struct userspace_context *user_ctx, struct k_heap
163164
work_item->event = &worker.event;
164165
#endif
165166
work_item->params.context = user_ctx;
167+
work_item->params.mod = NULL;
166168
user_ctx->work_item = work_item;
167169

168170
return 0;
@@ -382,7 +384,7 @@ static int userspace_proxy_start_agent(struct userspace_context *user_ctx,
382384
}
383385

384386
int userspace_proxy_create(struct userspace_context **user_ctx, const struct comp_driver *drv,
385-
const struct sof_man_module *manifest, system_agent_start_fn start_fn,
387+
const struct sof_man_module *manifest, system_agent_start_fn agent_fn,
386388
const struct system_agent_params *agent_params,
387389
const void **agent_interface, const struct module_interface **ops)
388390
{
@@ -410,15 +412,20 @@ int userspace_proxy_create(struct userspace_context **user_ctx, const struct com
410412
if (ret)
411413
goto error_dom;
412414

413-
ret = userspace_proxy_add_sections(context, agent_params->instance_id, manifest);
415+
if (agent_fn)
416+
ret = userspace_proxy_add_sections(context, agent_params->instance_id, manifest);
417+
else
418+
/* llext modules do not use the system agent. */
419+
ret = llext_manager_add_domain(agent_params->module_id, domain);
420+
414421
if (ret)
415422
goto error_dom;
416423

417424
ret = user_work_item_init(context, drv->user_heap);
418425
if (ret)
419426
goto error_dom;
420427

421-
ret = userspace_proxy_start_agent(context, start_fn, agent_params, agent_interface);
428+
ret = userspace_proxy_start_agent(context, agent_fn, agent_params, agent_interface);
422429
if (ret) {
423430
tr_err(&userspace_proxy_tr, "System agent failed with error %d.", ret);
424431
goto error_work_item;

src/library_manager/lib_manager.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,14 @@ static int lib_manager_start_agent(const struct comp_driver *drv,
543543
return ret;
544544
}
545545
#endif /* CONFIG_SOF_USERSPACE_PROXY */
546+
if (agent) {
547+
ret = agent(&agent_params, agent_interface);
548+
if (ret)
549+
tr_err(&lib_manager_tr, "System agent start failed %d!", ret);
550+
return ret;
551+
}
546552

547-
ret = agent(&agent_params, agent_interface);
548-
if (ret)
549-
tr_err(&lib_manager_tr, "System agent start failed %d!", ret);
550-
551-
return ret;
553+
return 0;
552554
}
553555

554556
enum buildinfo_mod_type { MOD_TYPE_INVALID, MOD_TYPE_IADK, MOD_TYPE_LMDK, MOD_TYPE_LLEXT };
@@ -654,6 +656,7 @@ static struct comp_dev *lib_manager_module_create(const struct comp_driver *drv,
654656
case MOD_TYPE_LLEXT:
655657
agent = NULL;
656658
ops = (const struct module_interface *)module_entry_point;
659+
agent_iface = NULL;
657660
break;
658661
case MOD_TYPE_LMDK:
659662
agent = &native_system_agent_start;
@@ -671,12 +674,10 @@ static struct comp_dev *lib_manager_module_create(const struct comp_driver *drv,
671674
}
672675

673676
/* At this point module resources are allocated and it is moved to L2 memory. */
674-
if (agent) {
675-
ret = lib_manager_start_agent(drv, config, mod, args, module_entry_point, agent,
676-
agent_iface, &userspace, &ops);
677-
if (ret)
678-
goto err;
679-
}
677+
ret = lib_manager_start_agent(drv, config, mod, args, module_entry_point, agent,
678+
agent_iface, &userspace, &ops);
679+
if (ret)
680+
goto err;
680681

681682
if (comp_set_adapter_ops(drv, ops) < 0)
682683
goto err;

0 commit comments

Comments
 (0)