From 22b85f5962464f10833b322f1205e2c94e6f47a2 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 21 Aug 2025 14:44:42 +0200 Subject: [PATCH 1/4] component: split a function into two Split comp_alloc() into two parts - allocation and initialisation to be able to re-use the initialisation code with a different allocation method. Signed-off-by: Guennadi Liakhovetski --- src/include/sof/audio/component.h | 35 +++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 61486e0e2a36..041a40eefb91 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -849,6 +849,24 @@ static inline enum sof_comp_type dev_comp_type(const struct comp_dev *dev) return dev->ipc_config.type; } +/** + * Initialize common part of a component device + * @param drv Parent component driver. + * @param dev Device. + * @param bytes Size of the component device in bytes. + */ +static inline void comp_init(const struct comp_driver *drv, + struct comp_dev *dev, size_t bytes) +{ + dev->size = bytes; + dev->drv = drv; + dev->state = COMP_STATE_INIT; + list_init(&dev->bsink_list); + list_init(&dev->bsource_list); + memcpy_s(&dev->tctx, sizeof(dev->tctx), + trace_comp_drv_get_tr_ctx(dev->drv), sizeof(struct tr_ctx)); +} + /** * Allocates memory for the component device and initializes common part. * @param drv Parent component driver. @@ -857,23 +875,18 @@ static inline enum sof_comp_type dev_comp_type(const struct comp_dev *dev) */ static inline struct comp_dev *comp_alloc(const struct comp_driver *drv, size_t bytes) { - struct comp_dev *dev = NULL; - /* * Use uncached address everywhere to access components to rule out * multi-core failures. TODO: verify if cached alias may be used in some cases */ - dev = module_driver_heap_rzalloc(drv->user_heap, SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, - bytes); + struct comp_dev *dev = module_driver_heap_rzalloc(drv->user_heap, + SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, + bytes); + if (!dev) return NULL; - dev->size = bytes; - dev->drv = drv; - dev->state = COMP_STATE_INIT; - list_init(&dev->bsink_list); - list_init(&dev->bsource_list); - memcpy_s(&dev->tctx, sizeof(struct tr_ctx), - trace_comp_drv_get_tr_ctx(dev->drv), sizeof(struct tr_ctx)); + + comp_init(drv, dev, bytes); return dev; } From 9b473d7e124bfc278fdda0c8496689152da16ff1 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 2 Oct 2025 17:34:40 +0200 Subject: [PATCH 2/4] module: add a missing header The private part of struct struct processing_module contains a list head, add the respective header. Signed-off-by: Guennadi Liakhovetski --- src/include/module/module/base.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/include/module/module/base.h b/src/include/module/module/base.h index ed116681afd2..6d7dea657314 100644 --- a/src/include/module/module/base.h +++ b/src/include/module/module/base.h @@ -16,6 +16,10 @@ #include "interface.h" #include "../ipc4/base-config.h" +#ifdef SOF_MODULE_API_PRIVATE +#include +#endif + #define module_get_private_data(mod) ((mod)->priv.private) #define module_set_private_data(mod, data) ((mod)->priv.private = data) From 94bcb3ae42b278ca6c27d7fa941f9f766a8b7785 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 2 Oct 2025 17:37:02 +0200 Subject: [PATCH 3/4] probe: fix a variable size structure member Variable size structure members are only allowed at the end. Signed-off-by: Guennadi Liakhovetski --- src/probe/probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/probe/probe.c b/src/probe/probe.c index 339935993ef1..b1c095deeda4 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -80,11 +80,11 @@ struct probe_dma_ext { * Probe main struct */ struct probe_pdata { + struct task dmap_work; /**< probe task */ struct probe_dma_ext ext_dma; /**< extraction DMA */ struct probe_dma_ext inject_dma[CONFIG_PROBE_DMA_MAX]; /**< injection DMA */ struct probe_point probe_points[CONFIG_PROBE_POINTS_MAX]; /**< probe points */ struct probe_data_packet header; /**< data packet header */ - struct task dmap_work; /**< probe task */ }; /** From 65bd156189d8b72d773aa1d6fe7aae7e123684ad Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 8 Oct 2025 14:18:22 +0200 Subject: [PATCH 4/4] library-manager: (cosmetic) make a function static Make lib_manager_allocate_module() static also for the CONFIG_MM_DRV=n case. Also don't drop the const qualifier needlessly. Signed-off-by: Guennadi Liakhovetski --- src/library_manager/lib_manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library_manager/lib_manager.c b/src/library_manager/lib_manager.c index d45df1493f5e..7cd35af57ad9 100644 --- a/src/library_manager/lib_manager.c +++ b/src/library_manager/lib_manager.c @@ -412,8 +412,8 @@ int lib_manager_free_module(const uint32_t component_id) #define PAGE_SZ 4096 /* equals to MAN_PAGE_SIZE used by rimage */ -uintptr_t lib_manager_allocate_module(const struct comp_ipc_config *ipc_config, - const void *ipc_specific_config, const void **buildinfo) +static uintptr_t lib_manager_allocate_module(const struct comp_ipc_config *ipc_config, + const void *ipc_specific_config, const void **buildinfo) { tr_err(&lib_manager_tr, "Dynamic module allocation is not supported"); return 0; @@ -578,7 +578,7 @@ static struct comp_dev *lib_manager_module_create(const struct comp_driver *drv, const void *spec) { const struct sof_man_fw_desc *const desc = lib_manager_get_library_manifest(config->id); - const struct ipc_config_process *args = (struct ipc_config_process *)spec; + const struct ipc_config_process *args = (const struct ipc_config_process *)spec; const uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(config->id); const struct module_interface *ops = NULL; const struct sof_man_module *mod;