Skip to content

Commit c39e6b2

Browse files
author
Jyri Sarha
committed
ASoC: SOF: ipc4-topology: Changes to mod init mem data message logic
Start adding struct sof_ipc4_mod_init_ext_memory_data payloads to all setup messages and not only to Data Processing module instance setup messages. The idea is that all non DP module instances within the same pipeline share the same memory attributes and access the same heap. The new logic sums heap 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_mod_init_ext_memory_data payload in pipeline's setup message, with the pipeline_id as the domain_id. The non Data Processing module instance's setup messages also have their struct sof_ipc4_mod_init_ext_memory_data payloads. In their payload the domain_id is set to be same as their pipeline_id, and the heap- and stack requirements are not set, as they were already sent with the pipeline setup message. The Data Processing module instances will also have their struct sof_ipc4_mod_init_ext_memory_data payloads as before. In their payload everything is as it was before, all attributes are copied directly from their topology attributes. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 617f177 commit c39e6b2

1 file changed

Lines changed: 45 additions & 19 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,25 @@ sof_ipc4_update_resource_usage(struct snd_sof_dev *sdev, struct snd_sof_widget *
13081308
pipeline = pipe_widget->private;
13091309
pipeline->mem_usage += total;
13101310

1311+
/*
1312+
* If this is not a Data Processing module instance, add the
1313+
* required heap sizes to the sum of all modules instance's
1314+
* belonging to same pipeline and find the maximun stack
1315+
* requirement of all module instances belonging to the same
1316+
* pipeline. Non DP module instances should use pipeline_id as
1317+
* their domain_id.
1318+
*/
1319+
if (swidget->comp_domain != SOF_COMP_DOMAIN_DP) {
1320+
pipe_widget->heap_bytes += swidget->heap_bytes;
1321+
if (pipe_widget->stack_bytes < swidget->stack_bytes)
1322+
pipe_widget->stack_bytes = swidget->stack_bytes;
1323+
1324+
if (swidget->domain_id != 0)
1325+
dev_warn(sdev->dev, "%s is not DP, but domain_id %u was set in topology",
1326+
swidget->widget->name, swidget->domain_id);
1327+
swidget->domain_id = swidget->pipeline_id;
1328+
}
1329+
13111330
/* Update base_config->cpc from the module manifest */
13121331
sof_ipc4_update_cpc_from_manifest(sdev, fw_module, base_config);
13131332

@@ -2964,15 +2983,6 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
29642983
u32 *payload;
29652984
u32 ext_pos;
29662985

2967-
/* For the moment the only reason for adding init_ext_init payload is DP
2968-
* memory data. If both stack and heap size are 0 (= use default), then
2969-
* there is no need for init_ext_init payload.
2970-
*/
2971-
if (swidget->comp_domain != SOF_COMP_DOMAIN_DP) {
2972-
msg->extension &= ~SOF_IPC4_MOD_EXT_EXTENDED_INIT_MASK;
2973-
return 0;
2974-
}
2975-
29762986
payload = kzalloc(sdev->ipc->max_payload_size, GFP_KERNEL);
29772987
if (!payload)
29782988
return -ENOMEM;
@@ -2984,20 +2994,26 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
29842994

29852995
/* Add object array objects after ext_init */
29862996

2987-
/* Add memory_data if comp_domain indicates DP */
2988-
if (swidget->comp_domain == SOF_COMP_DOMAIN_DP) {
2989-
hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos];
2990-
hdr->header = SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK |
2991-
SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_MEM_DATA) |
2992-
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(sizeof(*mem_data),
2997+
hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos];
2998+
hdr->header = SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK |
2999+
SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_MEM_DATA) |
3000+
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(sizeof(*mem_data),
29933001
sizeof(u32)));
2994-
ext_pos += DIV_ROUND_UP(sizeof(*hdr), sizeof(u32));
2995-
mem_data = (struct sof_ipc4_mod_init_ext_memory_data *)&payload[ext_pos];
2996-
mem_data->domain_id = swidget->domain_id;
3002+
ext_pos += DIV_ROUND_UP(sizeof(*hdr), sizeof(u32));
3003+
mem_data = (struct sof_ipc4_mod_init_ext_memory_data *)&payload[ext_pos];
3004+
mem_data->domain_id = swidget->domain_id;
3005+
/*
3006+
* Set stack- and heap sizes only if this is a pipeline widget
3007+
* or if this is a Data Processing module instance. All Low
3008+
* Latency module instances within same pipeline share the same
3009+
* memory properties.
3010+
*/
3011+
if (swidget->comp_domain == SOF_COMP_DOMAIN_DP ||
3012+
swidget->id == snd_soc_dapm_scheduler) {
29973013
mem_data->stack_bytes = swidget->stack_bytes;
29983014
mem_data->heap_bytes = swidget->heap_bytes;
2999-
ext_pos += DIV_ROUND_UP(sizeof(*mem_data), sizeof(u32));
30003015
}
3016+
ext_pos += DIV_ROUND_UP(sizeof(*mem_data), sizeof(u32));
30013017

30023018
/* If another array object is added, remember clear previous OBJ_LAST bit */
30033019

@@ -3188,6 +3204,16 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget
31883204
dev_dbg(sdev->dev, "Create pipeline %s (pipe %d) - instance %d, core %d\n",
31893205
swidget->widget->name, swidget->pipeline_id,
31903206
swidget->instance_id, swidget->core);
3207+
3208+
ret = sof_ipc4_widget_setup_msg_payload(sdev, swidget, msg, ipc_data, ipc_size,
3209+
&ext_data);
3210+
if (ret < 0)
3211+
goto fail;
3212+
3213+
if (ret > 0) {
3214+
ipc_size = ret;
3215+
ipc_data = ext_data;
3216+
}
31913217
}
31923218

31933219
msg->data_size = ipc_size;

0 commit comments

Comments
 (0)