From 6571103cea7838cd66e7b951e8ad2bd796f5638d Mon Sep 17 00:00:00 2001 From: Serhiy Katsyuba Date: Thu, 28 Nov 2024 17:15:22 +0100 Subject: [PATCH 1/3] ipc4: ipcgtw: code cleanup The use of intermediate endpoint buffer was removed from gateways some time ago. However, the IPC gateway code still contained logic that unnecessarily creates such endpoint buffer. That code has now been removed. Signed-off-by: Serhiy Katsyuba --- src/audio/copier/copier_ipcgtw.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/audio/copier/copier_ipcgtw.c b/src/audio/copier/copier_ipcgtw.c index 20d20b864652..f31da128a368 100644 --- a/src/audio/copier/copier_ipcgtw.c +++ b/src/audio/copier/copier_ipcgtw.c @@ -223,22 +223,13 @@ int copier_ipcgtw_create(struct comp_dev *dev, struct copier_data *cd, cd->ipc_gtw = true; - /* create_endpoint_buffer() uses this value to choose between input and - * output formats in copier config to setup buffer. For this purpose - * IPC gateway should be handled similarly as host gateway. - */ + /* The IPC gateway is treated as a host gateway */ config->type = SOF_COMP_HOST; cd->gtw_type = ipc4_gtw_host; - ret = create_endpoint_buffer(dev, cd, copier, false); - if (ret < 0) - return ret; - ipcgtw_data = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*ipcgtw_data)); - if (!ipcgtw_data) { - ret = -ENOMEM; - goto e_buf; - } + if (!ipcgtw_data) + return -ENOMEM; ipcgtw_data->node_id = gtw_cfg->node_id; ipcgtw_data->dev = dev; @@ -246,8 +237,8 @@ int copier_ipcgtw_create(struct comp_dev *dev, struct copier_data *cd, blob = (const struct ipc4_ipc_gateway_config_blob *) ((const struct ipc4_gateway_config_data *)gtw_cfg->config_data)->config_blob; - /* Endpoint buffer is created in copier with size specified in copier config. That buffer - * will be resized to size specified in IPC gateway blob later in ipcgtw_params(). + /* The buffer connected to the IPC gateway will be resized later in ipcgtw_params() + * to the size specified in the IPC gateway blob. */ comp_dbg(dev, "ipcgtw_create(): buffer_size: %u", blob->buffer_size); ipcgtw_data->buf_size = blob->buffer_size; @@ -264,15 +255,9 @@ int copier_ipcgtw_create(struct comp_dev *dev, struct copier_data *cd, } if (cd->direction == SOF_IPC_STREAM_PLAYBACK) { - comp_buffer_connect(dev, config->core, - cd->endpoint_buffer[cd->endpoint_num], - PPL_CONN_DIR_COMP_TO_BUFFER); cd->bsource_buffer = false; pipeline->source_comp = dev; } else { - comp_buffer_connect(dev, config->core, - cd->endpoint_buffer[cd->endpoint_num], - PPL_CONN_DIR_BUFFER_TO_COMP); cd->bsource_buffer = true; pipeline->sink_comp = dev; } @@ -285,8 +270,6 @@ int copier_ipcgtw_create(struct comp_dev *dev, struct copier_data *cd, e_ipcgtw: rfree(ipcgtw_data); -e_buf: - buffer_free(cd->endpoint_buffer[cd->endpoint_num]); return ret; } @@ -294,5 +277,4 @@ void copier_ipcgtw_free(struct copier_data *cd) { list_item_del(&cd->ipcgtw_data->item); rfree(cd->ipcgtw_data); - buffer_free(cd->endpoint_buffer[0]); } From 3b595f25bdbfd7ae98bd6515fe49d39cd120d84b Mon Sep 17 00:00:00 2001 From: Serhiy Katsyuba Date: Thu, 28 Nov 2024 17:23:37 +0100 Subject: [PATCH 2/3] ipc4: copier: remove unused endpoint_buffer[] The use of endpoint buffers in gateways was removed some time ago. endpoint_buffer[] is a leftover from an earlier refactoring, is not used, and can be removed. Signed-off-by: Serhiy Katsyuba --- src/audio/copier/copier.h | 10 ++++------ src/audio/copier/copier_dai.c | 2 +- src/audio/copier/copier_generic.c | 12 ++++-------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/audio/copier/copier.h b/src/audio/copier/copier.h index 41bca7afc287..7b490e53c384 100644 --- a/src/audio/copier/copier.h +++ b/src/audio/copier/copier.h @@ -246,10 +246,9 @@ struct copier_data { void *gtw_cfg; enum ipc4_gateway_type gtw_type; struct comp_dev *endpoint[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT]; - struct comp_buffer *endpoint_buffer[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT]; uint32_t endpoint_num; - /* buffer to mux/demux data from/to multiple endpoint buffers for ALH multi-gateway case */ + /* buffer to mux/demux data from/to multiple endpoints for ALH multi-gateway case */ struct comp_buffer *multi_endpoint_buffer; bool bsource_buffer; @@ -284,10 +283,9 @@ pcm_converter_func get_converter_func(const struct ipc4_audio_format *in_fmt, uint32_t chmap); struct comp_ipc_config; -int create_endpoint_buffer(struct comp_dev *dev, - struct copier_data *cd, - const struct ipc4_copier_module_cfg *copier_cfg, - bool create_multi_endpoint_buffer); +int create_multi_endpoint_buffer(struct comp_dev *dev, + struct copier_data *cd, + const struct ipc4_copier_module_cfg *copier_cfg); enum sof_ipc_stream_direction get_gateway_direction(enum ipc4_connector_node_id_type node_id_type); diff --git a/src/audio/copier/copier_dai.c b/src/audio/copier/copier_dai.c index f79c2b225255..587a133ebd75 100644 --- a/src/audio/copier/copier_dai.c +++ b/src/audio/copier/copier_dai.c @@ -351,7 +351,7 @@ int copier_dai_create(struct comp_dev *dev, struct copier_data *cd, /* create multi_endpoint_buffer for ALH multi-gateway case */ if (dai_count > 1) { - ret = create_endpoint_buffer(dev, cd, copier, true); + ret = create_multi_endpoint_buffer(dev, cd, copier); if (ret < 0) return ret; } diff --git a/src/audio/copier/copier_generic.c b/src/audio/copier/copier_generic.c index ac9e900e9157..a4fc8ca6c9a1 100644 --- a/src/audio/copier/copier_generic.c +++ b/src/audio/copier/copier_generic.c @@ -347,10 +347,9 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev, } } -int create_endpoint_buffer(struct comp_dev *dev, - struct copier_data *cd, - const struct ipc4_copier_module_cfg *copier_cfg, - bool create_multi_endpoint_buffer) +int create_multi_endpoint_buffer(struct comp_dev *dev, + struct copier_data *cd, + const struct ipc4_copier_module_cfg *copier_cfg) { struct comp_ipc_config *config = &dev->ipc_config; enum sof_ipc_frame in_frame_fmt, out_frame_fmt; @@ -438,10 +437,7 @@ int create_endpoint_buffer(struct comp_dev *dev, audio_buffer_set_hw_params_configured(&buffer->audio_buffer); - if (create_multi_endpoint_buffer) - cd->multi_endpoint_buffer = buffer; - else - cd->endpoint_buffer[cd->endpoint_num] = buffer; + cd->multi_endpoint_buffer = buffer; return 0; } From 14630ddc4431567dcc23a3ebde346dd4be206a6d Mon Sep 17 00:00:00 2001 From: Serhiy Katsyuba Date: Mon, 2 Dec 2024 11:38:22 +0100 Subject: [PATCH 3/3] ipc4: copier: remove unused endpoint[] The endpoint[] array is never initialized and is not really used. Signed-off-by: Serhiy Katsyuba --- src/audio/copier/copier.c | 4 ++-- src/audio/copier/copier.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/audio/copier/copier.c b/src/audio/copier/copier.c index dc2c0d3d2b87..0fe324cb78f3 100644 --- a/src/audio/copier/copier.c +++ b/src/audio/copier/copier.c @@ -956,8 +956,8 @@ static uint64_t copier_get_processed_data(struct comp_dev *dev, uint32_t stream_ ret = cd->dd[0]->total_data_processed; break; default: - ret = comp_get_total_data_processed(cd->endpoint[stream_no], - 0, input); + comp_err(dev, "Unexpected gateway type encountered: %d", + dev->ipc_config.type); break; } } diff --git a/src/audio/copier/copier.h b/src/audio/copier/copier.h index 7b490e53c384..43c125134f07 100644 --- a/src/audio/copier/copier.h +++ b/src/audio/copier/copier.h @@ -245,7 +245,6 @@ struct copier_data { struct ipc4_copier_module_cfg config; void *gtw_cfg; enum ipc4_gateway_type gtw_type; - struct comp_dev *endpoint[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT]; uint32_t endpoint_num; /* buffer to mux/demux data from/to multiple endpoints for ALH multi-gateway case */