Skip to content

Conversation

@jsarha
Copy link

@jsarha jsarha commented Sep 17, 2025

This is my first step towards implementing pipeline specific heaps. There is brand new create message payload definition and implementation. However, the target has already moved so that this payload is not enough anymore.

There is also a problem that it looks like the FW receives some pipeline create messages with payload bit set, but the payload is not there. Firmware receives two messages where linux driver only logs about sending only one. This probably has something to do with forwarding the messages form core 0 to core 2. I have no idea how this can happen, but as I should move to work on kernel heap, I leave the debugging for now.

The FW side code is here: thesofproject/sof#10265

@jsarha
Copy link
Author

jsarha commented Sep 17, 2025

FYI @ranj063 @lyakh @lgirdwood

@jsarha jsarha force-pushed the new_memory_domain_logic branch from 1541ecf to c39e6b2 Compare September 18, 2025 15:38

if (swidget->domain_id != 0)
dev_warn(sdev->dev, "%s is not DP, but domain_id %u was set in topology",
swidget->widget->name, swidget->domain_id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we've going to override it anyway, do we need a warning at all? Wont it be just noise?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is about to change. We need separate domain_id and pipeline_id. So this code is already obsolete, but I don't try to reimplement it yet, since it seems the target is still moving.

Jyri Sarha added 2 commits November 10, 2025 23:33
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.

Signed-off-by: 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

See: https://github.com/thesofproject/sof/blob/788861804ed08485496e979dd9c467c1a21b30c5/tools/topology/topology2/include/common/tokens.conf#L30

Signed-off-by: Jyri Sarha <[email protected]>
@jsarha jsarha force-pushed the new_memory_domain_logic branch from cc4773a to c503c3d Compare November 10, 2025 22:35
{SOF_TKN_COMP_STACK_BYTES_REQUIREMENT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct snd_sof_widget, stack_bytes)},
{SOF_TKN_COMP_STATIC_BYTES_REQUIREMENT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct snd_sof_widget, static_bytes)},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to the commit message: is it heap size for initialisation only or for the entire life-time of a single instance (estimated, possibly dependent on configuration or use-case)

#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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you do bitfields instead e.g.

u32 payload : 24;
u32 array : 8;

? Or at least pick up a more informative name like payload_array and maybe use __bitwise?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Linux kernel style, at least in SOF driver, and in all other Linux drivers I've been working on. In SOF driver every other IPC message and payload structure is defined with macros, not with bitfields. I don't think I should diverge from this in PR either.

#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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also be split into sub-fields

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@jsarha jsarha force-pushed the new_memory_domain_logic branch from c503c3d to ead2c46 Compare December 3, 2025 19:17
@jsarha
Copy link
Author

jsarha commented Dec 3, 2025

Updated to match and work with thesofproject/sof#10281 . I will address the review comments at later time.

@jsarha jsarha marked this pull request as ready for review December 4, 2025 13:44
@jsarha
Copy link
Author

jsarha commented Dec 4, 2025

I'll mark this ready for review, but before merging it should be checked that thesofproject/sof#10265 is also going to go in without changes to IPC payload.


dev_dbg(sdev->dev, "payload word0 %#x domain_id %u stack_bytes %u heap_bytes %u",
payload_hdr->word0, mem_data->domain_id, mem_data->stack_bytes,
mem_data->heap_bytes);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation seems be incorrect.

#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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this INTERIM_HEAP

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I can. These tokens were already part of 2.14, but then again they were not really used for anything then.

#define SOF_TKN_COMP_DOMAIN_ID 419
#define SOF_TKN_COMP_STACK_BYTES_REQUIREMENT 420
#define SOF_TKN_COMP_HEAP_BYTES_REQUIREMENT 421
#define SOF_TKN_COMP_LIFETIME_BYTES_REQUIREMENT 422
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and SOF_TKN_COMP_LIFETIME_HEAP_BYTES_REQUIREMENT

Jyri Sarha added 4 commits December 11, 2025 11:59
Add token SOF_TKN_COMP_LIFETIME_HEAP_BYTES_REQUIREMENT for the amount
of allocated memory a module instance needs for the whole of its life
time from init to free, and SOF_TKN_COMP_SHARED_BYTES_REQUIREMENT for
the amount of shared memory it needs to allocate.

Also renames the SOF_TKN_COMP_HEAP_BYTES_REQUIREMENT to
SOF_TKN_COMP_INTERIM_HEAP_BYTES_REQUIREMENT to follow FW
implementation terms.

Signed-off-by: Jyri Sarha <[email protected]>
Add to lifetime_bytes and shared_bytes snd_sof_widget. They are with
SOF_TKN_COMP_LIFETIME_HEAP_BYTES_REQUIREMENT topology tokens and
SOF_TKN_COMP_SHARED_BYTES_REQUIREMENT topology token's values.

Also renames heap_bytes to interim_bytes to follow the term used in FW
side implementation.

Signed-off-by: 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.

Signed-off-by: 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.

Signed-off-by: Jyri Sarha <[email protected]>
@jsarha jsarha force-pushed the new_memory_domain_logic branch from ead2c46 to 91c9b6e Compare December 11, 2025 18:07
@jsarha
Copy link
Author

jsarha commented Dec 11, 2025

The review comments are now addressed, but there is one loose end. The module init payload still uses the old DP memory data in the payload. Its easy change that too, but I need to work on the FW side for it to understand it and to be able to test the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants