Skip to content

Commit 5361a57

Browse files
committed
dp: thread: Remove user_memory_init_shared()
Remove the no longer needed user_memory_init_shared(). Add the dp thread to the memory domain directly in the dp scheduler. The function originally added the common partition to the memory domain and added thread to that domain. The userspace proxy now adds the common partition to memory domain, so the function cannot perform this step. Grant access to thread only when userspace is used. Kernel threads have access to all the memory, no need to additionally grant access to them. user_memory_init_shared
1 parent e32e702 commit 5361a57

3 files changed

Lines changed: 6 additions & 29 deletions

File tree

src/schedule/zephyr_dp_schedule_thread.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <rtos/task.h>
99

1010
#include <sof/audio/module_adapter/module/generic.h>
11+
#include <sof/audio/module_adapter/library/userspace_proxy.h>
1112
#include <sof/common.h>
1213
#include <sof/list.h>
1314
#include <sof/schedule/ll_schedule_domain.h>
@@ -277,13 +278,13 @@ int scheduler_dp_task_init(struct task **task,
277278
}
278279

279280
#ifdef CONFIG_USERSPACE
280-
k_thread_access_grant(pdata->thread_id, pdata->event);
281-
scheduler_dp_grant(pdata->thread_id, cpu_get_id());
281+
if (options & K_USER) {
282+
k_thread_access_grant(pdata->thread_id, pdata->event);
283+
scheduler_dp_grant(pdata->thread_id, core);
282284

283-
if (task_memory->task.flags & K_USER) {
284-
ret = user_memory_init_shared(pdata->thread_id, pdata->mod);
285+
ret = k_mem_domain_add_thread(pdata->mod->user_ctx->comp_dom, pdata->thread_id);
285286
if (ret < 0) {
286-
tr_err(&dp_tr, "user_memory_init_shared() failed");
287+
tr_err(&dp_tr, "k_mem_domain_add_thread() failed %d", ret);
287288
goto e_thread;
288289
}
289290
}

zephyr/include/rtos/userspace_helper.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ struct userspace_context;
4242
*/
4343
struct k_heap *module_driver_heap_init(void);
4444

45-
/**
46-
* Add DP scheduler created thread to module memory domain.
47-
* @param thread_id - id of thread to be added to memory domain.
48-
* @param module - processing module structure
49-
*
50-
* @return 0 for success, error otherwise.
51-
*
52-
* @note
53-
* Function used only when CONFIG_USERSPACE is set.
54-
*/
55-
int user_memory_init_shared(k_tid_t thread_id, struct processing_module *mod);
56-
5745
/**
5846
* Attach common userspace memory partition to a module memory domain.
5947
* @param dom - memory domain to attach the common partition to.

zephyr/lib/userspace_helper.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ int user_stack_free(void *p_stack)
7777
return k_thread_stack_free(p_stack);
7878
}
7979

80-
int user_memory_init_shared(k_tid_t thread_id, struct processing_module *mod)
81-
{
82-
struct k_mem_domain *comp_dom = mod->user_ctx->comp_dom;
83-
int ret;
84-
85-
ret = k_mem_domain_add_partition(comp_dom, &common_partition);
86-
if (ret < 0)
87-
return ret;
88-
89-
return k_mem_domain_add_thread(comp_dom, thread_id);
90-
}
91-
9280
int user_memory_attach_common_partition(struct k_mem_domain *dom)
9381
{
9482
return k_mem_domain_add_partition(dom, &common_partition);

0 commit comments

Comments
 (0)