Skip to content

Commit f2d4b55

Browse files
committed
schedule: dp: userspace: make scheduler_dp_internal_free() a syscall
Make scheduler_dp_internal_free() a syscall in the "application" DP implementation. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent bedd679 commit f2d4b55

3 files changed

Lines changed: 46 additions & 5 deletions

File tree

src/include/sof/schedule/dp_schedule.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ int scheduler_dp_task_init(struct task **task,
8080
uint32_t options);
8181

8282
#if defined(__ZEPHYR__) && CONFIG_SOF_FULL_ZEPHYR_APPLICATION
83+
#if CONFIG_SOF_USERSPACE_APPLICATION
84+
__syscall void scheduler_dp_internal_free(struct task *task);
85+
#else
86+
void scheduler_dp_internal_free(struct task *task);
87+
#endif
88+
8389
__syscall void scheduler_dp_ll_tick(unsigned int core);
8490
#include <zephyr/syscalls/dp_schedule.h>
8591
#endif

src/schedule/zephyr_dp_schedule.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,3 @@ void dp_thread_fn(void *p1, void *p2, void *p3);
5757
unsigned int scheduler_dp_lock(uint16_t core);
5858
void scheduler_dp_unlock(unsigned int key);
5959
void scheduler_dp_grant(k_tid_t thread_id, uint16_t core);
60-
int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
61-
const struct task_ops *ops, struct processing_module *mod,
62-
uint16_t core, size_t stack_size, uint32_t options);
63-
void scheduler_dp_internal_free(struct task *task);

src/schedule/zephyr_dp_schedule_application.c

Lines changed: 40 additions & 1 deletion
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/component.h>
1112
#include <sof/common.h>
1213
#include <sof/list.h>
1314
#include <sof/llext_manager.h>
@@ -400,7 +401,7 @@ struct scheduler_dp_task_memory {
400401
struct ipc4_flat flat;
401402
};
402403

403-
void scheduler_dp_internal_free(struct task *task)
404+
void z_impl_scheduler_dp_internal_free(struct task *task)
404405
{
405406
struct task_dp_pdata *pdata = task->priv_data;
406407

@@ -612,3 +613,41 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
612613
mod_free(mod, task_memory);
613614
return ret;
614615
}
616+
617+
#ifdef CONFIG_USERSPACE
618+
#include <zephyr/internal/syscall_handler.h>
619+
620+
static void scheduler_dp_mod_vrfy(struct processing_module *mod)
621+
{
622+
K_OOPS(K_SYSCALL_MEMORY_WRITE(mod, sizeof(*mod)));
623+
K_OOPS(K_SYSCALL_MEMORY_WRITE(mod->dev, sizeof(*mod->dev)));
624+
K_OOPS(K_SYSCALL_MEMORY_READ(mod->dev->drv, sizeof(*mod->dev->drv)));
625+
626+
struct mod_alloc_ctx *alloc = mod->priv.resources.alloc;
627+
628+
assert(alloc);
629+
if (alloc->heap) {
630+
size_t h_size = 0;
631+
uintptr_t h_start;
632+
633+
mod_heap_info(mod, &h_size, &h_start);
634+
if (h_size)
635+
K_OOPS(K_SYSCALL_MEMORY_WRITE(h_start, h_size));
636+
}
637+
if (alloc->vreg)
638+
K_OOPS(K_SYSCALL_MEMORY_WRITE(alloc->vreg_start, alloc->vreg_size));
639+
}
640+
641+
void z_vrfy_scheduler_dp_internal_free(struct task *task)
642+
{
643+
K_OOPS(K_SYSCALL_MEMORY_WRITE(task, sizeof(*task)));
644+
645+
struct task_dp_pdata *pdata = task->priv_data;
646+
647+
K_OOPS(K_SYSCALL_OBJ(pdata->event, K_OBJ_EVENT));
648+
K_OOPS(K_SYSCALL_OBJ_INIT(pdata->thread, K_OBJ_THREAD));
649+
scheduler_dp_mod_vrfy(pdata->mod);
650+
return z_impl_scheduler_dp_internal_free(task);
651+
}
652+
#include <zephyr/syscalls/scheduler_dp_internal_free_mrsh.c>
653+
#endif

0 commit comments

Comments
 (0)