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
19 changes: 6 additions & 13 deletions src/ipc/ipc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,6 @@ int ipc_user_forward_cmd(uint32_t primary, uint32_t extension, unsigned int core
pdata->ipc_msg_ext = extension;
pdata->ipc = ipc;

/*
* Forwarding the first IPC to this core, wait for its userspace IPC
* thread to start
*/
if (pdata->init_needed[core]) {
pdata->init_needed[core] = false;
k_sem_take(pdata->sem, K_FOREVER);
}

/* Prevent host completion until user thread finishes */
key = k_spin_lock(&ipc->lock);
ipc->task_mask |= IPC_TASK_IN_THREAD;
Expand Down Expand Up @@ -598,9 +589,6 @@ __cold int ipc_user_init_secondary(unsigned int core)
}

k_thread_access_grant(ipc_user->thread[core], ipc_user->audio_thread[core]);
ipc_user->init_needed[core] = true;

/* Wait for user thread startup — consumes the initial k_sem_give from thread */
return 0;
}

Expand All @@ -619,7 +607,7 @@ __cold static void ipc_user_init(void)
struct ipc_user *ipc_user = sof_heap_alloc(sof_sys_user_heap_get(),
SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
sizeof(*ipc_user), 0);
int ret;
int ret, core;

if (!ipc_user) {
LOG_ERR("user IPC pdata alloc failed");
Expand All @@ -628,6 +616,11 @@ __cold static void ipc_user_init(void)

assert_can_be_cold();

for (core = 0; core < CONFIG_CORE_COUNT; core++) {
if (core != PLATFORM_PRIMARY_CORE_ID)
ipc_user->init_needed[core] = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, and if you power off a core and then power it back on?

}

ipc_user->sem = k_object_alloc(K_OBJ_SEM);
if (!ipc_user->sem) {
LOG_ERR("user IPC sem alloc failed");
Expand Down
18 changes: 18 additions & 0 deletions src/ipc/ipc4/handler-kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,23 @@ __cold static int ipc4_module_process_d0ix(struct ipc4_message_request *ipc4)
return 0;
}

/* block until core has powered-up (in user-ll builds) */
__cold static void ipc_sec_core_sync_boot(uint32_t core_id)
{
#ifdef CONFIG_SOF_USERSPACE_LL
struct ipc *ipc = ipc_get();
struct ipc_user *ipc_user = ipc->ipc_user_pdata;

assert(core_id != PLATFORM_PRIMARY_CORE_ID);

if (ipc_user->init_needed[core_id]) {
/* wait for IPC thread (ipc_user_thread_fn()) */
k_sem_take(ipc_user->sem, K_FOREVER);
ipc_user->init_needed[core_id] = false;
}
#endif
}

/* enable/disable cores according to the state mask */
__cold static int ipc4_module_process_dx(struct ipc4_message_request *ipc4)
{
Expand Down Expand Up @@ -385,6 +402,7 @@ __cold static int ipc4_module_process_dx(struct ipc4_message_request *ipc4)
ipc_cmd_err(&ipc_tr, "failed to enable core %d", core_id);
return IPC4_FAILURE;
}
ipc_sec_core_sync_boot(core_id);
} else {
cpu_disable_core(core_id);
if (cpu_is_core_enabled(core_id)) {
Expand Down
Loading