Skip to content

Conversation

@jsarha
Copy link
Contributor

@jsarha jsarha commented Jun 17, 2025

Extend the existing struct ipc4_module_init_ext_init payload with an abstract object array, and use the object array to pass DP module memory configuration e.g. stack and heap size. The PR contains decoding of the payload and extraction of stack and heap size properties, but no actual functionality for applying the memory configuration for the module. The decoding also lacks the decoding of rtos_domain and gna_used flags and payload.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

LGTM, just some opens. @ranj063 pls also review since this may be used in your params patch ?

struct ipc4_input_pin_format *input_pins;
struct ipc4_output_pin_format *output_pins;
uint32_t stack_size; /* stack size in bytes, 0 means default value */
uint32_t heap_size; /* stack size in bytes, 0 means default value */
Copy link
Member

Choose a reason for hiding this comment

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

This will be max size for heap. i.e. the module may allocate less than this size but never more.

@jsarha
Copy link
Contributor Author

jsarha commented Jun 19, 2025

Let's mark this ready for review to get mor attention.

@jsarha jsarha force-pushed the comp_heap_and_stack_size_limits branch from 36651d9 to 0f9308a Compare June 24, 2025 22:03
@lgirdwood
Copy link
Member

@jsarha LGTM, but last HACK patch, can it be made non hack for SRC using DP ?

struct ipc4_output_pin_format *output_pins;
uint32_t domain_id; /* userspace domain ID */
uint32_t stack_bytes; /* stack size in bytes, 0 means default value */
uint32_t heap_bytes; /* stack size in bytes, 0 means default value */
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo in the comment: "heap size"

@jsarha jsarha force-pushed the comp_heap_and_stack_size_limits branch from 0f9308a to 5d3c13e Compare June 26, 2025 12:36
@jsarha
Copy link
Contributor Author

jsarha commented Jun 27, 2025

This PR is bound to conflict with #10009 , but I fix which ever was left behind.

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

A few comments, please see inline.

if (config->ipc_extended_init)
cfg = module_ext_init_decode(dev, dst, args->data, &cfgsz);
else
cfg = (const struct ipc4_base_module_extended_cfg *)args->data;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as to kernel PR. We already have a concept of "extended init". E.g. we have:

» struct sof_ipc4_base_module_cfg base_config;
» struct sof_ipc4_base_module_cfg_ext *base_config_ext;

All modules have base_config, but some have base_config_ext additionally. This new PR (and the bit29) seems to add a way to extend the module init data, but still keeps the old "base_config_ext" around as well. Having two "extended" module configs is highly confusing. Can we call this new variant (ipc_extended_init) something clearly different?

Copy link
Contributor Author

@jsarha jsarha Jul 1, 2025

Choose a reason for hiding this comment

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

I address all the other comments first and push a new version. I take on this tomorrow, when I am certain we have an agreement on what to do.

So @kv2019i , should I go and rename struct ipc4_module_init_ext_init that has been there since 6c29004 ? Or would something less be enough?

What I find most annoying is that the both payload extesions are described in completely different places in the source tree without any cross reference or comment that the both entities may exist in the same payload. The comments here

give an idea that this is all that should be in module init payload.

Would it be enough if I would document in the above place that struct ipc4_base_module_cfg_ext may follow the already mentioned structs structs, and document the situation the same way on the Linux side?

BTW it currently does not mention here

struct ipc4_base_module_cfg_ext {
at all how, when, or where this struct is used. Is the payload of module init message the only place or is there some other uses too? I could add some comments there too, but I am not certain what they should be.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ack @jsarha . I got (again) confused we extended the module init message both at 1) TOP level (t ipc4_module_init_ext_init) and at 2) BASEFW level (sof_ipc4_base_module_cfg). Given the naming predates your PR, no need to rename now.

if (config->ipc_extended_init)
cfg = module_ext_init_decode(dev, dst, args->data, &cfgsz);
else
cfg = (const struct ipc4_base_module_extended_cfg *)args->data;
Copy link
Contributor Author

@jsarha jsarha Jul 1, 2025

Choose a reason for hiding this comment

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

I address all the other comments first and push a new version. I take on this tomorrow, when I am certain we have an agreement on what to do.

So @kv2019i , should I go and rename struct ipc4_module_init_ext_init that has been there since 6c29004 ? Or would something less be enough?

What I find most annoying is that the both payload extesions are described in completely different places in the source tree without any cross reference or comment that the both entities may exist in the same payload. The comments here

give an idea that this is all that should be in module init payload.

Would it be enough if I would document in the above place that struct ipc4_base_module_cfg_ext may follow the already mentioned structs structs, and document the situation the same way on the Linux side?

BTW it currently does not mention here

struct ipc4_base_module_cfg_ext {
at all how, when, or where this struct is used. Is the payload of module init message the only place or is there some other uses too? I could add some comments there too, but I am not certain what they should be.

@jsarha jsarha force-pushed the comp_heap_and_stack_size_limits branch from 5d3c13e to c87722b Compare July 1, 2025 21:58
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Thanks @jsarha , looks good now.

if (config->ipc_extended_init)
cfg = module_ext_init_decode(dev, dst, args->data, &cfgsz);
else
cfg = (const struct ipc4_base_module_extended_cfg *)args->data;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ack @jsarha . I got (again) confused we extended the module init message both at 1) TOP level (t ipc4_module_init_ext_init) and at 2) BASEFW level (sof_ipc4_base_module_cfg). Given the naming predates your PR, no need to rename now.

@lgirdwood
Copy link
Member

@jsarha can you fix conflicts. Thanks !

Jyri Sarha added 3 commits July 2, 2025 15:13
Adds definition, enums, and bits for adding array of struct
ipc4_module_init_ext_object:s with associated data to struct
ipc4_module_init_ext_init payload. Also adds struct
ipc4_module_init_ext_obj_dp_data as an object to be sent as an object
in the array.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Add ipc_extended_init to struct comp_ipc_config to let component know
that a struct ipc4_module_init_ext_init and possible friends are added
into the struct ipc4_module_init_instance payload. The value of the
boolean is set according to extension bit 29 of struct
ipc4_module_init_instance message.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
…onfig

Add domain_id, stack_bytes and heap_bytes members to
module_config. These may be be filled from ext_init payload.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the comp_heap_and_stack_size_limits branch from c87722b to b020bd2 Compare July 2, 2025 13:28
@jsarha
Copy link
Contributor Author

jsarha commented Jul 2, 2025

@jsarha can you fix conflicts. Thanks !

@lgirdwood done

Copy link
Collaborator

@ranj063 ranj063 left a comment

Choose a reason for hiding this comment

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

LGTM

@wszypelt
Copy link

wszypelt commented Jul 4, 2025

@jsarha TGL IPC4 not building correctly in Internal Intel CI System

@jsarha
Copy link
Contributor Author

jsarha commented Jul 4, 2025

@jsarha TGL IPC4 not building correctly in Internal Intel CI System

I simply do not understand what is wrong with this line:
https://github.com/jsarha/sof/blob/b020bd2ee3e2e762a258bb878b3125dd7aecdd30/src/audio/module_adapter/module_adapter_ipc4.c#L65

... or why this error comes:
/home/runner/work/sof/sof/workspace/sof/src/audio/module_adapter/module_adapter_ipc4.c:65:4: error: expected expression
300
const struct ipc4_module_init_ext_obj_dp_data *dp_data =

The only thing I can think of doing is adding extra { } -block after "case IPC4_MOD_INIT_DATA_ID_DP_DATA:". Let's hope for the best, but I think there is something wrong with the compiler.

@lyakh
Copy link
Collaborator

lyakh commented Jul 4, 2025

@jsarha TGL IPC4 not building correctly in Internal Intel CI System

I simply do not understand what is wrong with this line: https://github.com/jsarha/sof/blob/b020bd2ee3e2e762a258bb878b3125dd7aecdd30/src/audio/module_adapter/module_adapter_ipc4.c#L65

... or why this error comes: /home/runner/work/sof/sof/workspace/sof/src/audio/module_adapter/module_adapter_ipc4.c:65:4: error: expected expression 300 const struct ipc4_module_init_ext_obj_dp_data *dp_data =

The only thing I can think of doing is adding extra { } -block after "case IPC4_MOD_INIT_DATA_ID_DP_DATA:". Let's hope for the best, but I think there is something wrong with the compiler.

@jsarha a variable declaration cannot be the first statement after case ...:

@jsarha jsarha force-pushed the comp_heap_and_stack_size_limits branch from b020bd2 to b7e2bae Compare July 4, 2025 10:05
@jsarha
Copy link
Contributor Author

jsarha commented Jul 4, 2025

Jyri Sarha added 3 commits July 5, 2025 23:55
Add module_ext_init_decode() for struct ipc4_module_init_ext_init
payload decoding. The function goes decodes ext_init and following
object array payload. The only recognized object so far is struct
sof_ipc4_mod_init_ext_dp_memory_data. The possibly found stack and
heap size requirements are copied to struct module_config, but no
other functionality is added. This first version ignores rtos_domain
and gna_used flags, and fails if their associated data is found
in the message payload.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
…utes

Define domain_id, stack_bytes_requirement and heap_bytes_requirement
widget attributes.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
…P SRC

Adds domain_id, stack and heap_size_requirements values to SRCs
widgets if SRC's scheduling domain is DP. At this phase the values are
there only for testing purposes and they do not represent SRC modules
actual requirements. The values are sent to FW using ipc4 module
init message's ext_init payload and its object array.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
@jsarha jsarha force-pushed the comp_heap_and_stack_size_limits branch from b7e2bae to 3b67e6a Compare July 5, 2025 20:55
@jsarha
Copy link
Contributor Author

jsarha commented Jul 5, 2025

Changed module_ext_init_decode() size parameter from uint32_t to size_t to fix a static analysis warning.

@lgirdwood lgirdwood merged commit b3b10a0 into thesofproject:main Jul 7, 2025
37 of 44 checks passed
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.

6 participants