Skip to content

Commit cf63f48

Browse files
committed
ipc: add the DP case to module initialization
ipc4_init_module_instance() should be called when CONFIG_SOF_USERSPACE_LL isn't selected but also when initializing a DP module. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 3cdb892 commit cf63f48

2 files changed

Lines changed: 37 additions & 41 deletions

File tree

src/ipc/ipc4/handler-user.c

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,7 @@ __cold static int ipc4_delete_module_instance(struct ipc4_message_request *ipc4)
15561556
__cold int ipc4_user_process_module_message(struct ipc4_message_request *ipc4,
15571557
struct ipc_msg *reply)
15581558
{
1559+
struct ipc4_module_init_instance *mi;
15591560
uint32_t type;
15601561
int ret;
15611562

@@ -1566,36 +1567,37 @@ __cold int ipc4_user_process_module_message(struct ipc4_message_request *ipc4,
15661567

15671568
switch (type) {
15681569
case SOF_IPC4_MOD_INIT_INSTANCE:
1570+
mi = (struct ipc4_module_init_instance *)ipc4;
1571+
1572+
if (mi->extension.r.proc_domain || !IS_ENABLED(CONFIG_SOF_USERSPACE_LL)) {
1573+
ret = ipc4_init_module_instance(ipc4);
1574+
} else {
15691575
#ifdef CONFIG_SOF_USERSPACE_LL
1570-
{
1571-
/* User-space init: kernel does driver lookup only (requires
1572-
* access to IMR manifest and driver list in kernel memory).
1573-
* Component creation (drv->ops.create) runs in user thread
1574-
* so untrusted module code does not execute in kernel context.
1575-
*/
1576-
struct ipc4_module_init_instance *mi = (struct ipc4_module_init_instance *)ipc4;
1577-
struct ipc *ipc = ipc_get();
1578-
uint32_t comp_id = IPC4_COMP_ID(mi->primary.r.module_id,
1579-
mi->primary.r.instance_id);
1580-
const struct comp_driver *drv = ipc4_get_comp_drv(IPC4_MOD_ID(comp_id));
1576+
/* User-space init: kernel does driver lookup only (requires
1577+
* access to IMR manifest and driver list in kernel memory).
1578+
* Component creation (drv->ops.create) runs in user thread
1579+
* so untrusted module code does not execute in kernel context.
1580+
*/
1581+
struct ipc *ipc = ipc_get();
1582+
uint32_t comp_id = IPC4_COMP_ID(mi->primary.r.module_id,
1583+
mi->primary.r.instance_id);
1584+
const struct comp_driver *drv = ipc4_get_comp_drv(IPC4_MOD_ID(comp_id));
15811585

1582-
if (!drv) {
1583-
ret = IPC4_MOD_NOT_INITIALIZED;
1584-
break;
1585-
}
1586+
if (!drv) {
1587+
ret = IPC4_MOD_NOT_INITIALIZED;
1588+
break;
1589+
}
15861590

1587-
struct ipc_user *pdata = ipc->ipc_user_pdata;
1591+
ret = llext_manager_map_lib(comp_id);
1592+
if (ret < 0)
1593+
break;
15881594

1589-
ret = llext_manager_map_lib(comp_id);
1590-
if (ret < 0)
1591-
break;
1595+
struct ipc_user *pdata = ipc->ipc_user_pdata;
15921596

1593-
pdata->init_drv = drv;
1594-
ret = ipc_user_forward_cmd(ipc4, mi->extension.r.core_id);
1595-
}
1596-
#else
1597-
ret = ipc4_init_module_instance(ipc4);
1597+
pdata->init_drv = drv;
1598+
ret = ipc_user_forward_cmd(ipc4, mi->extension.r.core_id);
15981599
#endif
1600+
}
15991601
break;
16001602
case SOF_IPC4_MOD_CONFIG_GET:
16011603
#ifdef CONFIG_SOF_USERSPACE_LL

src/ipc/ipc4/helper.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,16 @@ __cold struct comp_dev *comp_new_ipc4(const struct ipc4_module_init_instance *mo
161161
if (!drv)
162162
return NULL;
163163

164-
#if CONFIG_ZEPHYR_DP_SCHEDULER
165-
if (module_init->extension.r.proc_domain)
166-
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_DP;
167-
else
164+
if (!module_init->extension.r.proc_domain) {
168165
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_LL;
169-
#else /* CONFIG_ZEPHYR_DP_SCHEDULER */
170-
if (module_init->extension.r.proc_domain) {
171-
tr_err(&ipc_tr, "ipc: DP scheduling is disabled, cannot create comp 0x%x", comp_id);
166+
} else if (IS_ENABLED(CONFIG_ZEPHYR_DP_SCHEDULER)) {
167+
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_DP;
168+
} else {
169+
tr_err(&ipc_tr,
170+
"ipc: DP scheduling is disabled, cannot create comp 0x%x",
171+
comp_id);
172172
return NULL;
173173
}
174-
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_LL;
175-
#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */
176174

177175
if (drv->type == SOF_COMP_MODULE_ADAPTER) {
178176
const struct ipc_config_process spec = {
@@ -272,20 +270,16 @@ __cold struct comp_dev *comp_new_ipc4_user(struct ipc4_message_request *ipc4,
272270
#endif
273271
data = ipc4_get_comp_new_data();
274272

275-
#if CONFIG_ZEPHYR_DP_SCHEDULER
276-
if (module_init.extension.r.proc_domain)
277-
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_DP;
278-
else
273+
if (!module_init.extension.r.proc_domain) {
279274
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_LL;
280-
#else
281-
if (module_init.extension.r.proc_domain) {
275+
} else if (IS_ENABLED(CONFIG_ZEPHYR_DP_SCHEDULER)) {
276+
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_DP;
277+
} else {
282278
tr_err(&ipc_tr,
283279
"ipc: DP scheduling is disabled, cannot create comp 0x%x",
284280
comp_id);
285281
return NULL;
286282
}
287-
ipc_config.proc_domain = COMP_PROCESSING_DOMAIN_LL;
288-
#endif
289283

290284
if (drv->type == SOF_COMP_MODULE_ADAPTER) {
291285
const struct ipc_config_process spec = {

0 commit comments

Comments
 (0)