New memory domain logic#5537
Conversation
|
FYI @ranj063 @lyakh @lgirdwood |
1541ecf to
c39e6b2
Compare
c39e6b2 to
c9df7c7
Compare
c9df7c7 to
cc4773a
Compare
cc4773a to
c503c3d
Compare
| {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)}, |
There was a problem hiding this comment.
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)
c503c3d to
ead2c46
Compare
|
Updated to match and work with thesofproject/sof#10281 . I will address the review comments at later time. |
|
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. |
ead2c46 to
91c9b6e
Compare
|
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. |
|
Change module init IPC payload as requested by @lgirdwood . |
|
@ujfalusi , @ranj063 , this thesofproject/sof#10265 is getting closer to be merged, could you review this too, hopefully before the merging. |
b1e5288 to
a3430c5
Compare
|
Missed some changes in include directory in the last commit, now the changes are included. |
| 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 */ |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
why change types? I think u32 is preferred in the kernel
|
@kv2019i wrote in #5537 (comment) :
Yes, the pipeline widgets are always built from scratch. "Always" here means the only one time when SOF driver pulls itself up and builds its data structures based on the topology file. The code doing it is bit hard to follow. The benefit of that is that when you have spent couple of days to find that out, you never forget it 😅. Maybe it would deserve a comment some where describing how the driver actually works, but since its not entirely clear to me either, I have not done that. Hmm, once I said that I'd better make sure if this is not one of those things that are made at runtime when pipelines are created in the frimware. Oops. That is indeed the case. It was just the suggestiong where to reset the usages was quite awkward. I'll put it in better place. Still, if I would know by heart all the widget opts branching from ipc topology ops struct (there is a lot of them), I would put this calculation in a place where its done only once at boot time, but unfortunately I do not where that would be, and this function seems to be used for similar purposes. So I just reset the values, but in more sensible place. |
7b5faa3 to
37f470e
Compare
|
Ok. Updated once more. |
There was a problem hiding this comment.
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_PIPELINEto 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.
| File | Description |
|---|---|
| sound/soc/sof/sof-audio.h | Renames/expands widget memory requirement fields to support new memory model. |
| sound/soc/sof/ipc4-topology.c | Parses new tokens, accumulates pipeline memory requirements, and adds IPC payload builders for module init and pipeline create. |
| include/uapi/sound/sof/tokens.h | Updates/extends topology token IDs for memory requirements. |
| include/sound/sof/ipc4/header.h | Adds 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.
| 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", |
| /* Put total payload size in words to the payload header */ | ||
| payload_hdr->word0 |= SOF_IPC4_GLB_PIPE_PAYLOAD_WORDS(ext_pos); | ||
| *new_data = payload; | ||
|
|
||
| /* Update msg extension bits according to the payload changes */ | ||
| msg->extension |= SOF_IPC4_GLB_PIPE_PAYLOAD_MASK; | ||
|
|
||
| dev_dbg(sdev->dev, "%s: payload word0 %#x", swidget->widget->name, | ||
| payload_hdr->word0); | ||
|
|
||
| return ext_pos * sizeof(int32_t); |
| * Macros for creating struct sof_ipc4_glb_pipe_payload payload with | ||
| * its associated data. ext_init payload should be the first piece of | ||
| * payload following SOF_IPC4_GLB_CREATE_PIPELINE msg, and its | ||
| * existence is indicated with SOF_IPC4_GLB_PIPE_PAYLOAD bit. |
| #define SOF_TKN_COMP_STACK_BYTES_REQUIREMENT 420 | ||
| #define SOF_TKN_COMP_INTERIM_HEAP_BYTES_REQUIREMENT 421 | ||
| #define SOF_TKN_COMP_LIFETIME_HEAP_BYTES_REQUIREMENT 422 | ||
| #define SOF_TKN_COMP_SHARED_BYTES_REQUIREMENT 423 |
|
SOFCI TEST |
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>
37f470e to
2ccc28f
Compare
|
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. |
|
FYI @lgirdwood , @ujfalusi , Now that thesofproject/sof#10842 is merged, there is no particular reason to hold this back. |
2ccc28f to
669bd79
Compare
|
Drop the two commits that had no relevant changes. |
| * requirement of all module instances belonging to the same | ||
| * pipeline. | ||
| */ | ||
| if (swidget->comp_domain != SOF_COMP_DOMAIN_DP) { |
There was a problem hiding this comment.
Unset will never happen.
| * If this is not a Data Processing module instance, add the | ||
| * required heap sizes to the sum of all modules instance's | ||
| * belonging to same pipeline and find the maximum stack | ||
| * requirement of all module instances belonging to the same | ||
| * pipeline. |
| * Macros for creating struct sof_ipc4_glb_pipe_payload payload with | ||
| * its associated data. ext_init payload should be the first piece of | ||
| * payload following SOF_IPC4_GLB_CREATE_PIPELINE msg, and its | ||
| * existence is indicated with SOF_IPC4_GLB_PIPE_PAYLOAD bit. |
| SOF_IPC4_GLB_PIPE_DATA_ID_MAX = SOF_IPC4_GLB_PIPE_DATA_ID_MEM_DATA, | ||
| }; | ||
|
|
||
| /* Pipeline memory configuration data object for ext_init object array */ |
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>
669bd79 to
1404820
Compare
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: