copier: remove redundant cache invalidation, add comments

No need to invalidate cache again - comp_new() already has done it.
Also document why we don't need to copy config_data[] and use
memcpy() directly instead of mailbox_hostbox_read() - we already have
a pointer and cached have been invalidated already.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2023-01-10 18:02:59 +01:00 committed by Kai Vehmanen
parent 31c637a285
commit 4cc9d5418b
2 changed files with 13 additions and 9 deletions

View File

@ -495,7 +495,6 @@ static struct comp_dev *copier_new(const struct comp_driver *drv,
struct ipc *ipc = ipc_get();
struct copier_data *cd;
struct comp_dev *dev;
size_t size, config_size;
int i;
comp_cl_dbg(&comp_copier, "copier_new()");
@ -506,17 +505,17 @@ static struct comp_dev *copier_new(const struct comp_driver *drv,
dev->ipc_config = *config;
config_size = copier->gtw_cfg.config_length * sizeof(uint32_t);
dcache_invalidate_region((__sparse_force char __sparse_cache *)spec + sizeof(*copier),
config_size);
size = sizeof(*cd);
cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, size);
cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (!cd)
goto error;
size = sizeof(*copier);
mailbox_hostbox_read(&cd->config, size, 0, size);
/*
* Don't copy the config_data[] variable size array, we don't need to
* store it, it's only used during IPC processing, besides we haven't
* allocated space for it, so don't "fix" this!
*/
if (memcpy_s(&cd->config, sizeof(cd->config), copier, sizeof(*copier)) < 0)
goto error_cd;
for (i = 0; i < IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT; i++)
cd->out_fmt[i] = cd->config.out_fmt;

View File

@ -327,6 +327,11 @@ typedef void (* channel_copy_func)(struct audio_stream __sparse_cache *dst,
int src_channel, int frame_count);
struct copier_data {
/*
* struct ipc4_copier_module_cfg actually has variable size, but we
* don't need the variable size array at the end, we won't be copying it
* from the IPC data.
*/
struct ipc4_copier_module_cfg config;
struct comp_dev *endpoint[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT];
struct comp_buffer *endpoint_buffer[IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT];