ASoC: SOF: ipc4-topology: Update the memory data building
Subsystems (3)
Peter Ujfalusi
maintainercover ASoC: SOF: ipc4-topology: Update the memory data building
Hi,
This series fixes some issues left to the first version sof_ipc4_mod_init_ext_dp_memory_data payload building code. The payload to specify memory requirements of Data Processing components, running as independent processes in SOF firmware.
But more importantly it adds a payload of similar purpose to the pipeline create message, e.g. sof_ipc4_glb_pipe_payload. It sums up the memory requirements of individual Low Latency components in the pipeline and sends the summed up values in pipeline create message.
Regards,
Peter
Jyri Sarha (6):
ASoC: SOF: ipc4-topology: Remove dp_ from all module memory attributes
ASoC: SOF: ipc4-topology: Fix SOF_TKN_COMP_STACK_BYTES_REQUIREMENT id
ASoC: SOF: ipc4: Add SOF_IPC4_GLB_CREATE_PIPELINE payload macros and
structs
ASoC: SOF: ipc4-topology: Add payload to pipeline create messages
ASoC: SOF: ipc4-topology: Fix sof_ipc4_mod_init_ext_dp_memory_data
comments
ASoC: SOF: ipc4-topology: Refactor
sof_ipc4_widget_mod_init_msg_payload()
include/sound/sof/ipc4/header.h | 80 +++++++++++++- include/uapi/sound/sof/tokens.h | 4 +- sound/soc/sof/ipc4-topology.c | 179 ++++++++++++++++++++++++++------ sound/soc/sof/sof-audio.h | 8 +- 4 files changed, 229 insertions(+), 42 deletions(-)
Signature · 1 line
2.55.0
Peter Ujfalusi
maintainerPATCH 1/6 ASoC: SOF: ipc4-topology: Remove dp_ from all module memory attributes
From: Jyri Sarha <[email protected]>
Remove dp-prefix from all module instance's memory attributes and related data structures. The attributes are not anymore exclusively for Data Processing module instances, but generic for all module instances. However, the module init payload is still only for DP module instances.
--- sound/soc/sof/ipc4-topology.c | 14 +++++++------- sound/soc/sof/sof-audio.h | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-)
sound/soc/sof/ipc4-topology.c +7 -7
@@ -163,11 +163,11 @@ static const struct sof_topology_token comp_ext_tokens[] = { {SOF_TKN_COMP_SCHED_DOMAIN ,SND_SOC_TPLG_TUPLE_TYPE_STRING , get_token_comp_domain, offsetof(struct snd_sof_widget, comp_domain)}, {SOF_TKN_COMP_DOMAIN_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, - offsetof(struct snd_sof_widget, dp_domain_id)}, + offsetof(struct snd_sof_widget, domain_id)}, {SOF_TKN_COMP_HEAP_BYTES_REQUIREMENT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, - offsetof(struct snd_sof_widget, dp_heap_bytes)}, + offsetof(struct snd_sof_widget, heap_bytes)}, {SOF_TKN_COMP_STACK_BYTES_REQUIREMENT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, - offsetof(struct snd_sof_widget, dp_stack_bytes)}, + offsetof(struct snd_sof_widget, stack_bytes)}, }; static const struct sof_topology_token gain_tokens[] = {
@@ -3118,7 +3118,7 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,/* Add object array objects after ext_init */ -/* Add dp_memory_data if comp_domain indicates DP */ +/* Add memory_data if comp_domain indicates DP */ if (swidget->comp_domain ==SOF_COMP_DOMAIN_DP ) { hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos]; hdr->header = SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK |
@@ -3127,9 +3127,9 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev, sizeof(u32))); ext_pos +=DIV_ROUND_UP (sizeof (*hdr),sizeof (u32)); dp_mem_data = (struct sof_ipc4_mod_init_ext_dp_memory_data *)&payload[ext_pos]; - dp_mem_data->domain_id = swidget->dp_domain_id; - dp_mem_data->stack_bytes = swidget->dp_stack_bytes; - dp_mem_data->heap_bytes = swidget->dp_heap_bytes; + dp_mem_data->domain_id = swidget->domain_id; + dp_mem_data->stack_bytes = swidget->stack_bytes; + dp_mem_data->heap_bytes = swidget->heap_bytes; ext_pos +=DIV_ROUND_UP (sizeof (*dp_mem_data),sizeof (u32)); }
sound/soc/sof/sof-audio.h +4 -4
@@ -459,10 +459,10 @@ struct snd_sof_widget {/* Scheduling domain (enum sof_comp_domain), unset, Low Latency, or Data Processing */ u32 comp_domain; -/* The values below are added to mod_init pay load if comp_domain indicates DP component */ -u32 dp_domain_id;/* DP process userspace domain ID */ -u32 dp_stack_bytes;/* DP process stack size requirement in bytes */ -u32 dp_heap_bytes;/* DP process heap size requirement in bytes */ +/* Module instance's memory configuration. */ +u32 domain_id;/* Module instance's userspace domain ID */ +u32 stack_bytes;/* Module instance's stack size requirement */ +u32 heap_bytes;/* Module instance's heap size requirement */ struct snd_soc_dapm_widget *widget;struct list_head list;/* list in sdev widget list */
Signature · 1 line
2.55.0
Peter Ujfalusi
maintainerPATCH 2/6 ASoC: SOF: ipc4-topology: Fix SOF_TKN_COMP_STACK_BYTES_REQUIREMENT id
In reply to Peter UjfalusiFrom: Jyri Sarha <[email protected]>
The was inconsistency with SOF_TKN_COMP_STACK_BYTES_REQUIREMENT and SOF_TKN_COMP_HEAP_BYTES_REQUIREMENT token ids in the Linux driver code with SOF FW topology code. This commit fixes the Linux side to match tools/topology/topology2/include/common/tokens.conf
--- include/uapi/sound/sof/tokens.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/sound/sof/tokens.h +2 -2
@@ -111,8 +111,8 @@#define SOF_TKN_COMP_SCHED_DOMAIN 418#define SOF_TKN_COMP_DOMAIN_ID 419 -#define SOF_TKN_COMP_HEAP_BYTES_REQUIREMENT 420 -#define SOF_TKN_COMP_STACK_BYTES_REQUIREMENT 421 +#define SOF_TKN_COMP_STACK_BYTES_REQUIREMENT 420 +#define SOF_TKN_COMP_HEAP_BYTES_REQUIREMENT 421/* SSP */ #define SOF_TKN_INTEL_SSP_CLKS_CONTROL 500
Signature · 1 line
2.55.0
Peter Ujfalusi
maintainerPATCH 3/6 ASoC: SOF: ipc4: Add SOF_IPC4_GLB_CREATE_PIPELINE payload macros and structs
In reply to Peter UjfalusiFrom: Jyri Sarha <[email protected]>
Adds SOF_IPC4_GLB_PIPE_EXT_OBJ_ARRAY macros to set extension bit in SOF_IPC4_GLB_CREATE_PIPELINE indicating presence of the payload, and all necessary macros and structs to create the payload.
--- include/sound/sof/ipc4/header.h | 76 ++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-)
include/sound/sof/ipc4/header.h +75 -1
@@ -187,6 +187,10 @@ enum sof_ipc4_pipeline_state {#define SOF_IPC4_GLB_PIPE_EXT_CORE_ID_MASK GENMASK(23, 20)#define SOF_IPC4_GLB_PIPE_EXT_CORE_ID (x) ((x) << SOF_IPC4_GLB_PIPE_EXT_CORE_ID_SHIFT) +#define SOF_IPC4_GLB_PIPE_PAYLOAD_SHIFT 29 +#define SOF_IPC4_GLB_PIPE_PAYLOAD_MASK BIT(29) +#define SOF_IPC4_GLB_PIPE_PAYLOAD (x) ((x) << SOF_IPC4_GLB_PIPE_PAYLOAD_SHIFT) +/* pipeline set state ipc msg */ #define SOF_IPC4_GLB_PIPE_STATE_ID_SHIFT 16#define SOF_IPC4_GLB_PIPE_STATE_ID_MASK GENMASK(23, 16)
@@ -654,13 +658,83 @@ enum sof_ipc4_mod_init_ext_obj_id { SOF_IPC4_MOD_INIT_DATA_ID_MAX = SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA, }; -/* DP module memory configuration data object for ext_init object array */ +/* DP module memory configuration data object for object array */ struct sof_ipc4_mod_init_ext_dp_memory_data {u32 domain_id;/* userspace domain ID */ u32 stack_bytes;/* stack size in bytes, 0 means default size */ u32 heap_bytes;/* stack size in bytes, 0 means default size */ } __packed__aligned(4) ; +/* +* This set of macros are very similar to the set above, but these are +* for building payload to SOF_IPC4_GLB_CREATE_PIPELINE message. +* +* Macros for creating struct sof_ipc4_glb_pipe_payload payload with +* its associated data. struct sof_ipc4_glb_pipe_payload should be the +* first piece of payload following SOF_IPC4_GLB_CREATE_PIPELINE msg, +* and its existence is indicated with SOF_IPC4_GLB_PIPE_PAYLOAD bit. +* +* The macros below apply to sof_ipc4_glb_pipe_payload.word0 +*/ +#define SOF_IPC4_GLB_PIPE_PAYLOAD_WORDS_SHIFT 0 +#define SOF_IPC4_GLB_PIPE_PAYLOAD_WORDS_MASK GENMASK(23, 0) +#define SOF_IPC4_GLB_PIPE_PAYLOAD_WORDS (x) ((x) << SOF_IPC4_GLB_PIPE_PAYLOAD_WORDS_SHIFT) + +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_ARRAY_SHIFT 24 +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_ARRAY_MASK BIT(24) +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_ARRAY (x) ((x) << SOF_IPC4_GLB_PIPE_EXT_OBJ_ARRAY_SHIFT) + +struct sof_ipc4_glb_pipe_payload { +u32 word0; +u32 rsvd1; +u32 rsvd2; +} __packed__aligned(4) ; + +/* +* SOF_IPC4_GLB_CREATE_PIPELINE payload may be followed by arbitrary +* number of object array objects. SOF_IPC4_GLB_PIPE_EXT_OBJ_ARRAY-bit +* indicates that an array object follows struct +* sof_ipc4_glb_pipe_payload. +* +* The object header's SOF_IPC4_GLB_PIPE_EXT_OBJ_LAST-bit in struct +* sof_ipc4_glb_pipe_ext_object indicates if the array is continued +* with another object. The header has also fields to identify the +* object, SOF_IPC4_GLB_PIPE_EXT_OBJ_ID, and to indicate the object's +* size in 32-bit words, SOF_IPC4_GLB_PIPE_EXT_OBJ_WORDS, not +* including the header itself. +* +* The macros below apply to sof_ipc4_glb_pipe_ext_object.header +*/ +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_LAST_SHIFT 0 +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_LAST_MASK BIT(0) +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_LAST (x) ((x) << SOF_IPC4_GLB_PIPE_EXT_OBJ_LAST_SHIFT) + +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_ID_SHIFT 1 +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_ID_MASK GENMASK(15, 1) +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_ID (x) ((x) << SOF_IPC4_GLB_PIPE_EXT_OBJ_ID_SHIFT) + +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_WORDS_SHIFT 16 +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_WORDS_MASK GENMASK(31, 16) +#define SOF_IPC4_GLB_PIPE_EXT_OBJ_WORDS (x) ((x) << SOF_IPC4_GLB_PIPE_EXT_OBJ_WORDS_SHIFT) + +struct sof_ipc4_glb_pipe_ext_object { +u32 header; +u32 data[]; +} __packed__aligned(4) ; + +enum sof_ipc4_glb_pipe_ext_obj_id { +SOF_IPC4_GLB_PIPE_DATA_ID_INVALID =0 , +SOF_IPC4_GLB_PIPE_DATA_ID_MEM_DATA , +SOF_IPC4_GLB_PIPE_DATA_ID_MAX =SOF_IPC4_GLB_PIPE_DATA_ID_MEM_DATA , +}; + +/* Pipeline memory configuration data object for ext_init object array */ +struct sof_ipc4_glb_pipe_ext_obj_memory_data { +u32 domain_id;/* userspace domain ID */ +u32 stack_bytes;/* stack size in bytes */ +u32 heap_bytes;/* heap size in bytes */ +} __packed__aligned(4) ; +/** @}*/ #endif
Signature · 1 line
2.55.0
Peter Ujfalusi
maintainerPATCH 4/6 ASoC: SOF: ipc4-topology: Add payload to pipeline create messages
In reply to Peter UjfalusiFrom: Jyri Sarha <[email protected]>
Start adding payloads to pipeline create messages. The payload contains information for payload specific memory configuration.
All non DP module instances within the same pipeline share the same memory attributes and access the same resources. The new logic sums interim, lifetime, and shared heap memory requirements together and picks the highest stack requirement of all module instances belonging to a pipeline. These pipeline specific attributes are sent as struct sof_ipc4_glb_pipe_payload payload in pipeline's create message.
The idea is to pass common memory configuration for all the Low Latency modules in the pipeline in pipeline create message payload.
The Data Processing module instances will still have an individual memory configuration in struct sof_ipc4_mod_init_ext_dp_memory_data payloads as before. In their payload everything is as it was before, all attributes are copied directly from their topology attributes.
--- sound/soc/sof/ipc4-topology.c | 112 +++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 9 deletions(-)
sound/soc/sof/ipc4-topology.c +103 -9
@@ -1371,6 +1371,22 @@ sof_ipc4_update_resource_usage(struct snd_sof_dev *sdev, struct snd_sof_widget * pipeline = pipe_widget->private; pipeline->mem_usage += total; +/* +* If this is not a Data Processing module instance, add the +* required heap sizes to the sum of all module instances belonging +* to the same pipeline, and find the maximum stack requirement +* among all module instances belonging to the same pipeline. +*/ +if (swidget->comp_domain !=SOF_COMP_DOMAIN_DP ) { + pipe_widget->heap_bytes += swidget->heap_bytes; +if (pipe_widget->stack_bytes < swidget->stack_bytes) + pipe_widget->stack_bytes = swidget->stack_bytes; + +dev_dbg (sdev->dev,"%s mem reqs to %s heap %u stack %u" , + swidget->widget->name, pipe_widget->widget->name, + pipe_widget->heap_bytes, pipe_widget->stack_bytes); + } +/* Update base_config->cpc from the module manifest */ sof_ipc4_update_cpc_from_manifest (sdev, fw_module, base_config);
@@ -1688,6 +1704,8 @@ static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget) pipe_widget = swidget->spipe->pipe_widget; pipeline = pipe_widget->private; pipeline->mem_usage =0 ; + pipe_widget->heap_bytes =0 ; + pipe_widget->stack_bytes =0 ;if (WIDGET_IS_AIF (swidget->id) || swidget->id == snd_soc_dapm_buffer) {if (pipeline->use_chain_dma) {
@@ -3085,11 +3103,11 @@ static int sof_ipc4_control_setup(struct snd_sof_dev *sdev, struct snd_sof_contrreturn 0 ; } -static int sof_ipc4_widget_setup_msg_payload (struct snd_sof_dev *sdev, -struct snd_sof_widget *swidget, -struct sof_ipc4_msg *msg, -void *ipc_data,u32 ipc_size, -void **new_data) +static int sof_ipc4_widget_mod_init_msg_payload (struct snd_sof_dev *sdev, +struct snd_sof_widget *swidget, +struct sof_ipc4_msg *msg, +void *ipc_data,u32 ipc_size, +void **new_data) {struct sof_ipc4_mod_init_ext_dp_memory_data *dp_mem_data;struct sof_ipc4_module_init_ext_init *ext_init;
@@ -3113,13 +3131,14 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,/* Add ext_init first and set objects array flag to 1 */ ext_init = (struct sof_ipc4_module_init_ext_init *)payload; - ext_init->word0 |=SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK ; ext_pos =DIV_ROUND_UP (sizeof (*ext_init),sizeof (u32));/* Add object array objects after ext_init */ /* Add memory_data if comp_domain indicates DP */ if (swidget->comp_domain ==SOF_COMP_DOMAIN_DP ) { + ext_init->word0 |=SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK ; + hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos]; hdr->header =SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK | SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA) |
@@ -3132,7 +3151,6 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev, dp_mem_data->heap_bytes = swidget->heap_bytes; ext_pos +=DIV_ROUND_UP (sizeof (*dp_mem_data),sizeof (u32)); } -/* If another array object is added, remember clear previous OBJ_LAST bit */ /* Calculate final size and check that it fits to max payload size */
@@ -3156,6 +3174,69 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,return new_size; } +static void sof_ipc4_widget_pipe_ext_obj_memory_data (struct snd_sof_dev *sdev, +struct snd_sof_widget *swidget, +u32 *payload,u32 *ext_pos, +struct sof_ipc4_glb_pipe_ext_object **hdr) +{ +struct sof_ipc4_glb_pipe_ext_obj_memory_data *mem_data; + + *hdr = (struct sof_ipc4_glb_pipe_ext_object *)&payload[*ext_pos]; + (*hdr)->header = +SOF_IPC4_GLB_PIPE_EXT_OBJ_ID (SOF_IPC4_GLB_PIPE_DATA_ID_MEM_DATA ) | +SOF_IPC4_GLB_PIPE_EXT_OBJ_WORDS (DIV_ROUND_UP (sizeof (*mem_data), +sizeof (u32))); + *ext_pos +=DIV_ROUND_UP (sizeof (**hdr),sizeof (u32)); + mem_data = (struct sof_ipc4_glb_pipe_ext_obj_memory_data *)&payload[*ext_pos]; + mem_data->domain_id = swidget->domain_id; + mem_data->stack_bytes = swidget->stack_bytes; + mem_data->heap_bytes = swidget->heap_bytes; + *ext_pos +=DIV_ROUND_UP (sizeof (*mem_data),sizeof (u32)); + +dev_dbg (sdev->dev, +"%s; domain_id %u stack %u heap %u bytes" , + swidget->widget->name, mem_data->domain_id, mem_data->stack_bytes, + mem_data->heap_bytes); +} + +static int sof_ipc4_widget_pipe_create_msg_payload (struct snd_sof_dev *sdev, +struct snd_sof_widget *swidget, +struct sof_ipc4_msg *msg, +void **new_data) +{ +struct sof_ipc4_glb_pipe_payload *payload_hdr; +struct sof_ipc4_glb_pipe_ext_object *hdr =NULL ; +u32 *payload; +u32 ext_pos; + + payload =kzalloc (sdev->ipc->max_payload_size,GFP_KERNEL ); +if (!payload) +return -ENOMEM ; + +/* Add sof_ipc4_glb_pipe_payload and set array bit to 1 */ + payload_hdr = (struct sof_ipc4_glb_pipe_payload *)payload; + payload_hdr->word0 |=SOF_IPC4_GLB_PIPE_EXT_OBJ_ARRAY_MASK ; + ext_pos =DIV_ROUND_UP (sizeof (*payload_hdr),sizeof (u32)); + +sof_ipc4_widget_pipe_ext_obj_memory_data (sdev, swidget, payload, &ext_pos, &hdr); +/* Add following array objects here */ + +/* Mark end of object array */ + hdr->header |=SOF_IPC4_GLB_PIPE_EXT_OBJ_LAST_MASK ; + +/* Put total payload size in words to the payload header */ + payload_hdr->word0 |=SOF_IPC4_GLB_PIPE_PAYLOAD_WORDS (ext_pos); + *new_data = payload; + +/* Update msg extension bits according to the payload changes */ + msg->extension |=SOF_IPC4_GLB_PIPE_PAYLOAD_MASK ; + +dev_dbg (sdev->dev,"%s: payload word0 %#x" , swidget->widget->name, + payload_hdr->word0); + +return ext_pos *sizeof (int32_t ); +} +static int sof_ipc4_widget_setup (struct snd_sof_dev *sdev,struct snd_sof_widget *swidget) {struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
@@ -3309,8 +3390,8 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget swidget->widget->name, swidget->pipeline_id, module_id, swidget->instance_id, swidget->core); - ret =sof_ipc4_widget_setup_msg_payload (sdev, swidget, msg, ipc_data, ipc_size, - &ext_data); + ret =sof_ipc4_widget_mod_init_msg_payload (sdev, swidget, msg, ipc_data, ipc_size, + &ext_data);if (ret <0 ) goto fail;
@@ -3322,6 +3403,17 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widgetdev_dbg (sdev->dev,"Create pipeline %s (pipe %d) - instance %d, core %d\n" , swidget->widget->name, swidget->pipeline_id, swidget->instance_id, swidget->core); + + msg->extension &= ~SOF_IPC4_GLB_PIPE_PAYLOAD_MASK ; + ret =sof_ipc4_widget_pipe_create_msg_payload (sdev, swidget, msg, + &ext_data); +if (ret <0 ) + goto fail; + +if (ret >0 ) { + ipc_size = ret; + ipc_data = ext_data; + } } msg->data_size = ipc_size;
@@ -3379,6 +3471,8 @@ static int sof_ipc4_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget swidget->widget->name); pipeline->mem_usage =0 ; + swidget->heap_bytes =0 ; + swidget->stack_bytes =0 ; pipeline->state =SOF_IPC4_PIPE_UNINITIALIZED ;ida_free (&pipeline_ida, swidget->instance_id); swidget->instance_id = -EINVAL ;
Signature · 1 line
2.55.0
Mark Brown
maintainerRe: [PATCH 4/6] ASoC: SOF: ipc4-topology: Add payload to pipeline create messages
sound/soc/sof/ipc4-topology.c sof_ipc4_update_resource_usage(struct snd_sof_dev *sdev, struct snd_sof_widget * · line 1380
Quoted 7 lines · Peter Ujfalusi
sound/soc/sof/ipc4-topology.c +7
-0+/* +* If this is not a Data Processing module instance, add the +* required heap sizes to the sum of all module instances belonging +* to the same pipeline, and find the maximum stack requirement +* among all module instances belonging to the same pipeline. +*/ +if (swidget->comp_domain !=SOF_COMP_DOMAIN_DP ) {
Does this DTRT if the comp_domain was read from the manifest?
sound/soc/sof/ipc4-topology.c static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev, · line 3191
Quoted 7 lines
sound/soc/sof/ipc4-topology.c +6
-0+static void sof_ipc4_widget_pipe_ext_obj_memory_data (struct snd_sof_dev *sdev, +struct snd_sof_widget *swidget, +u32 *payload,u32 *ext_pos, +struct sof_ipc4_glb_pipe_ext_object **hdr) +{ + mem_data->domain_id = swidget->domain_id;
Do we need SOF_COMP_EXT_TOKENS in pipeline_token_list to parse the domain ID?
Re: [PATCH 4/6] ASoC: SOF: ipc4-topology: Add payload to pipeline create messages
Quoted 16 lines · Mark Brown
sound/soc/sof/ipc4-topology.c sof_ipc4_update_resource_usage(struct snd_sof_dev *sdev, struct snd_sof_widget * · line 1380
Quoted 11 lines · Peter Ujfalusi
(quoted diff) +2
-0+ /* + * If this is not a Data Processing module instance, addthe
(quoted diff) +1
-0+ * required heap sizes to the sum of all module instancesbelonging
(quoted diff) +1
-0+ * to the same pipeline, and find the maximum stackrequirement
(quoted diff) +1
-0+ * among all module instances belonging to the samepipeline.
sound/soc/sof/ipc4-topology.c +2
-0+*/ +if (swidget->comp_domain !=SOF_COMP_DOMAIN_DP ) {Does this DTRT if the
comp_domainwas read from the manifest?
Linux driver does not do that, but the SOF FW is supposed to, and it will give an IPC error if the module cannot be configured as a DP module. E.g. the topology should be compatible with the firmware build, and if it's not, there is nothing the Linux driver can do about it but fail.
Quoted 10 lines
Quoted 9 lines
+static void sof_ipc4_widget_pipe_ext_obj_memory_data(struct
snd_sof_dev*sdev,(quoted diff) +1
-0+ struct
snd_sof_widget*swidget,(quoted diff) +1
-0+ u32 *payload,u32
*ext_pos,(quoted diff) +1
-0+ struct
sof_ipc4_glb_pipe_ext_object**hdr)
+{
Quoted 4 lines
sound/soc/sof/ipc4-topology.c static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev, · line 3191
Quoted 1 line
sound/soc/sof/ipc4-topology.c +1
-0+ mem_data->domain_id = swidget->domain_id;Do we need
SOF_COMP_EXT_TOKENSinpipeline_token_listto parse the domain ID?
Not for the moment. We could indeed add its parsing to pipeline nodes, but for the moment the domain_id IPC field in the pipeline message is for future use, and the default 0 for the default memory domain is all we need for the pipelines ATM. The FW is not yet, or in the near future, ready to assign different memory domains for different pipelines.
Best regards,
Jyri
Peter Ujfalusi
maintainerPATCH 5/6 ASoC: SOF: ipc4-topology: Fix sof_ipc4_mod_init_ext_dp_memory_data comments
In reply to Peter UjfalusiFrom: Jyri Sarha <[email protected]>
Fix a copy-paste error in struct sof_ipc4_mod_init_ext_dp_memory_data datamember comments. And while at it, drop the overly specific notes on the datamember values. The values are coming from topology and and what to do with them is decided in SOF FW. Its a bad idea to try to document their meaning in detail here. The Linux driver is only passing the values.
--- include/sound/sof/ipc4/header.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/sound/sof/ipc4/header.h +4 -4
@@ -660,9 +660,9 @@ enum sof_ipc4_mod_init_ext_obj_id {/* DP module memory configuration data object for object array */ struct sof_ipc4_mod_init_ext_dp_memory_data { -u32 domain_id;/* userspace domain ID */ -u32 stack_bytes;/* stack size in bytes, 0 means default size */ -u32 heap_bytes;/* stack size in bytes, 0 means default size */ +u32 domain_id;/* userspace domain ID */ +u32 stack_bytes;/* required stack size in bytes */ +u32 heap_bytes;/* required heap size in bytes */ } __packed__aligned(4) ;/*
@@ -732,7 +732,7 @@ enum sof_ipc4_glb_pipe_ext_obj_id {struct sof_ipc4_glb_pipe_ext_obj_memory_data {u32 domain_id;/* userspace domain ID */ u32 stack_bytes;/* stack size in bytes */ -u32 heap_bytes;/* heap size in bytes */ +u32 heap_bytes;/* heap size in bytes */ } __packed__aligned(4) ;/** @}*/
Signature · 1 line
2.55.0
Peter Ujfalusi
maintainerPATCH 6/6 ASoC: SOF: ipc4-topology: Refactor sof_ipc4_widget_mod_init_msg_payload()
In reply to Peter UjfalusiFrom: Jyri Sarha <[email protected]>
Refactor sof_ipc4_widget_mod_init_msg_payload() to be easier to extend.
--- sound/soc/sof/ipc4-topology.c | 65 ++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 23 deletions(-)
sound/soc/sof/ipc4-topology.c +42 -23
@@ -3103,27 +3103,47 @@ static int sof_ipc4_control_setup(struct snd_sof_dev *sdev, struct snd_sof_contrreturn 0 ; } +static void sof_ipc4_add_init_ext_dp_memory_data (struct snd_sof_dev *sdev, +struct snd_sof_widget *swidget, +u32 *payload,u32 *ext_pos, +struct sof_ipc4_module_init_ext_object **hdr) +{ +/* Add memory_data if comp_domain indicates DP */ +if (swidget->comp_domain ==SOF_COMP_DOMAIN_DP ) { +struct sof_ipc4_mod_init_ext_dp_memory_data *dp_mem_data; + + *hdr = (struct sof_ipc4_module_init_ext_object *)&payload[*ext_pos]; + (*hdr)->header = +SOF_IPC4_MOD_INIT_EXT_OBJ_ID (SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA ) | +SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS (DIV_ROUND_UP (sizeof (*dp_mem_data), +sizeof (u32))); + *ext_pos +=DIV_ROUND_UP (sizeof (**hdr),sizeof (u32)); + dp_mem_data = (struct sof_ipc4_mod_init_ext_dp_memory_data *)&payload[*ext_pos]; + dp_mem_data->domain_id = swidget->domain_id; + dp_mem_data->stack_bytes = swidget->stack_bytes; + dp_mem_data->heap_bytes = swidget->heap_bytes; + *ext_pos +=DIV_ROUND_UP (sizeof (*dp_mem_data),sizeof (u32)); + } +} +static int sof_ipc4_widget_mod_init_msg_payload (struct snd_sof_dev *sdev,struct snd_sof_widget *swidget,struct sof_ipc4_msg *msg,void *ipc_data,u32 ipc_size,void **new_data) { -struct sof_ipc4_mod_init_ext_dp_memory_data *dp_mem_data;struct sof_ipc4_module_init_ext_init *ext_init; -struct sof_ipc4_module_init_ext_object *hdr; +struct sof_ipc4_module_init_ext_object *hdr =NULL ;int new_size;u32 *payload;u32 ext_pos; -/* For the moment the only reason for adding init_ext_init payload is DP -* memory data. If both stack and heap size are 0 (= use default), then -* there is no need for init_ext_init payload. +/* +* Only DP widgets currently add init-ext objects here. Avoid allocating +* a max-sized payload buffer for widgets that will immediately return 0. */ -if (swidget->comp_domain !=SOF_COMP_DOMAIN_DP ) { - msg->extension &= ~SOF_IPC4_MOD_EXT_EXTENDED_INIT_MASK ; +if (swidget->comp_domain !=SOF_COMP_DOMAIN_DP )return 0 ; - } payload =kzalloc (sdev->ipc->max_payload_size,GFP_KERNEL );if (!payload)
@@ -3135,23 +3155,22 @@ static int sof_ipc4_widget_mod_init_msg_payload(struct snd_sof_dev *sdev,/* Add object array objects after ext_init */ -/* Add memory_data if comp_domain indicates DP */ -if (swidget->comp_domain ==SOF_COMP_DOMAIN_DP ) { - ext_init->word0 |=SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK ; +sof_ipc4_add_init_ext_dp_memory_data (sdev, swidget, payload, &ext_pos, &hdr); - hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos]; - hdr->header =SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK | -SOF_IPC4_MOD_INIT_EXT_OBJ_ID (SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA ) | -SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS (DIV_ROUND_UP (sizeof (*dp_mem_data), -sizeof (u32))); - ext_pos +=DIV_ROUND_UP (sizeof (*hdr),sizeof (u32)); - dp_mem_data = (struct sof_ipc4_mod_init_ext_dp_memory_data *)&payload[ext_pos]; - dp_mem_data->domain_id = swidget->domain_id; - dp_mem_data->stack_bytes = swidget->stack_bytes; - dp_mem_data->heap_bytes = swidget->heap_bytes; - ext_pos +=DIV_ROUND_UP (sizeof (*dp_mem_data),sizeof (u32)); +/* Add following object array items here */ + +if (!hdr) { +/* +* NOTE: Remove this early bail out, when struct +* sof_ipc4_module_init_ext_init alone has some +* function. +*/ +kfree (payload); +return 0 ; } -/* If another array object is added, remember clear previous OBJ_LAST bit */ + + ext_init->word0 |=SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK ; + hdr->header |=SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK ;/* Calculate final size and check that it fits to max payload size */ new_size = ext_pos *sizeof (u32) + ipc_size;
Signature · 1 line
2.55.0
Mark Brown
maintainerQuoted 10 lines · Peter Ujfalusi
ASoC: SOF: ipc4-topology: Update the memory data building
Hi,
This series fixes some issues left to the first version
sof_ipc4_mod_init_ext_dp_memory_datapayload building code. The payload to specify memory requirements of Data Processing components, running as independent processes in SOF firmware.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/6] ASoC: SOF: ipc4-topology: Remove dp_ from all module memory attributes
https://git.kernel.org/broonie/sound/c/5a25f27f5118 [2/6] ASoC: SOF: ipc4-topology: Fix SOF_TKN_COMP_STACK_BYTES_REQUIREMENT id https://git.kernel.org/broonie/sound/c/18d0619ced26 [3/6] ASoC: SOF: ipc4: Add SOF_IPC4_GLB_CREATE_PIPELINE payload macros and structs https://git.kernel.org/broonie/sound/c/52db046c388d [4/6] ASoC: SOF: ipc4-topology: Add payload to pipeline create messages https://git.kernel.org/broonie/sound/c/0244c162d1a5 [5/6] ASoC: SOF: ipc4-topology: Fix sof_ipc4_mod_init_ext_dp_memory_data comments https://git.kernel.org/broonie/sound/c/e5b0daa6f974 [6/6] ASoC: SOF: ipc4-topology: Refactor sof_ipc4_widget_mod_init_msg_payload() https://git.kernel.org/broonie/sound/c/221f3b29366e
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark