-
Notifications
You must be signed in to change notification settings - Fork 349
Add object array abstraction to ipc4_module_init_ext_init and use it to pass stack and heap size for DP modules #10064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6f7b0f9
1adb3a3
355dcf0
f3a9094
aeb63bb
3b67e6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,76 @@ | |||||
|
|
||||||
| LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL); | ||||||
|
|
||||||
| static const struct ipc4_base_module_extended_cfg * | ||||||
| module_ext_init_decode(struct comp_dev *dev, struct module_config *dst, | ||||||
| const unsigned char *data, size_t *size) | ||||||
| { | ||||||
| const struct ipc4_module_init_ext_init *ext_init = | ||||||
| (const struct ipc4_module_init_ext_init *)data; | ||||||
| bool last_object = !ext_init->data_obj_array; | ||||||
| const struct ipc4_module_init_ext_object *obj; | ||||||
|
|
||||||
| if (*size < sizeof(ext_init)) { | ||||||
| comp_err(dev, "Size too small for ext init %u < %u", | ||||||
| *size, sizeof(ext_init)); | ||||||
| return NULL; | ||||||
| } | ||||||
| /* TODO: Handle ext_init->gna_used and ext_init->rtos_domain here */ | ||||||
| /* Get the first obj struct right after ext_init struct */ | ||||||
| obj = (const struct ipc4_module_init_ext_object *)(ext_init + 1); | ||||||
lgirdwood marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| while (!last_object) { | ||||||
| const struct ipc4_module_init_ext_object *next_obj; | ||||||
|
|
||||||
| /* Check if there is space for the object header */ | ||||||
| if ((unsigned char *)(obj + 1) - data > *size) { | ||||||
| comp_err(dev, "ext init obj overflow, %u > %u", | ||||||
| (unsigned char *)(obj + 1) - data, *size); | ||||||
| return NULL; | ||||||
| } | ||||||
| /* Calculate would be next object position and check if current object fits */ | ||||||
| next_obj = (const struct ipc4_module_init_ext_object *) | ||||||
| (((uint32_t *) (obj + 1)) + obj->object_words); | ||||||
| if ((unsigned char *)next_obj - data > *size) { | ||||||
| comp_err(dev, "ext init object array overflow, %u > %u", | ||||||
| (unsigned char *)obj - data, *size); | ||||||
| return NULL; | ||||||
| } | ||||||
| switch (obj->object_id) { | ||||||
| case IPC4_MOD_INIT_DATA_ID_DP_DATA: | ||||||
| { | ||||||
| /* Get dp_data struct that follows the obj struct */ | ||||||
| const struct ipc4_module_init_ext_obj_dp_data *dp_data = | ||||||
| (const struct ipc4_module_init_ext_obj_dp_data *)(obj + 1); | ||||||
|
|
||||||
kv2019i marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| if (obj->object_words * sizeof(uint32_t) < sizeof(*dp_data)) { | ||||||
| comp_err(dev, "dp_data object too small %u < %u", | ||||||
| obj->object_words * sizeof(uint32_t), sizeof(*dp_data)); | ||||||
| return NULL; | ||||||
| } | ||||||
| dst->domain_id = dp_data->domain_id; | ||||||
| dst->stack_bytes = dp_data->stack_bytes; | ||||||
| dst->heap_bytes = dp_data->heap_bytes; | ||||||
| comp_info(dev, "init_ext_obj_dp_data domain %u stack %u heap %u", | ||||||
| dp_data->domain_id, dp_data->stack_bytes, dp_data->heap_bytes); | ||||||
| break; | ||||||
| } | ||||||
| default: | ||||||
| comp_info(dev, "Unknown ext init object id %u of %u words", | ||||||
| obj->object_id, obj->object_words); | ||||||
| } | ||||||
| /* Read the last object flag from obj header */ | ||||||
| last_object = obj->last_object; | ||||||
| /* Move to next object */ | ||||||
| obj = next_obj; | ||||||
| } | ||||||
|
|
||||||
| /* Remove decoded ext_init payload from the size */ | ||||||
| *size -= (unsigned char *) obj - data; | ||||||
|
|
||||||
| /* return remaining payload */ | ||||||
| return (const struct ipc4_base_module_extended_cfg *)obj; | ||||||
| } | ||||||
|
|
||||||
| /* | ||||||
| * \module adapter data initialize. | ||||||
| * \param[in] dev - device. | ||||||
|
|
@@ -39,11 +109,18 @@ int module_adapter_init_data(struct comp_dev *dev, | |||||
| const struct comp_ipc_config *config, | ||||||
| const void *spec) | ||||||
| { | ||||||
| const struct ipc4_base_module_extended_cfg *cfg; | ||||||
| const struct ipc_config_process *args = spec; | ||||||
| const struct ipc4_base_module_extended_cfg *cfg = (void *)args->data; | ||||||
| size_t cfgsz = args->size; | ||||||
|
|
||||||
| assert(dev->drv->type == SOF_COMP_MODULE_ADAPTER); | ||||||
| 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; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Line 175 in 4ecaa95
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 sof/src/include/module/ipc4/base-config.h Line 149 in 4ecaa95
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 (cfg == NULL) | ||||||
| return -EINVAL; | ||||||
| if (cfgsz < sizeof(cfg->base_cfg)) | ||||||
| return -EINVAL; | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.