Skip to content
Open
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
8 changes: 1 addition & 7 deletions app/overlays/ptl/ll_userspace_overlay.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,23 @@ CONFIG_SOF_USERSPACE_LL=y
# make the drivers work in user-space
CONFIG_SOF_USERSPACE_INTERFACE_DMA=y
CONFIG_DAI_USERSPACE=y
CONFIG_MAX_THREAD_BYTES=4

# Temporary settings that are needed currently to enable user-space LL
# --------------------------------------------------------------------

# problem with DSP panics due to illegal instruction hit in user-space if cold
# store execution is enabled. Disable it for now until rootcause is found.
CONFIG_COLD_STORE_EXECUTE_DRAM=n
CONFIG_COLD_STORE_EXECUTE_DEBUG=n

# telemetry not yet user-space compatible
CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS=n
CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS=n

# disable loadable modules (hits privilege issues in user-space now)
CONFIG_LLEXT_STORAGE_WRITABLE=n
CONFIG_LLEXT_EXPERIMENTAL=n
CONFIG_MODULES=n

# some of current boot tests interfere with user-space setup
CONFIG_SOF_BOOT_TEST_ALLOWED=n

# misc features not yet compatible with user-space
CONFIG_CROSS_CORE_STREAM=n
CONFIG_INTEL_ADSP_MIC_PRIVACY=n
CONFIG_XRUN_NOTIFICATIONS_ENABLE=n
CONFIG_ZEPHYR_DP_SCHEDULER=n
8 changes: 8 additions & 0 deletions src/include/ipc4/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ struct ipc4_message_request;
*/
int ipc4_user_process_module_message(struct ipc4_message_request *ipc4, struct ipc_msg *reply);

/**
* \brief Load a dynamically loadable module.
* @param[in] drv Component driver.
* @param[in] mi SOF_IPC4_MOD_INIT_INSTANCE data
*/
int ipc4_user_module_load(const struct comp_driver *drv,
const struct ipc4_module_init_instance *mi);

