Skip to content

Commit

Permalink
ipc: move all functions to run from DRAM
Browse files Browse the repository at this point in the history
Mark all IPC functions as "cold" to run them directly in DRAM.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
  • Loading branch information
lyakh committed Feb 21, 2025
1 parent c7f6a7a commit 61fe5a7
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 104 deletions.
27 changes: 14 additions & 13 deletions src/ipc/ipc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <rtos/cache.h>
#include <sof/lib/cpu.h>
#include <sof/lib/mailbox.h>
#include <sof/lib/memory.h>
#include <sof/list.h>
#include <sof/platform.h>
#include <rtos/sof.h>
Expand All @@ -41,7 +42,7 @@ SOF_DEFINE_REG_UUID(ipc);

DECLARE_TR_CTX(ipc_tr, SOF_UUID(ipc_uuid), LOG_LEVEL_INFO);

int ipc_process_on_core(uint32_t core, bool blocking)
__cold int ipc_process_on_core(uint32_t core, bool blocking)
{
struct ipc *ipc = ipc_get();
struct idc_msg msg = { .header = IDC_MSG_IPC, .core = core, };
Expand Down Expand Up @@ -83,7 +84,7 @@ int ipc_process_on_core(uint32_t core, bool blocking)
* Components, buffers and pipelines are stored in the same lists, hence
* type and ID have to be used for the identification.
*/
struct ipc_comp_dev *ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint32_t id)
__cold struct ipc_comp_dev *ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint32_t id)
{
struct ipc_comp_dev *icd;
struct list_item *clist;
Expand All @@ -101,7 +102,7 @@ EXPORT_SYMBOL(ipc_get_comp_dev);
/* Walks through the list of components looking for a sink/source endpoint component
* of the given pipeline
*/
struct ipc_comp_dev *ipc_get_ppl_comp(struct ipc *ipc, uint32_t pipeline_id, int dir)
__cold struct ipc_comp_dev *ipc_get_ppl_comp(struct ipc *ipc, uint32_t pipeline_id, int dir)
{
struct ipc_comp_dev *icd;
struct comp_buffer *buffer;
Expand Down Expand Up @@ -140,7 +141,7 @@ struct ipc_comp_dev *ipc_get_ppl_comp(struct ipc *ipc, uint32_t pipeline_id, int
return next_ppl_icd;
}

void ipc_send_queued_msg(void)
__cold void ipc_send_queued_msg(void)
{
struct ipc *ipc = ipc_get();
struct ipc_msg *msg;
Expand Down Expand Up @@ -175,7 +176,7 @@ static struct k_work_q ipc_send_wq;
static K_THREAD_STACK_DEFINE(ipc_send_wq_stack, CONFIG_STACK_SIZE_IPC_TX);
#endif

static void schedule_ipc_worker(void)
__cold static void schedule_ipc_worker(void)
{
/*
* note: in XTOS builds, this is handled in
Expand All @@ -188,7 +189,7 @@ static void schedule_ipc_worker(void)
#endif
}

void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
__cold void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
{
struct ipc *ipc = ipc_get();
k_spinlock_key_t key;
Expand All @@ -208,7 +209,7 @@ void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
k_spin_unlock(&ipc->lock, key);
}

void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
__cold void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
{
struct ipc *ipc = ipc_get();
k_spinlock_key_t key;
Expand Down Expand Up @@ -255,7 +256,7 @@ void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
EXPORT_SYMBOL(ipc_msg_send);

#ifdef __ZEPHYR__
static void ipc_work_handler(struct k_work *work)
__cold static void ipc_work_handler(struct k_work *work)
{
struct ipc *ipc = ipc_get();
k_spinlock_key_t key;
Expand All @@ -271,12 +272,12 @@ static void ipc_work_handler(struct k_work *work)
}
#endif

void ipc_schedule_process(struct ipc *ipc)
__cold void ipc_schedule_process(struct ipc *ipc)
{
schedule_task(&ipc->ipc_task, 0, IPC_PERIOD_USEC);
}

int ipc_init(struct sof *sof)
__cold int ipc_init(struct sof *sof)
{
tr_dbg(&ipc_tr, "ipc_init()");

Expand Down Expand Up @@ -323,7 +324,7 @@ int ipc_init(struct sof *sof)
}

/* Locking: call with ipc->lock held and interrupts disabled */
void ipc_complete_cmd(struct ipc *ipc)
__cold void ipc_complete_cmd(struct ipc *ipc)
{
/*
* We have up to three contexts, attempting to complete IPC processing:
Expand All @@ -343,7 +344,7 @@ void ipc_complete_cmd(struct ipc *ipc)
ipc_platform_complete_cmd(ipc);
}

static void ipc_complete_task(void *data)
__cold static void ipc_complete_task(void *data)
{
struct ipc *ipc = data;
k_spinlock_key_t key;
Expand All @@ -354,7 +355,7 @@ static void ipc_complete_task(void *data)
k_spin_unlock(&ipc->lock, key);
}

static enum task_state ipc_do_cmd(void *data)
__cold static enum task_state ipc_do_cmd(void *data)
{
struct ipc *ipc = data;

Expand Down
25 changes: 13 additions & 12 deletions src/ipc/ipc-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <rtos/cache.h>
#include <sof/lib/cpu.h>
#include <sof/lib/mailbox.h>
#include <sof/lib/memory.h>
#include <sof/list.h>
#include <sof/platform.h>
#include <rtos/sof.h>
Expand All @@ -37,7 +38,7 @@

LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL);

static bool valid_ipc_buffer_desc(const struct sof_ipc_buffer *desc)
__cold static bool valid_ipc_buffer_desc(const struct sof_ipc_buffer *desc)
{
if (desc->caps >= SOF_MEM_CAPS_LOWEST_INVALID)
return false;
Expand All @@ -47,7 +48,7 @@ static bool valid_ipc_buffer_desc(const struct sof_ipc_buffer *desc)
}

/* create a new component in the pipeline */
struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared)
__cold struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared)
{
struct comp_buffer *buffer;

Expand Down Expand Up @@ -75,7 +76,7 @@ struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared
return buffer;
}

int32_t ipc_comp_pipe_id(const struct ipc_comp_dev *icd)
__cold int32_t ipc_comp_pipe_id(const struct ipc_comp_dev *icd)
{
switch (icd->type) {
case COMP_TYPE_COMPONENT:
Expand All @@ -95,9 +96,9 @@ int32_t ipc_comp_pipe_id(const struct ipc_comp_dev *icd)
/* Function overwrites PCM parameters (frame_fmt, buffer_fmt, channels, rate)
* with buffer parameters when specific flag is set.
*/
static void comp_update_params(uint32_t flag,
struct sof_ipc_stream_params *params,
struct comp_buffer *buffer)
__cold static void comp_update_params(uint32_t flag,
struct sof_ipc_stream_params *params,
struct comp_buffer *buffer)
{
if (flag & BUFF_PARAMS_FRAME_FMT)
params->frame_fmt = audio_stream_get_frm_fmt(&buffer->stream);
Expand All @@ -112,8 +113,8 @@ static void comp_update_params(uint32_t flag,
params->rate = audio_stream_get_rate(&buffer->stream);
}

int comp_verify_params(struct comp_dev *dev, uint32_t flag,
struct sof_ipc_stream_params *params)
__cold int comp_verify_params(struct comp_dev *dev, uint32_t flag,
struct sof_ipc_stream_params *params)
{
struct list_item *buffer_list;
struct list_item *source_list;
Expand Down Expand Up @@ -179,8 +180,8 @@ int comp_verify_params(struct comp_dev *dev, uint32_t flag,
}
EXPORT_SYMBOL(comp_verify_params);

int comp_buffer_connect(struct comp_dev *comp, uint32_t comp_core,
struct comp_buffer *buffer, uint32_t dir)
__cold int comp_buffer_connect(struct comp_dev *comp, uint32_t comp_core,
struct comp_buffer *buffer, uint32_t dir)
{
/* check if it's a connection between cores */
if (buffer->core != comp_core) {
Expand All @@ -197,7 +198,7 @@ int comp_buffer_connect(struct comp_dev *comp, uint32_t comp_core,
return pipeline_connect(comp, buffer, dir);
}

int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id)
__cold int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id)
{
struct ipc_comp_dev *ipc_pipe;
struct ipc_comp_dev *icd;
Expand Down Expand Up @@ -260,7 +261,7 @@ int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id)
ipc_ppl_sink->cd);
}

int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
__cold int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
{
struct ipc_comp_dev *icd;
struct list_item *clist, *tmp;
Expand Down
Loading

0 comments on commit 61fe5a7

Please sign in to comment.