Skip to content

Commit f587336

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 6e1887a commit f587336

2 files changed

Lines changed: 20 additions & 12 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;
@@ -384,7 +386,7 @@ static int userspace_proxy_start_agent(struct userspace_context *user_ctx,
384386
}
385387

386388
int userspace_proxy_create(struct userspace_context **user_ctx, const struct comp_driver *drv,
387-
const struct sof_man_module *manifest, system_agent_start_fn start_fn,
389+
const struct sof_man_module *manifest, system_agent_start_fn agent_fn,
388390
const struct system_agent_params *agent_params,
389391
const void **agent_interface, const struct module_interface **ops)
390392
{
@@ -412,15 +414,20 @@ int userspace_proxy_create(struct userspace_context **user_ctx, const struct com
412414
if (ret)
413415
goto error_dom;
414416

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

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

423-
ret = userspace_proxy_start_agent(context, start_fn, agent_params, agent_interface);
430+
ret = userspace_proxy_start_agent(context, agent_fn, agent_params, agent_interface);
424431
if (ret) {
425432
tr_err(&userspace_proxy_tr, "System agent failed with error %d.", ret);
426433
goto error_work_item;

src/library_manager/lib_manager.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static int lib_manager_start_agent(const struct comp_driver *drv,
520520
{
521521
struct system_agent_params agent_params;
522522
byte_array_t mod_cfg;
523-
int ret;
523+
int ret = 0;
524524

525525
mod_cfg.data = (uint8_t *)args->data;
526526
/* Intel modules expects DW size here */
@@ -540,13 +540,13 @@ static int lib_manager_start_agent(const struct comp_driver *drv,
540540
agent_interface, ops);
541541
if (ret)
542542
tr_err(&lib_manager_tr, "userspace_proxy_create failed! %d", ret);
543-
return ret;
544-
}
543+
} else
545544
#endif /* CONFIG_SOF_USERSPACE_PROXY */
546-
547-
ret = agent(&agent_params, agent_interface);
548-
if (ret)
549-
tr_err(&lib_manager_tr, "System agent start failed %d!", ret);
545+
if (agent) {
546+
ret = agent(&agent_params, agent_interface);
547+
if (ret)
548+
tr_err(&lib_manager_tr, "System agent start failed %d!", ret);
549+
}
550550

551551
return ret;
552552
}
@@ -654,6 +654,7 @@ static struct comp_dev *lib_manager_module_create(const struct comp_driver *drv,
654654
case MOD_TYPE_LLEXT:
655655
agent = NULL;
656656
ops = (const struct module_interface *)module_entry_point;
657+
agent_iface = NULL;
657658
break;
658659
case MOD_TYPE_LMDK:
659660
agent = &native_system_agent_start;
@@ -670,8 +671,8 @@ static struct comp_dev *lib_manager_module_create(const struct comp_driver *drv,
670671
goto err;
671672
}
672673

673-
/* At this point module resources are allocated and it is moved to L2 memory. */
674-
if (agent) {
674+
if (agent || IS_ENABLED(CONFIG_SOF_USERSPACE_PROXY)) {
675+
/* At this point module resources are allocated and it is moved to L2 memory. */
675676
ret = lib_manager_start_agent(drv, config, mod, args, module_entry_point, agent,
676677
agent_iface, &userspace, &ops);
677678
if (ret)

0 commit comments

Comments
 (0)