/**
* @brief Process MOD_CONFIG_GET or MOD_CONFIG_SET in any execution context.
* @param[in] ipc4 IPC4 message request.
Expand Down
28 changes: 24 additions & 4 deletions src/include/sof/ipc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ extern struct tr_ctx ipc_tr;
#define IPC_TASK_SECONDARY_CORE BIT(2)
#define IPC_TASK_POWERDOWN BIT(3)

#ifdef CONFIG_CORE_COUNT
#define CORE_COUNT CONFIG_CORE_COUNT
#else
#define CORE_COUNT 1
#endif

struct ipc_user {
struct k_thread *thread;
struct k_thread *thread[CORE_COUNT];
struct k_sem *sem;
struct k_event *event;
struct k_event *event[CORE_COUNT];
/** @brief Copy of IPC4 message primary word forwarded to user thread */
uint32_t ipc_msg_pri;
/** @brief Copy of IPC4 message extension word forwarded to user thread */
Expand All @@ -73,9 +79,10 @@ struct ipc_user {
/** @brief Reply TX data pointer from user thread (e.g. LARGE_CONFIG_GET result) */
void *reply_tx_data;
struct ipc *ipc;
struct k_thread *audio_thread;
struct k_thread *audio_thread[CORE_COUNT];
/** @brief Original kernel driver pointer for restoring dev->drv after create */
const struct comp_driver *init_drv;
bool init_needed[CORE_COUNT];
/**
* @brief User-accessible copy of comp_driver + tr_ctx for create().
*
Expand Down Expand Up @@ -326,7 +333,7 @@ extern bool ipc_enter_gdb;
* @param extension Extension message word
* @return Result code from user thread processing
*/
int ipc_user_forward_cmd(uint32_t primary, uint32_t extension);
int ipc_user_forward_cmd(uint32_t primary, uint32_t extension, unsigned int core);

/**
* @brief Protocol-specific dispatch of a forwarded IPC command.
Expand All @@ -338,6 +345,19 @@ int ipc_user_forward_cmd(uint32_t primary, uint32_t extension);
* @return Result code to report back to the host
*/
int ipc_user_thread_dispatch(struct ipc_user *ipc_user);

/**
* @brief Initialize IPC and LL scheduler threads on a booting secondary core.
*
* @param core Secondary core ID
* @return 0 or a negative error code
*/
int ipc_user_init_secondary(unsigned int core);
#endif

/**
* \brief get pointer to the userspace IPC thread for core
*/
struct k_thread *ipc_thread_user(unsigned int core);

#endif /* __SOF_DRIVERS_IPC_H__ */
19 changes: 19 additions & 0 deletions src/include/sof/lib_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,25 @@ void lib_manager_get_instance_bss_address(uint32_t instance_id,
*/
int lib_manager_load_library(uint32_t dma_id, uint32_t lib_id, uint32_t type);

struct userspace_context;
/*
* \brief Allocate the module and start the agent if needed
*/
int lib_manager_mod_create_priv(const struct comp_driver *drv,
const struct comp_ipc_config *config,
const void *spec, void **adapter_priv,
struct userspace_context **userspace,
const struct module_interface **ops);

#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
__syscall int lib_manager_free_module(const uint32_t component_id);

#include <zephyr/syscalls/lib_manager.h>
#else
int z_impl_lib_manager_free_module(const uint32_t component_id);
#define lib_manager_free_module z_impl_lib_manager_free_module
#endif

/*
* \brief Initialize message
*
Expand Down
7 changes: 6 additions & 1 deletion src/include/sof/schedule/dp_schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ int scheduler_dp_task_init(struct task **task,
uint16_t core,
size_t stack_size,
uint32_t options);
void scheduler_dp_ll_tick(void);

#if defined(__ZEPHYR__) && CONFIG_SOF_FULL_ZEPHYR_APPLICATION
__syscall void scheduler_dp_internal_free(struct task *task);
__syscall void scheduler_dp_ll_tick(void);
#include <zephyr/syscalls/dp_schedule.h>
#endif

/**
* \brief Extract information about scheduler's tasks
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/schedule/ll_schedule_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ struct ll_schedule_domain *zephyr_domain_init(int clk);
struct k_thread *zephyr_domain_thread_tid(struct ll_schedule_domain *domain);
struct k_thread *zephyr_domain_thread_tid_for_core(int core);
struct k_mem_domain *zephyr_ll_mem_domain(void);
struct k_thread *zephyr_ll_domain_thread(void);
#endif /* CONFIG_SOF_USERSPACE_LL */
#ifdef CONFIG_SOF_FULL_ZEPHYR_APPLICATION
__syscall int zephyr_ll_task_sem_alloc(struct task *task);
Expand Down
12 changes: 11 additions & 1 deletion src/init/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <rtos/init.h>
#include <rtos/interrupt.h>
#include <sof/init.h>
#include <sof/ipc/common.h>
#include <sof/lib/cpu.h>
#include <sof/lib/cpu-clk-manager.h>
#include <sof/lib/memory.h>
Expand Down Expand Up @@ -110,6 +111,9 @@ static inline int secondary_core_restore(void) { return 0; };

__cold int secondary_core_init(struct sof *sof)
{
#if CONFIG_SOF_USERSPACE_LL || CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
unsigned int core = cpu_get_id();
#endif
int err;
struct ll_schedule_domain *dma_domain;

Expand All @@ -134,6 +138,12 @@ __cold int secondary_core_init(struct sof *sof)
if (dma_domain)
scheduler_init_ll(dma_domain);

#if CONFIG_SOF_USERSPACE_LL
err = ipc_user_init_secondary(core);
if (err < 0)
return err;
#endif

#if CONFIG_ZEPHYR_DP_SCHEDULER
err = scheduler_dp_init();
if (err < 0)
Expand All @@ -152,7 +162,7 @@ __cold int secondary_core_init(struct sof *sof)
return err;
#endif
#if CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL
err = core_kcps_adjust(cpu_get_id(), SECONDARY_CORE_BASE_CPS_USAGE);
err = core_kcps_adjust(core, SECONDARY_CORE_BASE_CPS_USAGE);
if (err < 0)
return err;
#endif
Expand Down
Loading
Loading