diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 048eda0d47e0..9a0bb90aaea3 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -226,22 +226,26 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv, if (!mod) return NULL; + module_set_private_data(mod, mod_priv); + list_init(&mod->raw_data_buffers_list); +#if CONFIG_USERSPACE + mod->user_ctx = user_ctx; +#endif /* CONFIG_USERSPACE */ + struct comp_dev *dev = mod->dev; #if CONFIG_ZEPHYR_DP_SCHEDULER /* create a task for DP processing */ if (config->proc_domain == COMP_PROCESSING_DOMAIN_DP) { /* All data allocated, create a thread */ - pipeline_comp_dp_task_init(dev); + ret = pipeline_comp_dp_task_init(dev); + if (ret) { + comp_cl_err(drv, "DP task creation failed with error %d.", ret); + goto err; + } } #endif /* CONFIG_ZEPHYR_DP_SCHEDULER */ - module_set_private_data(mod, mod_priv); - list_init(&mod->raw_data_buffers_list); -#if CONFIG_USERSPACE - mod->user_ctx = user_ctx; -#endif /* CONFIG_USERSPACE */ - dst = &mod->priv.cfg; /* * NOTE: dst->ext_data points to stack variable and contains @@ -330,10 +334,6 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv, schedule_task_free(dev->task); #endif module_adapter_mem_free(mod); -#if CONFIG_IPC_MAJOR_4 - dst->ext_data = NULL; -#endif - return NULL; } diff --git a/src/schedule/zephyr_dp_schedule_thread.c b/src/schedule/zephyr_dp_schedule_thread.c index a2d703528b33..5d5d495b9160 100644 --- a/src/schedule/zephyr_dp_schedule_thread.c +++ b/src/schedule/zephyr_dp_schedule_thread.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -262,12 +263,12 @@ int scheduler_dp_task_init(struct task **task, /* success, fill the structures */ pdata->p_stack = p_stack; pdata->mod = mod; - *task = &task_memory->task; /* create a zephyr thread for the task */ pdata->thread_id = k_thread_create(pdata->thread, (__sparse_force void *)p_stack, - stack_size, dp_thread_fn, *task, NULL, NULL, - CONFIG_DP_THREAD_PRIORITY, (*task)->flags, K_FOREVER); + stack_size, dp_thread_fn, &task_memory->task, NULL, NULL, + CONFIG_DP_THREAD_PRIORITY, task_memory->task.flags, + K_FOREVER); /* pin the thread to specific core */ ret = k_thread_cpu_pin(pdata->thread_id, core); @@ -277,13 +278,13 @@ int scheduler_dp_task_init(struct task **task, } #ifdef CONFIG_USERSPACE - k_thread_access_grant(pdata->thread_id, pdata->event); - scheduler_dp_grant(pdata->thread_id, cpu_get_id()); + if (options & K_USER) { + k_thread_access_grant(pdata->thread_id, pdata->event); + scheduler_dp_grant(pdata->thread_id, core); - if ((*task)->flags & K_USER) { - ret = user_memory_init_shared(pdata->thread_id, pdata->mod); + ret = k_mem_domain_add_thread(pdata->mod->user_ctx->comp_dom, pdata->thread_id); if (ret < 0) { - tr_err(&dp_tr, "user_memory_init_shared() failed"); + tr_err(&dp_tr, "k_mem_domain_add_thread() failed %d", ret); goto e_thread; } } @@ -293,6 +294,8 @@ int scheduler_dp_task_init(struct task **task, k_event_init(pdata->event); k_thread_start(pdata->thread_id); + /* success, fill output parameter */ + *task = &task_memory->task; return 0; e_thread: diff --git a/west.yml b/west.yml index d5a72f1f3c35..f60267a887a2 100644 --- a/west.yml +++ b/west.yml @@ -43,7 +43,7 @@ manifest: - name: zephyr repo-path: zephyr - revision: b246d3f3f987f5ddfa6530bea2082c09ce1f00d8 + revision: d885cfebaa3464bf8bbf731a8b7f94854a90ae15 remote: zephyrproject # Import some projects listed in zephyr/west.yml@revision diff --git a/zephyr/include/rtos/userspace_helper.h b/zephyr/include/rtos/userspace_helper.h index 8cdcc4b291f6..29635fb942ad 100644 --- a/zephyr/include/rtos/userspace_helper.h +++ b/zephyr/include/rtos/userspace_helper.h @@ -42,18 +42,6 @@ struct userspace_context; */ struct k_heap *module_driver_heap_init(void); -/** - * Add DP scheduler created thread to module memory domain. - * @param thread_id - id of thread to be added to memory domain. - * @param module - processing module structure - * - * @return 0 for success, error otherwise. - * - * @note - * Function used only when CONFIG_USERSPACE is set. - */ -int user_memory_init_shared(k_tid_t thread_id, struct processing_module *mod); - /** * Attach common userspace memory partition to a module memory domain. * @param dom - memory domain to attach the common partition to. diff --git a/zephyr/lib/userspace_helper.c b/zephyr/lib/userspace_helper.c index 0aecf7079256..8c4aef423e15 100644 --- a/zephyr/lib/userspace_helper.c +++ b/zephyr/lib/userspace_helper.c @@ -77,18 +77,6 @@ int user_stack_free(void *p_stack) return k_thread_stack_free(p_stack); } -int user_memory_init_shared(k_tid_t thread_id, struct processing_module *mod) -{ - struct k_mem_domain *comp_dom = mod->user_ctx->comp_dom; - int ret; - - ret = k_mem_domain_add_partition(comp_dom, &common_partition); - if (ret < 0) - return ret; - - return k_mem_domain_add_thread(comp_dom, thread_id); -} - int user_memory_attach_common_partition(struct k_mem_domain *dom) { return k_mem_domain_add_partition(dom, &common_partition);