Skip to content

Commit 1541ecf

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 1541ecf

1 file changed

Lines changed: 50 additions & 19 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,30 @@ 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.
1317+
*/
1318+
if (swidget->comp_domain != SOF_COMP_DOMAIN_DP) {
1319+
pipe_widget->heap_bytes += swidget->heap_bytes;
1320+
if (pipe_widget->stack_bytes < swidget->stack_bytes)
1321+
pipe_widget->stack_bytes = swidget->stack_bytes;
1322+
}
1323+
1324+
/*
1325+
* If this is not a Data Processing module instance the
1326+
* pipeline_id should be used as domain_id.
1327+
*/
1328+
if (swidget->comp_domain != SOF_COMP_DOMAIN_DP) {
1329+
if (swidget->domain_id != 0)
1330+
dev_warn(sdev->dev, "%s is not DP, but domain_id %u was set in topology",
1331+
swidget->widget->name, swidget->domain_id);
1332+
swidget->domain_id = swidget->pipeline_id;
1333+
}
1334+
13111335
/* Update base_config->cpc from the module manifest */
13121336
sof_ipc4_update_cpc_from_manifest(sdev, fw_module, base_config);
13131337

@@ -2964,15 +2988,6 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
29642988
u32 *payload;
29652989
u32 ext_pos;
29662990

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-
29762991
payload = kzalloc(sdev->ipc->max_payload_size, GFP_KERNEL);
29772992
if (!payload)
29782993
return -ENOMEM;
@@ -2984,20 +2999,26 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
29842999

29853000
/* Add object array objects after ext_init */
29863001

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),
3002+
hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos];
3003+
hdr->header = SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK |
3004+
SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_MEM_DATA) |
3005+
SOF_IPC4_MOD_INIT_EXT_OBJ_WORDS(DIV_ROUND_UP(sizeof(*mem_data),
29933006
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;
3007+
ext_pos += DIV_ROUND_UP(sizeof(*hdr), sizeof(u32));
3008+
mem_data = (struct sof_ipc4_mod_init_ext_memory_data *)&payload[ext_pos];
3009+
mem_data->domain_id = swidget->domain_id;
3010+
/*
3011+
* Set stack- and heap sizes only if this is a pipeline widget
3012+
* or if this is a Data Processing module instance. All Low
3013+
* Latency module instances within same pipeline share the same
3014+
* memory properties.
3015+
*/
3016+
if (swidget->comp_domain == SOF_COMP_DOMAIN_DP ||
3017+
swidget->id == snd_soc_dapm_scheduler) {
29973018
mem_data->stack_bytes = swidget->stack_bytes;
29983019
mem_data->heap_bytes = swidget->heap_bytes;
2999-
ext_pos += DIV_ROUND_UP(sizeof(*mem_data), sizeof(u32));
30003020
}
3021+
ext_pos += DIV_ROUND_UP(sizeof(*mem_data), sizeof(u32));
30013022

30023023
/* If another array object is added, remember clear previous OBJ_LAST bit */
30033024

@@ -3188,6 +3209,16 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget
31883209
dev_dbg(sdev->dev, "Create pipeline %s (pipe %d) - instance %d, core %d\n",
31893210
swidget->widget->name, swidget->pipeline_id,
31903211
swidget->instance_id, swidget->core);
3212+
3213+
ret = sof_ipc4_widget_setup_msg_payload(sdev, swidget, msg, ipc_data, ipc_size,
3214+
&ext_data);
3215+
if (ret < 0)
3216+
goto fail;
3217+
3218+
if (ret > 0) {
3219+
ipc_size = ret;
3220+
ipc_data = ext_data;
3221+
}
31913222
}
31923223

31933224
msg->data_size = ipc_size;

0 commit comments

Comments
 (0)