Skip to content

Commit 61fe5a7

Browse files
committed
ipc: move all functions to run from DRAM
Mark all IPC functions as "cold" to run them directly in DRAM. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent c7f6a7a commit 61fe5a7

4 files changed

Lines changed: 108 additions & 104 deletions

File tree

src/ipc/ipc-common.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <rtos/cache.h>
2121
#include <sof/lib/cpu.h>
2222
#include <sof/lib/mailbox.h>
23+
#include <sof/lib/memory.h>
2324
#include <sof/list.h>
2425
#include <sof/platform.h>
2526
#include <rtos/sof.h>
@@ -41,7 +42,7 @@ SOF_DEFINE_REG_UUID(ipc);
4142

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

44-
int ipc_process_on_core(uint32_t core, bool blocking)
45+
__cold int ipc_process_on_core(uint32_t core, bool blocking)
4546
{
4647
struct ipc *ipc = ipc_get();
4748
struct idc_msg msg = { .header = IDC_MSG_IPC, .core = core, };
@@ -83,7 +84,7 @@ int ipc_process_on_core(uint32_t core, bool blocking)
8384
* Components, buffers and pipelines are stored in the same lists, hence
8485
* type and ID have to be used for the identification.
8586
*/
86-
struct ipc_comp_dev *ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint32_t id)
87+
__cold struct ipc_comp_dev *ipc_get_comp_dev(struct ipc *ipc, uint16_t type, uint32_t id)
8788
{
8889
struct ipc_comp_dev *icd;
8990
struct list_item *clist;
@@ -101,7 +102,7 @@ EXPORT_SYMBOL(ipc_get_comp_dev);
101102
/* Walks through the list of components looking for a sink/source endpoint component
102103
* of the given pipeline
103104
*/
104-
struct ipc_comp_dev *ipc_get_ppl_comp(struct ipc *ipc, uint32_t pipeline_id, int dir)
105+
__cold struct ipc_comp_dev *ipc_get_ppl_comp(struct ipc *ipc, uint32_t pipeline_id, int dir)
105106
{
106107
struct ipc_comp_dev *icd;
107108
struct comp_buffer *buffer;
@@ -140,7 +141,7 @@ struct ipc_comp_dev *ipc_get_ppl_comp(struct ipc *ipc, uint32_t pipeline_id, int
140141
return next_ppl_icd;
141142
}
142143

143-
void ipc_send_queued_msg(void)
144+
__cold void ipc_send_queued_msg(void)
144145
{
145146
struct ipc *ipc = ipc_get();
146147
struct ipc_msg *msg;
@@ -175,7 +176,7 @@ static struct k_work_q ipc_send_wq;
175176
static K_THREAD_STACK_DEFINE(ipc_send_wq_stack, CONFIG_STACK_SIZE_IPC_TX);
176177
#endif
177178

178-
static void schedule_ipc_worker(void)
179+
__cold static void schedule_ipc_worker(void)
179180
{
180181
/*
181182
* note: in XTOS builds, this is handled in
@@ -188,7 +189,7 @@ static void schedule_ipc_worker(void)
188189
#endif
189190
}
190191

191-
void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
192+
__cold void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
192193
{
193194
struct ipc *ipc = ipc_get();
194195
k_spinlock_key_t key;
@@ -208,7 +209,7 @@ void ipc_msg_send_direct(struct ipc_msg *msg, void *data)
208209
k_spin_unlock(&ipc->lock, key);
209210
}
210211

211-
void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
212+
__cold void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
212213
{
213214
struct ipc *ipc = ipc_get();
214215
k_spinlock_key_t key;
@@ -255,7 +256,7 @@ void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
255256
EXPORT_SYMBOL(ipc_msg_send);
256257

257258
#ifdef __ZEPHYR__
258-
static void ipc_work_handler(struct k_work *work)
259+
__cold static void ipc_work_handler(struct k_work *work)
259260
{
260261
struct ipc *ipc = ipc_get();
261262
k_spinlock_key_t key;
@@ -271,12 +272,12 @@ static void ipc_work_handler(struct k_work *work)
271272
}
272273
#endif
273274

274-
void ipc_schedule_process(struct ipc *ipc)
275+
__cold void ipc_schedule_process(struct ipc *ipc)
275276
{
276277
schedule_task(&ipc->ipc_task, 0, IPC_PERIOD_USEC);
277278
}
278279

279-
int ipc_init(struct sof *sof)
280+
__cold int ipc_init(struct sof *sof)
280281
{
281282
tr_dbg(&ipc_tr, "ipc_init()");
282283

@@ -323,7 +324,7 @@ int ipc_init(struct sof *sof)
323324
}
324325

325326
/* Locking: call with ipc->lock held and interrupts disabled */
326-
void ipc_complete_cmd(struct ipc *ipc)
327+
__cold void ipc_complete_cmd(struct ipc *ipc)
327328
{
328329
/*
329330
* We have up to three contexts, attempting to complete IPC processing:
@@ -343,7 +344,7 @@ void ipc_complete_cmd(struct ipc *ipc)
343344
ipc_platform_complete_cmd(ipc);
344345
}
345346

346-
static void ipc_complete_task(void *data)
347+
__cold static void ipc_complete_task(void *data)
347348
{
348349
struct ipc *ipc = data;
349350
k_spinlock_key_t key;
@@ -354,7 +355,7 @@ static void ipc_complete_task(void *data)
354355
k_spin_unlock(&ipc->lock, key);
355356
}
356357

357-
static enum task_state ipc_do_cmd(void *data)
358+
__cold static enum task_state ipc_do_cmd(void *data)
358359
{
359360
struct ipc *ipc = data;
360361

src/ipc/ipc-helper.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <rtos/cache.h>
2222
#include <sof/lib/cpu.h>
2323
#include <sof/lib/mailbox.h>
24+
#include <sof/lib/memory.h>
2425
#include <sof/list.h>
2526
#include <sof/platform.h>
2627
#include <rtos/sof.h>
@@ -37,7 +38,7 @@
3738

3839
LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL);
3940

40-
static bool valid_ipc_buffer_desc(const struct sof_ipc_buffer *desc)
41+
__cold static bool valid_ipc_buffer_desc(const struct sof_ipc_buffer *desc)
4142
{
4243
if (desc->caps >= SOF_MEM_CAPS_LOWEST_INVALID)
4344
return false;
@@ -47,7 +48,7 @@ static bool valid_ipc_buffer_desc(const struct sof_ipc_buffer *desc)
4748
}
4849

4950
/* create a new component in the pipeline */
50-
struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared)
51+
__cold struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared)
5152
{
5253
struct comp_buffer *buffer;
5354

@@ -75,7 +76,7 @@ struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared
7576
return buffer;
7677
}
7778

78-
int32_t ipc_comp_pipe_id(const struct ipc_comp_dev *icd)
79+
__cold int32_t ipc_comp_pipe_id(const struct ipc_comp_dev *icd)
7980
{
8081
switch (icd->type) {
8182
case COMP_TYPE_COMPONENT:
@@ -95,9 +96,9 @@ int32_t ipc_comp_pipe_id(const struct ipc_comp_dev *icd)
9596
/* Function overwrites PCM parameters (frame_fmt, buffer_fmt, channels, rate)
9697
* with buffer parameters when specific flag is set.
9798
*/
98-
static void comp_update_params(uint32_t flag,
99-
struct sof_ipc_stream_params *params,
100-
struct comp_buffer *buffer)
99+
__cold static void comp_update_params(uint32_t flag,
100+
struct sof_ipc_stream_params *params,
101+
struct comp_buffer *buffer)
101102
{
102103
if (flag & BUFF_PARAMS_FRAME_FMT)
103104
params->frame_fmt = audio_stream_get_frm_fmt(&buffer->stream);
@@ -112,8 +113,8 @@ static void comp_update_params(uint32_t flag,
112113
params->rate = audio_stream_get_rate(&buffer->stream);
113114
}
114115

115-
int comp_verify_params(struct comp_dev *dev, uint32_t flag,
116-
struct sof_ipc_stream_params *params)
116+
__cold int comp_verify_params(struct comp_dev *dev, uint32_t flag,
117+
struct sof_ipc_stream_params *params)
117118
{
118119
struct list_item *buffer_list;
119120
struct list_item *source_list;
@@ -179,8 +180,8 @@ int comp_verify_params(struct comp_dev *dev, uint32_t flag,
179180
}
180181
EXPORT_SYMBOL(comp_verify_params);
181182

182-
int comp_buffer_connect(struct comp_dev *comp, uint32_t comp_core,
183-
struct comp_buffer *buffer, uint32_t dir)
183+
__cold int comp_buffer_connect(struct comp_dev *comp, uint32_t comp_core,
184+
struct comp_buffer *buffer, uint32_t dir)
184185
{
185186
/* check if it's a connection between cores */
186187
if (buffer->core != comp_core) {
@@ -197,7 +198,7 @@ int comp_buffer_connect(struct comp_dev *comp, uint32_t comp_core,
197198
return pipeline_connect(comp, buffer, dir);
198199
}
199200

200-
int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id)
201+
__cold int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id)
201202
{
202203
struct ipc_comp_dev *ipc_pipe;
203204
struct ipc_comp_dev *icd;
@@ -260,7 +261,7 @@ int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id)
260261
ipc_ppl_sink->cd);
261262
}
262263

263-
int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
264+
__cold int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
264265
{
265266
struct ipc_comp_dev *icd;
266267
struct list_item *clist, *tmp;

0 commit comments

Comments
 (0)