From b2adb755b886b300dbbd4105372545e58c726f80 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Fri, 20 Dec 2024 15:05:29 +0100 Subject: [PATCH] [DNM] examples of cold code and data Only for testing - mark some functions and const objects for DRAM residency. Signed-off-by: Guennadi Liakhovetski --- src/audio/drc/drc.c | 9 ++-- src/audio/src/coef/src_ipc4_int32_table.h | 14 +++--- src/audio/src/src_ipc4.c | 3 +- src/ipc/ipc4/handler.c | 55 ++++++++++++----------- src/schedule/edf_schedule.c | 3 +- 5 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/audio/drc/drc.c b/src/audio/drc/drc.c index 000e804cbd00..785727063ad8 100644 --- a/src/audio/drc/drc.c +++ b/src/audio/drc/drc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -304,7 +305,7 @@ static int drc_process(struct processing_module *mod, } #if CONFIG_IPC_MAJOR_4 -static void drc_params(struct processing_module *mod) +__cold static void drc_params(struct processing_module *mod) { struct sof_ipc_stream_params *params = mod->stream_params; struct comp_buffer *sinkb, *sourceb; @@ -323,9 +324,9 @@ static void drc_params(struct processing_module *mod) } #endif /* CONFIG_IPC_MAJOR_4 */ -static int drc_prepare(struct processing_module *mod, - struct sof_source **sources, int num_of_sources, - struct sof_sink **sinks, int num_of_sinks) +__cold static int drc_prepare(struct processing_module *mod, + struct sof_source **sources, int num_of_sources, + struct sof_sink **sinks, int num_of_sinks) { struct drc_comp_data *cd = module_get_private_data(mod); struct comp_buffer *sourceb, *sinkb; diff --git a/src/audio/src/coef/src_ipc4_int32_table.h b/src/audio/src/coef/src_ipc4_int32_table.h index 55bf350bead1..8abbe0b1d3b4 100644 --- a/src/audio/src/coef/src_ipc4_int32_table.h +++ b/src/audio/src/coef/src_ipc4_int32_table.h @@ -9,6 +9,8 @@ #ifndef __SOF_AUDIO_COEFFICIENTS_SRC_SRC_IPC4_INT32_TABLE_H__ #define __SOF_AUDIO_COEFFICIENTS_SRC_SRC_IPC4_INT32_TABLE_H__ +#include + /* SRC conversions */ #include "src_ipc4_int32_1_2_2268_5000.h" #include "src_ipc4_int32_1_2_2500_5000.h" @@ -100,15 +102,15 @@ #include /* SRC table */ -static const int32_t fir_one = 1073741824; -static const struct src_stage src_int32_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one }; -static const struct src_stage src_int32_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one }; -static const int src_in_fs[16] = { 8000, 11025, 12000, 16000, 18900, 22050, 24000, 32000, +__cold_rodata static const int32_t fir_one = 1073741824; +__cold_rodata static const struct src_stage src_int32_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one }; +__cold_rodata static const struct src_stage src_int32_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one }; +__cold_rodata static const int src_in_fs[16] = { 8000, 11025, 12000, 16000, 18900, 22050, 24000, 32000, 37800, 44100, 48000, 64000, 88200, 96000, 176400, 192000 }; -static const int src_out_fs[10] = { 8000, 16000, 24000, 32000, 44100, 48000, 88200, 96000, +__cold_rodata static const int src_out_fs[10] = { 8000, 16000, 24000, 32000, 44100, 48000, 88200, 96000, 176400, 192000}; -static const struct src_stage * const src_table1[10][16] = { +__cold_rodata static const struct src_stage * const src_table1[10][16] = { { &src_int32_1_1_0_0, &src_int32_16_21_4319_5000, &src_int32_2_3_4535_5000, &src_int32_1_2_4535_5000, &src_int32_0_0_0_0, &src_int32_10_21_3455_5000, diff --git a/src/audio/src/src_ipc4.c b/src/audio/src/src_ipc4.c index c1244801d1c1..c44d6afeb843 100644 --- a/src/audio/src/src_ipc4.c +++ b/src/audio/src/src_ipc4.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -179,7 +180,7 @@ int src_prepare_general(struct processing_module *mod, return ret; } -int src_init(struct processing_module *mod) +__cold int src_init(struct processing_module *mod) { struct module_data *md = &mod->priv; struct module_config *cfg = &md->cfg; diff --git a/src/ipc/ipc4/handler.c b/src/ipc/ipc4/handler.c index 6645d6fd08e5..014f40fd98ad 100644 --- a/src/ipc/ipc4/handler.c +++ b/src/ipc/ipc4/handler.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -131,14 +132,14 @@ static inline const struct ipc4_pipeline_set_state_data *ipc4_get_pipeline_data( /* * Global IPC Operations. */ -static int ipc4_new_pipeline(struct ipc4_message_request *ipc4) +__cold static int ipc4_new_pipeline(struct ipc4_message_request *ipc4) { struct ipc *ipc = ipc_get(); return ipc_pipeline_new(ipc, (ipc_pipe_new *)ipc4); } -static int ipc4_delete_pipeline(struct ipc4_message_request *ipc4) +__cold static int ipc4_delete_pipeline(struct ipc4_message_request *ipc4) { struct ipc4_pipeline_delete *pipe; struct ipc *ipc = ipc_get(); @@ -149,7 +150,7 @@ static int ipc4_delete_pipeline(struct ipc4_message_request *ipc4) return ipc_pipeline_free(ipc, pipe->primary.r.instance_id); } -static int ipc4_comp_params(struct comp_dev *current, +__cold static int ipc4_comp_params(struct comp_dev *current, struct comp_buffer *calling_buf, struct pipeline_walk_context *ctx, int dir) { @@ -171,7 +172,7 @@ static int ipc4_comp_params(struct comp_dev *current, return pipeline_for_each_comp(current, ctx, dir); } -static int ipc4_pipeline_params(struct pipeline *p, struct comp_dev *host) +__cold static int ipc4_pipeline_params(struct pipeline *p, struct comp_dev *host) { struct sof_ipc_pcm_params hw_params = {{ 0 }}; struct pipeline_data data = { @@ -189,7 +190,7 @@ static int ipc4_pipeline_params(struct pipeline *p, struct comp_dev *host) return param_ctx.comp_func(host, NULL, ¶m_ctx, host->direction); } -static int ipc4_pcm_params(struct ipc_comp_dev *pcm_dev) +__cold static int ipc4_pcm_params(struct ipc_comp_dev *pcm_dev) { int err, reset_err; @@ -229,7 +230,7 @@ static int ipc4_pcm_params(struct ipc_comp_dev *pcm_dev) return err; } -static bool is_any_ppl_active(void) +__cold static bool is_any_ppl_active(void) { struct ipc_comp_dev *icd; struct list_item *clist; @@ -246,7 +247,7 @@ static bool is_any_ppl_active(void) return false; } -static struct ipc_comp_dev *pipeline_get_host_dev(struct ipc_comp_dev *ppl_icd) +__cold static struct ipc_comp_dev *pipeline_get_host_dev(struct ipc_comp_dev *ppl_icd) { struct ipc_comp_dev *host_dev; struct ipc *ipc = ipc_get(); @@ -315,7 +316,7 @@ static struct ipc_comp_dev *pipeline_get_host_dev(struct ipc_comp_dev *ppl_icd) * / */ -int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd) +__cold int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd) { struct ipc_comp_dev *host = NULL; struct ipc *ipc = ipc_get(); @@ -404,7 +405,7 @@ int ipc4_pipeline_prepare(struct ipc_comp_dev *ppl_icd, uint32_t cmd) return ret; } -int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *delayed) +__cold int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *delayed) { struct ipc_comp_dev *host; int status; @@ -496,7 +497,7 @@ int ipc4_pipeline_trigger(struct ipc_comp_dev *ppl_icd, uint32_t cmd, bool *dela return ret; } -static void ipc_compound_pre_start(int msg_id) +__cold static void ipc_compound_pre_start(int msg_id) { /* ipc thread will wait for all scheduled tasks to be complete * Use a reference count to check status of these tasks. @@ -504,7 +505,7 @@ static void ipc_compound_pre_start(int msg_id) atomic_add(&msg_data.delayed_reply, 1); } -static void ipc_compound_post_start(uint32_t msg_id, int ret, bool delayed) +__cold static void ipc_compound_post_start(uint32_t msg_id, int ret, bool delayed) { if (ret) { ipc_cmd_err(&ipc_tr, "failed to process msg %d status %d", msg_id, ret); @@ -517,7 +518,7 @@ static void ipc_compound_post_start(uint32_t msg_id, int ret, bool delayed) atomic_sub(&msg_data.delayed_reply, 1); } -static void ipc_compound_msg_done(uint32_t msg_id, int error) +__cold static void ipc_compound_msg_done(uint32_t msg_id, int error) { if (!atomic_read(&msg_data.delayed_reply)) { ipc_cmd_err(&ipc_tr, "unexpected delayed reply"); @@ -544,7 +545,7 @@ static int ipc_wait_for_compound_msg(void) return IPC4_SUCCESS; } #else -static int ipc_wait_for_compound_msg(void) +__cold static int ipc_wait_for_compound_msg(void) { int try_count = 30; @@ -562,7 +563,7 @@ static int ipc_wait_for_compound_msg(void) } #endif -const struct ipc4_pipeline_set_state_data *ipc4_get_pipeline_data_wrapper(void) +__cold const struct ipc4_pipeline_set_state_data *ipc4_get_pipeline_data_wrapper(void) { const struct ipc4_pipeline_set_state_data *ppl_data; @@ -571,7 +572,7 @@ const struct ipc4_pipeline_set_state_data *ipc4_get_pipeline_data_wrapper(void) return ppl_data; } -static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4) +__cold static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4) { const struct ipc4_pipeline_set_state_data *ppl_data; struct ipc4_pipeline_set_state state; @@ -700,7 +701,7 @@ static int ipc4_set_pipeline_state(struct ipc4_message_request *ipc4) } #if CONFIG_LIBRARY_MANAGER -static int ipc4_load_library(struct ipc4_message_request *ipc4) +__cold static int ipc4_load_library(struct ipc4_message_request *ipc4) { struct ipc4_module_load_library library; int ret; @@ -716,7 +717,7 @@ static int ipc4_load_library(struct ipc4_message_request *ipc4) } #endif -static int ipc4_process_chain_dma(struct ipc4_message_request *ipc4) +__cold static int ipc4_process_chain_dma(struct ipc4_message_request *ipc4) { #if CONFIG_COMP_CHAIN_DMA struct ipc_comp_dev *cdma_comp; @@ -771,7 +772,7 @@ static int ipc4_process_chain_dma(struct ipc4_message_request *ipc4) #endif } -static int ipc4_process_ipcgtw_cmd(struct ipc4_message_request *ipc4) +__cold static int ipc4_process_ipcgtw_cmd(struct ipc4_message_request *ipc4) { #if CONFIG_IPC4_GATEWAY struct ipc *ipc = ipc_get(); @@ -810,7 +811,7 @@ static int ipc4_process_ipcgtw_cmd(struct ipc4_message_request *ipc4) #endif } -static int ipc4_process_glb_message(struct ipc4_message_request *ipc4) +__cold static int ipc4_process_glb_message(struct ipc4_message_request *ipc4) { uint32_t type; int ret; @@ -891,7 +892,7 @@ static int ipc4_process_glb_message(struct ipc4_message_request *ipc4) * delete module <-------> free component */ -static int ipc4_init_module_instance(struct ipc4_message_request *ipc4) +__cold static int ipc4_init_module_instance(struct ipc4_message_request *ipc4) { struct ipc4_module_init_instance module_init; struct comp_dev *dev; @@ -921,7 +922,7 @@ static int ipc4_init_module_instance(struct ipc4_message_request *ipc4) return 0; } -static int ipc4_bind_module_instance(struct ipc4_message_request *ipc4) +__cold static int ipc4_bind_module_instance(struct ipc4_message_request *ipc4) { struct ipc4_module_bind_unbind bu; struct ipc *ipc = ipc_get(); @@ -937,7 +938,7 @@ static int ipc4_bind_module_instance(struct ipc4_message_request *ipc4) return ipc_comp_connect(ipc, (ipc_pipe_comp_connect *)&bu); } -static int ipc4_unbind_module_instance(struct ipc4_message_request *ipc4) +__cold static int ipc4_unbind_module_instance(struct ipc4_message_request *ipc4) { struct ipc4_module_bind_unbind bu; struct ipc *ipc = ipc_get(); @@ -953,7 +954,7 @@ static int ipc4_unbind_module_instance(struct ipc4_message_request *ipc4) return ipc_comp_disconnect(ipc, (ipc_pipe_comp_connect *)&bu); } -static int ipc4_get_vendor_config_module_instance(struct comp_dev *dev, +__cold static int ipc4_get_vendor_config_module_instance(struct comp_dev *dev, const struct comp_driver *drv, bool init_block, bool final_block, @@ -1046,7 +1047,7 @@ static int ipc4_get_vendor_config_module_instance(struct comp_dev *dev, return IPC4_SUCCESS; } -static int ipc4_get_large_config_module_instance(struct ipc4_message_request *ipc4) +__cold static int ipc4_get_large_config_module_instance(struct ipc4_message_request *ipc4) { struct ipc4_module_large_config_reply reply; struct ipc4_module_large_config config; @@ -1085,7 +1086,7 @@ static int ipc4_get_large_config_module_instance(struct ipc4_message_request *ip } if (!drv) - return IPC4_MOD_INVALID_ID; + return IPC4_MOD_INVALID_ID + (config.primary.r.module_id ? 7 : 8); if (!drv->ops.get_large_config) return IPC4_INVALID_REQUEST; @@ -1146,7 +1147,7 @@ static int ipc4_get_large_config_module_instance(struct ipc4_message_request *ip return ret; } -static int ipc4_set_vendor_config_module_instance(struct comp_dev *dev, +__cold static int ipc4_set_vendor_config_module_instance(struct comp_dev *dev, const struct comp_driver *drv, uint32_t module_id, uint32_t instance_id, @@ -1209,7 +1210,7 @@ static int ipc4_set_vendor_config_module_instance(struct comp_dev *dev, data_off_size, data); } -static int ipc4_set_large_config_module_instance(struct ipc4_message_request *ipc4) +__cold static int ipc4_set_large_config_module_instance(struct ipc4_message_request *ipc4) { struct ipc4_module_large_config config; struct comp_dev *dev = NULL; diff --git a/src/schedule/edf_schedule.c b/src/schedule/edf_schedule.c index 11bf195dba7a..e521391a2e34 100644 --- a/src/schedule/edf_schedule.c +++ b/src/schedule/edf_schedule.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,7 @@ struct edf_schedule_data { int irq; }; -static const struct scheduler_ops schedule_edf_ops; +__cold_rodata static const struct scheduler_ops schedule_edf_ops; static int schedule_edf_task_complete(void *data, struct task *task); static int schedule_edf_task_running(void *data, struct task *task);