From 9cc6b0fdf02ce888ab43eeb22e1cdc2969412b28 Mon Sep 17 00:00:00 2001 From: Chao Song Date: Wed, 2 Mar 2022 20:26:50 +0800 Subject: [PATCH] audio: component: don't inline functions that have logging Two reasons: - If a function contains logging code, normally it means there are a lot of operations, so, better not to inline it. - It is not possible for us to define a clear logging context for these functions when using zephyr logging utilities, because the header file contains these functions are included by other modules, and each has a logging context defined. Signed-off-by: Chao Song --- src/audio/component.c | 59 +++++++++++++++++++++ src/include/sof/audio/component.h | 21 ++++++++ src/include/sof/audio/component_ext.h | 74 --------------------------- 3 files changed, 80 insertions(+), 74 deletions(-) diff --git a/src/audio/component.c b/src/audio/component.c index 898abe2376ec..843b879c266e 100644 --- a/src/audio/component.c +++ b/src/audio/component.c @@ -557,3 +557,62 @@ void audio_stream_copy_to_linear(struct audio_stream *source, int ioffset, snk += bytes_copied; } } + +/** See comp_ops::params */ +int comp_params(struct comp_dev *dev, + struct sof_ipc_stream_params *params) +{ + int ret = 0; + + if (dev->is_shared && !cpu_is_me(dev->ipc_config.core)) { + ret = comp_params_remote(dev, params); + } else { + if (dev->drv->ops.params) { + ret = dev->drv->ops.params(dev, params); + } else { + /* not defined, run the default handler */ + ret = comp_verify_params(dev, 0, params); + if (ret < 0) + comp_err(dev, "pcm params verification failed"); + } + } + + return ret; +} + +/** See comp_ops::cmd */ +int comp_cmd(struct comp_dev *dev, int cmd, void *data, + int max_data_size) +{ + struct sof_ipc_ctrl_data *cdata = ASSUME_ALIGNED(data, 4); + + if (cmd == COMP_CMD_SET_DATA && + (cdata->data->magic != SOF_ABI_MAGIC || + SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi))) { + comp_err(dev, "comp_cmd(): invalid version, data->magic = %u, data->abi = %u", + cdata->data->magic, cdata->data->abi); + return -EINVAL; + } + + if (dev->drv->ops.cmd) + return dev->drv->ops.cmd(dev, cmd, data, max_data_size); + + return -EINVAL; +} + +/** See comp_ops::copy */ +int comp_copy(struct comp_dev *dev) +{ + int ret = 0; + + assert(dev->drv->ops.copy); + + /* copy only if we are the owner of the component */ + if (cpu_is_me(dev->ipc_config.core)) { + perf_cnt_init(&dev->pcd); + ret = dev->drv->ops.copy(dev); + perf_cnt_stamp(&dev->pcd, comp_perf_info, dev); + } + + return ret; +} diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index aa87f2f3884c..5982cc26b33d 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -843,6 +843,21 @@ static inline int comp_get_state(struct comp_dev *req_dev, struct comp_dev *dev) struct comp_data_blob_handler; +/** + * Parameter init for component on other core. + * @param dev Component device. + * @param params Parameters to be set. + * @return 0 if succeeded, error code otherwise. + */ +static inline int comp_params_remote(struct comp_dev *dev, + struct sof_ipc_stream_params *params) +{ + struct idc_msg msg = { IDC_MSG_PARAMS, IDC_MSG_PARAMS_EXT(dev->ipc_config.id), + dev->ipc_config.core, sizeof(*params), params, }; + + return idc_send_msg(&msg, IDC_BLOCKING); +} + /** * Returns data blob. In case when new data blob is available it returns new * one. Function returns also data blob size in case when size pointer is given. @@ -920,6 +935,12 @@ void comp_data_blob_handler_free(struct comp_data_blob_handler *blob_handler); int comp_verify_params(struct comp_dev *dev, uint32_t flag, struct sof_ipc_stream_params *params); +int comp_params(struct comp_dev *dev, struct sof_ipc_stream_params *params); + +int comp_cmd(struct comp_dev *dev, int cmd, void *data, int max_data_size); + +int comp_copy(struct comp_dev *dev); + /** @}*/ #endif /* __SOF_AUDIO_COMPONENT_H__ */ diff --git a/src/include/sof/audio/component_ext.h b/src/include/sof/audio/component_ext.h index 290e124be92e..65add7383187 100644 --- a/src/include/sof/audio/component_ext.h +++ b/src/include/sof/audio/component_ext.h @@ -55,43 +55,6 @@ static inline void comp_free(struct comp_dev *dev) dev->drv->ops.free(dev); } -/** - * Parameter init for component on other core. - * @param dev Component device. - * @param params Parameters to be set. - * @return 0 if succeeded, error code otherwise. - */ -static inline int comp_params_remote(struct comp_dev *dev, - struct sof_ipc_stream_params *params) -{ - struct idc_msg msg = { IDC_MSG_PARAMS, IDC_MSG_PARAMS_EXT(dev->ipc_config.id), - dev->ipc_config.core, sizeof(*params), params, }; - - return idc_send_msg(&msg, IDC_BLOCKING); -} - -/** See comp_ops::params */ -static inline int comp_params(struct comp_dev *dev, - struct sof_ipc_stream_params *params) -{ - int ret = 0; - - if (dev->is_shared && !cpu_is_me(dev->ipc_config.core)) { - ret = comp_params_remote(dev, params); - } else { - if (dev->drv->ops.params) { - ret = dev->drv->ops.params(dev, params); - } else { - /* not defined, run the default handler */ - ret = comp_verify_params(dev, 0, params); - if (ret < 0) - comp_err(dev, "pcm params verification failed"); - } - } - - return ret; -} - /** See comp_ops::dai_get_hw_params */ static inline int comp_dai_get_hw_params(struct comp_dev *dev, struct sof_ipc_stream_params *params, @@ -103,26 +66,6 @@ static inline int comp_dai_get_hw_params(struct comp_dev *dev, return -EINVAL; } -/** See comp_ops::cmd */ -static inline int comp_cmd(struct comp_dev *dev, int cmd, void *data, - int max_data_size) -{ - struct sof_ipc_ctrl_data *cdata = ASSUME_ALIGNED(data, 4); - - if (cmd == COMP_CMD_SET_DATA && - (cdata->data->magic != SOF_ABI_MAGIC || - SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi))) { - comp_err(dev, "comp_cmd(): invalid version, data->magic = %u, data->abi = %u", - cdata->data->magic, cdata->data->abi); - return -EINVAL; - } - - if (dev->drv->ops.cmd) - return dev->drv->ops.cmd(dev, cmd, data, max_data_size); - - return -EINVAL; -} - /** * Runs comp_ops::trigger on the core the target component is assigned to. */ @@ -163,23 +106,6 @@ static inline int comp_prepare(struct comp_dev *dev) return 0; } -/** See comp_ops::copy */ -static inline int comp_copy(struct comp_dev *dev) -{ - int ret = 0; - - assert(dev->drv->ops.copy); - - /* copy only if we are the owner of the component */ - if (cpu_is_me(dev->ipc_config.core)) { - perf_cnt_init(&dev->pcd); - ret = dev->drv->ops.copy(dev); - perf_cnt_stamp(&dev->pcd, comp_perf_info, dev); - } - - return ret; -} - /** See comp_ops::get_attribute */ static inline int comp_get_attribute(struct comp_dev *dev, uint32_t type, void *value)