Skip to content

Commit f8b5dde

Browse files
author
Jyri Sarha
committed
ASoC: SOF: ipc4-topology: Add payload to pipeline create messages
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 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_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. Signed-off-by: Jyri Sarha <[email protected]>
1 parent 47cef43 commit f8b5dde

1 file changed

Lines changed: 89 additions & 9 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,25 @@ sof_ipc4_update_resource_usage(struct snd_sof_dev *sdev, struct snd_sof_widget *
13151315
pipeline = pipe_widget->private;
13161316
pipeline->mem_usage += total;
13171317

1318+
/*
1319+
* If this is not a Data Processing module instance, add the
1320+
* required heap sizes to the sum of all modules instance's
1321+
* belonging to same pipeline and find the maximun stack
1322+
* requirement of all module instances belonging to the same
1323+
* pipeline.
1324+
*/
1325+
if (swidget->comp_domain != SOF_COMP_DOMAIN_DP) {
1326+
pipe_widget->heap_bytes += swidget->heap_bytes;
1327+
pipe_widget->static_bytes += swidget->static_bytes;
1328+
if (pipe_widget->stack_bytes < swidget->stack_bytes)
1329+
pipe_widget->stack_bytes = swidget->stack_bytes;
1330+
1331+
dev_dbg(sdev->dev, "%s mem reqs to %s heap %u stack %u static %u",
1332+
swidget->widget->name, pipe_widget->widget->name,
1333+
pipe_widget->heap_bytes, pipe_widget->stack_bytes,
1334+
pipe_widget->static_bytes);
1335+
}
1336+
13181337
/* Update base_config->cpc from the module manifest */
13191338
sof_ipc4_update_cpc_from_manifest(sdev, fw_module, base_config);
13201339

@@ -2995,11 +3014,11 @@ static int sof_ipc4_control_setup(struct snd_sof_dev *sdev, struct snd_sof_contr
29953014
return 0;
29963015
}
29973016

2998-
static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
2999-
struct snd_sof_widget *swidget,
3000-
struct sof_ipc4_msg *msg,
3001-
void *ipc_data, u32 ipc_size,
3002-
void **new_data)
3017+
static int sof_ipc4_widget_mod_init_msg_payload(struct snd_sof_dev *sdev,
3018+
struct snd_sof_widget *swidget,
3019+
struct sof_ipc4_msg *msg,
3020+
void *ipc_data, u32 ipc_size,
3021+
void **new_data)
30033022
{
30043023
struct sof_ipc4_mod_init_ext_dp_memory_data *dp_mem_data;
30053024
struct sof_ipc4_module_init_ext_init *ext_init;
@@ -3023,13 +3042,14 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30233042

30243043
/* Add ext_init first and set objects array flag to 1 */
30253044
ext_init = (struct sof_ipc4_module_init_ext_init *)payload;
3026-
ext_init->word0 |= SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK;
30273045
ext_pos = DIV_ROUND_UP(sizeof(*ext_init), sizeof(u32));
30283046

30293047
/* Add object array objects after ext_init */
30303048

30313049
/* Add memory_data if comp_domain indicates DP */
30323050
if (swidget->comp_domain == SOF_COMP_DOMAIN_DP) {
3051+
ext_init->word0 |= SOF_IPC4_MOD_INIT_EXT_OBJ_ARRAY_MASK;
3052+
30333053
hdr = (struct sof_ipc4_module_init_ext_object *)&payload[ext_pos];
30343054
hdr->header = SOF_IPC4_MOD_INIT_EXT_OBJ_LAST_MASK |
30353055
SOF_IPC4_MOD_INIT_EXT_OBJ_ID(SOF_IPC4_MOD_INIT_DATA_ID_DP_DATA) |
@@ -3042,7 +3062,6 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30423062
dp_mem_data->heap_bytes = swidget->heap_bytes;
30433063
ext_pos += DIV_ROUND_UP(sizeof(*dp_mem_data), sizeof(u32));
30443064
}
3045-
30463065
/* If another array object is added, remember clear previous OBJ_LAST bit */
30473066

30483067
/* Calculate final size and check that it fits to max payload size */
@@ -3066,6 +3085,56 @@ static int sof_ipc4_widget_setup_msg_payload(struct snd_sof_dev *sdev,
30663085
return new_size;
30673086
}
30683087

3088+
static int sof_ipc4_widget_pipe_create_msg_payload(struct snd_sof_dev *sdev,
3089+
struct snd_sof_widget *swidget,
3090+
struct sof_ipc4_msg *msg,
3091+
void **new_data)
3092+
{
3093+
struct sof_ipc4_glb_pipe_ext_obj_memory_data *mem_data;
3094+
struct sof_ipc4_glb_pipe_payload *payload_hdr;
3095+
struct sof_ipc4_glb_pipe_ext_object *obj;
3096+
u32 *payload;
3097+
u32 ext_pos;
3098+
3099+
payload = kzalloc(sdev->ipc->max_payload_size, GFP_KERNEL);
3100+
if (!payload)
3101+
return -ENOMEM;
3102+
3103+
/* Add sof_ipc4_glb_pipe_payload and set array bit to 1 */
3104+
payload_hdr = (struct sof_ipc4_glb_pipe_payload *)payload;
3105+
payload_hdr->word0 |= SOF_IPC4_GLB_PIPE_EXT_OBJ_ARRAY_MASK;
3106+
ext_pos = DIV_ROUND_UP(sizeof(*payload_hdr), sizeof(u32));
3107+
3108+
obj = (struct sof_ipc4_glb_pipe_ext_object *)&payload[ext_pos];
3109+
/* Add object array objects after payload_hdr */
3110+
obj->header = SOF_IPC4_GLB_PIPE_EXT_OBJ_LAST_MASK |
3111+
SOF_IPC4_GLB_PIPE_EXT_OBJ_ID(SOF_IPC4_GLB_PIPE_DATA_ID_MEM_DATA) |
3112+
SOF_IPC4_GLB_PIPE_EXT_OBJ_WORDS(DIV_ROUND_UP(sizeof(*mem_data),
3113+
sizeof(u32)));
3114+
ext_pos += DIV_ROUND_UP(sizeof(*obj), sizeof(u32));
3115+
mem_data = (struct sof_ipc4_glb_pipe_ext_obj_memory_data *)&payload[ext_pos];
3116+
mem_data->domain_id = swidget->domain_id;
3117+
mem_data->stack_bytes = swidget->stack_bytes;
3118+
mem_data->heap_bytes = swidget->heap_bytes;
3119+
mem_data->static_bytes = swidget->static_bytes;
3120+
ext_pos += DIV_ROUND_UP(sizeof(*mem_data), sizeof(u32));
3121+
3122+
/* If another array object is added, remember clear previous OBJ_LAST bit */
3123+
3124+
/* Put total payload size in words to the payload header */
3125+
payload_hdr->word0 |= SOF_IPC4_GLB_PIPE_PAYLOAD_WORDS(ext_pos);
3126+
*new_data = payload;
3127+
3128+
/* Update msg extension bits according to the payload changes */
3129+
msg->extension |= SOF_IPC4_GLB_PIPE_PAYLOAD_MASK;
3130+
3131+
dev_dbg(sdev->dev, "payload word0 %#x domain_id %u stack_bytes %u heap_bytes %u",
3132+
payload_hdr->word0, mem_data->domain_id, mem_data->stack_bytes,
3133+
mem_data->heap_bytes);
3134+
3135+
return ext_pos * sizeof(int32_t);
3136+
}
3137+
30693138
static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
30703139
{
30713140
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
@@ -3219,8 +3288,8 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget
32193288
swidget->widget->name, swidget->pipeline_id, module_id,
32203289
swidget->instance_id, swidget->core);
32213290

3222-
ret = sof_ipc4_widget_setup_msg_payload(sdev, swidget, msg, ipc_data, ipc_size,
3223-
&ext_data);
3291+
ret = sof_ipc4_widget_mod_init_msg_payload(sdev, swidget, msg, ipc_data, ipc_size,
3292+
&ext_data);
32243293
if (ret < 0)
32253294
goto fail;
32263295

@@ -3232,6 +3301,17 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget
32323301
dev_dbg(sdev->dev, "Create pipeline %s (pipe %d) - instance %d, core %d\n",
32333302
swidget->widget->name, swidget->pipeline_id,
32343303
swidget->instance_id, swidget->core);
3304+
3305+
msg->extension &= ~SOF_IPC4_GLB_PIPE_PAYLOAD_MASK;
3306+
ret = sof_ipc4_widget_pipe_create_msg_payload(sdev, swidget, msg,
3307+
&ext_data);
3308+
if (ret < 0)
3309+
goto fail;
3310+
3311+
if (ret > 0) {
3312+
ipc_size = ret;
3313+
ipc_data = ext_data;
3314+
}
32353315
}
32363316

32373317
msg->data_size = ipc_size;

0 commit comments

Comments
 (0)