Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/overlays/ptl/userspace_overlay.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_USERSPACE=y
CONFIG_XTENSA_MMU_NUM_L2_TABLES=86
CONFIG_MAX_THREAD_BYTES=4

CONFIG_INIT_STACKS=n
CONFIG_THREAD_STACK_INFO=n
CONFIG_DYNAMIC_THREAD_PREFER_ALLOC=y
CONFIG_DYNAMIC_THREAD=y
CONFIG_DYNAMIC_THREAD_POOL_SIZE=4
CONFIG_DYNAMIC_THREAD_ALLOC=n
# IADK module adapter store some buffers on stack, so we need to increase stack size
CONFIG_DYNAMIC_THREAD_STACK_SIZE=8192
CONFIG_SOF_STACK_SIZE=8192
3 changes: 3 additions & 0 deletions posix/include/rtos/userspace_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

#include <rtos/alloc.h>

#define APP_TASK_BSS
#define APP_TASK_DATA

struct sys_heap;

#ifdef CONFIG_USERSPACE
Expand Down
5 changes: 3 additions & 2 deletions src/audio/buffers/comp_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sof/audio/sink_api.h>
#include <sof/audio/source_api.h>
#include <sof/audio/sink_source_utils.h>
#include <rtos/userspace_helper.h>
#include <sof/common.h>
#include <rtos/interrupt.h>
#include <rtos/alloc.h>
Expand Down Expand Up @@ -161,7 +162,7 @@ static void comp_buffer_free(struct sof_audio_buffer *audio_buffer)
rfree(buffer);
}

static const struct source_ops comp_buffer_source_ops = {
APP_TASK_DATA static const struct source_ops comp_buffer_source_ops = {
.get_data_available = comp_buffer_get_data_available,
.get_data = comp_buffer_get_data,
.release_data = comp_buffer_release_data,
Expand All @@ -170,7 +171,7 @@ static const struct source_ops comp_buffer_source_ops = {
.set_alignment_constants = audio_buffer_source_set_alignment_constants,
};

static const struct sink_ops comp_buffer_sink_ops = {
APP_TASK_DATA static const struct sink_ops comp_buffer_sink_ops = {
.get_free_size = comp_buffer_get_free_size,
.get_buffer = comp_buffer_get_buffer,
.commit_buffer = comp_buffer_commit_buffer,
Expand Down
9 changes: 7 additions & 2 deletions src/audio/pipeline/pipeline-schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sof/audio/module_adapter/module/generic.h>

LOG_MODULE_DECLARE(pipe, CONFIG_SOF_LOG_LEVEL);

Expand All @@ -39,7 +40,7 @@ SOF_DEFINE_REG_UUID(dp_task);
* current static stack size for each DP component
* TODO: to be taken from module manifest
*/
#define TASK_DP_STACK_SIZE 8192
#define TASK_DP_STACK_SIZE CONFIG_SOF_STACK_SIZE

#endif /* CONFIG_ZEPHYR_DP_SCHEDULER */

Expand Down Expand Up @@ -397,7 +398,11 @@ int pipeline_comp_dp_task_init(struct comp_dev *comp)
&ops,
mod,
comp->ipc_config.core,
TASK_DP_STACK_SIZE);
TASK_DP_STACK_SIZE,
#if CONFIG_USERSPACE
mod->user_ctx ? K_USER :
#endif /* CONFIG_USERSPACE */
0);
if (ret < 0)
return ret;
}
Expand Down
6 changes: 3 additions & 3 deletions src/idc/idc.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ static int idc_prepare(uint32_t comp_id)
/* we're running LL on different core, so allocate our own task */
if (!dev->task && dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL) {
/* allocate task for shared component */
dev->task = rzalloc(SOF_MEM_FLAG_USER,
sizeof(*dev->task));
dev->task = module_driver_heap_rzalloc(dev->drv->user_heap, SOF_MEM_FLAG_USER,
sizeof(*dev->task));
if (!dev->task) {
ret = -ENOMEM;
goto out;
Expand All @@ -197,7 +197,7 @@ static int idc_prepare(uint32_t comp_id)
dev->priority, comp_task, dev,
dev->ipc_config.core, 0);
if (ret < 0) {
rfree(dev->task);
module_driver_heap_free(dev->drv->user_heap, dev->task);
goto out;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/include/module/module/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ enum module_processing_type {
MODULE_PROCESS_TYPE_RAW,
};

struct userspace_context;

/*
* A pointer to this structure is passed to module API functions (from struct module_interface).
* This structure should contain only fields that should be available to a module.
Expand Down Expand Up @@ -180,6 +182,9 @@ struct processing_module {
uint32_t max_sinks;

enum module_processing_type proc_type;
#if CONFIG_USERSPACE
struct userspace_context *user_ctx;
#endif /* CONFIG_USERSPACE */
#endif /* SOF_MODULE_PRIVATE */
};

Expand Down
2 changes: 1 addition & 1 deletion src/include/sof/audio/component_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static inline void comp_free(struct comp_dev *dev)
if ((dev->is_shared || dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) &&
dev->task) {
schedule_task_free(dev->task);
rfree(dev->task);
module_driver_heap_free(dev->drv->user_heap, dev->task);
dev->task = NULL;
}

Expand Down
25 changes: 25 additions & 0 deletions src/include/sof/audio/module_adapter/library/userspace_proxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2025 Intel Corporation. All rights reserved.
*
* Author: Jaroslaw Stelter <jaroslaw.stelter@intel.com>
* Author: Adrian Warecki <adrian.warecki@intel.com>
*/

#ifndef __SOF_AUDIO_USERSPACE_PROXY_H__
#define __SOF_AUDIO_USERSPACE_PROXY_H__

#if CONFIG_USERSPACE
#include <stdint.h>
#include <stdbool.h>

#include <zephyr/kernel.h>

/* Processing module structure fields needed for user mode */
struct userspace_context {
struct k_mem_domain *comp_dom; /* Module specific memory domain */
};

#endif /* CONFIG_USERSPACE */

#endif /* __SOF_AUDIO_USERSPACE_PROXY_H__ */
4 changes: 3 additions & 1 deletion src/include/sof/schedule/dp_schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ int scheduler_dp_init(void);
* \param[in] mod pointer to the module to be run
* \param[in] core CPU the thread should run on
* \param[in] stack_size size of stack for a zephyr task
* \param[in] options task options used for creation
*/
int scheduler_dp_task_init(struct task **task,
const struct sof_uuid_entry *uid,
const struct task_ops *ops,
struct processing_module *mod,
uint16_t core,
size_t stack_size);
size_t stack_size,
uint32_t options);

/**
* \brief Extract information about scheduler's tasks
Expand Down
Loading
Loading