Skip to content

New memory domain logic - #5537

Merged
lgirdwood merged 7 commits into
thesofproject:topic/sof-devfrom
jsarha:new_memory_domain_logic
Jul 20, 2026
Merged

New memory domain logic#5537
lgirdwood merged 7 commits into
thesofproject:topic/sof-devfrom
jsarha:new_memory_domain_logic

Conversation

@jsarha

@jsarhajsarha commented Sep 17, 2025

Copy link
Copy Markdown
Collaborator

Let's put this on hold until I get my experiment about implicit interim vs. lifetime heap division. E.g. Since the lifetime allocations are done at pipeline and module init phase and the interim allocations later - at runtime - it should be possible to create the interim heap when the first interim allocation arrives and use all memory that is left of lifetime heap. If this scheme works well, we can drop the interim vs. lifetime heap division.

The original description has been obsolete already for some time:

his 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: https://github.com/thesofproject/sof/pull/10265

@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

FYI @ranj063@lyakh@lgirdwood

@jsarha
jsarhaforce-pushed the new_memory_domain_logic branch from 1541ecf to c39e6b2CompareSeptember 18, 2025 15:38
Comment threadsound/soc/sof/ipc4-topology.c Outdated
Comment threadsound/soc/sof/ipc4-topology.c
Comment threadsound/soc/sof/ipc4-topology.c Outdated
{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
Copy Markdown
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)

Comment threadinclude/sound/sof/ipc4/header.h Outdated
Comment threadinclude/sound/sof/ipc4/header.h
Comment threadinclude/sound/sof/ipc4/header.h
@jsarha
jsarhaforce-pushed the new_memory_domain_logic branch from c503c3d to ead2c46CompareDecember 3, 2025 19:17
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
CollaboratorAuthor

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.

Comment threadsound/soc/sof/ipc4-topology.c Outdated
Comment threadinclude/uapi/sound/sof/tokens.h
Comment threadinclude/uapi/sound/sof/tokens.h Outdated
@jsarha
jsarhaforce-pushed the new_memory_domain_logic branch from ead2c46 to 91c9b6eCompareDecember 11, 2025 18:07
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

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.

@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

Change module init IPC payload as requested by @lgirdwood .

@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

@ujfalusi , @ranj063 , this thesofproject/sof#10265 is getting closer to be merged, could you review this too, hopefully before the merging.

@lgirdwoodlgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few questions

Comment threadinclude/uapi/sound/sof/tokens.h
Comment threadsound/soc/sof/ipc4-topology.c
Comment threadsound/soc/sof/ipc4-topology.c
lgirdwood
lgirdwood previously approved these changes Jan 20, 2026
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

Missed some changes in include directory in the last commit, now the changes are included.

kv2019i
kv2019i previously approved these changes Jan 22, 2026
Comment threadinclude/sound/sof/ipc4/header.h Outdated
uint32_t stack_bytes; /* required stack size in bytes */
uint32_t interim_heap_bytes; /* required interim heap size in bytes */
uint32_t lifetime_heap_bytes; /* required lifetime heap size in bytes */
uint32_t shared_bytes; /* required shared memory size in bytes */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewing this together with thesofproject/sof#10265 makes this a bit easier to follow. I still find relation of interim and lifetime a bit confusing, but additional notes in #10265 clarify this a bit (lifetime_heap_bytes memory needed in init and interim_heap_bytes stuff that may be allocated during runtime).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why change types? I think u32 is preferred in the kernel

@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

Ok. Updated once more.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR is an initial step toward pipeline-specific heap/memory configuration support in the SOF IPC4 driver by extending topology tokens and IPC payload construction to carry per-module and per-pipeline memory requirements.

Changes:

  • Replace DP-specific dp_* widget memory fields with generalized per-instance memory requirement fields (domain_id, stack_bytes, interim_bytes, lifetime_bytes, shared_bytes).
  • Extend IPC4 topology token parsing to populate the new memory requirement fields and accumulate non-DP module requirements at the pipeline level.
  • Introduce a payload format + builder for SOF_IPC4_GLB_CREATE_PIPELINE to send pipeline memory configuration via an object array.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

FileDescription
sound/soc/sof/sof-audio.hRenames/expands widget memory requirement fields to support new memory model.
sound/soc/sof/ipc4-topology.cParses new tokens, accumulates pipeline memory requirements, and adds IPC payload builders for module init and pipeline create.
include/uapi/sound/sof/tokens.hUpdates/extends topology token IDs for memory requirements.
include/sound/sof/ipc4/header.hAdds IPC4 definitions/macros/structs for pipeline create payload object array and expands DP memory data struct.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsound/soc/sof/ipc4-topology.c Outdated
if (pipe_widget->stack_bytes < swidget->stack_bytes)
pipe_widget->stack_bytes = swidget->stack_bytes;

dev_dbg(sdev->dev, "%s mem reqs to %s lifetime %u heap %u shared %u stack %u",
Comment threadsound/soc/sof/ipc4-topology.c
Comment threadinclude/sound/sof/ipc4/header.h Outdated
Comment threadinclude/uapi/sound/sof/tokens.h Outdated
kv2019i
kv2019i previously approved these changes Apr 22, 2026
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

SOFCI TEST

Jyri Sarha added 2 commits June 3, 2026 00:47
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 <jyri.sarha@linux.intel.com>
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 <jyri.sarha@linux.intel.com>
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

This version has taken couple of steps back. There is no more separate lifetime and interim heap sizes being specified. The FW manages the division by itself, that is if the approach in thesofproject/sof#10783 is accepted.

@jsarhajsarha changed the title [DNM] New memory domain logicNew memory domain logicJun 9, 2026
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

FYI @lgirdwood , @ujfalusi , Now that thesofproject/sof#10842 is merged, there is no particular reason to hold this back.

@jsarha
jsarhaforce-pushed the new_memory_domain_logic branch from 2ccc28f to 669bd79CompareJune 25, 2026 14:56
CopilotAI review requested due to automatic review settings June 25, 2026 14:56
@jsarha

Copy link
Copy Markdown
CollaboratorAuthor

Drop the two commits that had no relevant changes.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment threadsound/soc/sof/ipc4-topology.c
Comment threadsound/soc/sof/ipc4-topology.c Outdated
Comment threadinclude/sound/sof/ipc4/header.h Outdated
Comment threadinclude/sound/sof/ipc4/header.h
Jyri Sarha added 5 commits June 25, 2026 21:37
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 <jyri.sarha@linux.intel.com>
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 <jyri.sarha@linux.intel.com>
…ry_data
Change struct sof_ipc4_mod_init_ext_dp_memory_data to what is required
for the SOF FW userspace DP processing. The earlier version of the
firmware (v2.14) did not use the contents of the struct for anything,
and if it receives a struct that is larger than the original, the
extra words are simply ignored, so there should not be any problem in
changing the struct. The following FW versions will expect larger
struct and ignore anything that is smaller.
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
…ad()
Refactor sof_ipc4_widget_mod_init_msg_payload() to be easier to extend.
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
…ad()
Optimize sof_ipc4_widget_mod_init_msg_payload() so that it skips the
payload allocation and rest of the function if no payload is needed.
Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha
jsarhaforce-pushed the new_memory_domain_logic branch from 669bd79 to 1404820CompareJune 25, 2026 18:44
@lgirdwood
lgirdwood merged commit 8e1e0d8 into thesofproject:topic/sof-devJul 20, 2026
8 of 9 checks passed
Sign up for freeto 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.

8 participants

@jsarha@lgirdwood@lyakh@ranj063@bardliao@ujfalusi@kv2019i