-
Notifications
You must be signed in to change notification settings - Fork 349
copier: store gateway config in copier_data #8558
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,8 @@ static int copier_init(struct processing_module *mod) | |
| struct module_data *md = &mod->priv; | ||
| struct ipc4_copier_module_cfg *copier = (struct ipc4_copier_module_cfg *)md->cfg.init_data; | ||
| struct comp_ipc_config *config = &dev->ipc_config; | ||
| void *gtw_cfg = NULL; | ||
| size_t gtw_cfg_size; | ||
| int i, ret = 0; | ||
|
|
||
| cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd)); | ||
|
|
@@ -78,7 +80,31 @@ static int copier_init(struct processing_module *mod) | |
| */ | ||
| if (memcpy_s(&cd->config, sizeof(cd->config), copier, sizeof(*copier)) < 0) { | ||
| ret = -EINVAL; | ||
| goto error; | ||
| goto error_cd; | ||
| } | ||
|
|
||
| /* Allocate memory and store gateway_cfg in runtime. Gateway cfg has to | ||
| * be kept even after copier is created e.g. during SET_PIPELINE_STATE | ||
| * IPC when dai_config_dma_channel() is called second time and DMA | ||
| * config is used to assign dma_channel_id value. | ||
| */ | ||
| if (copier->gtw_cfg.config_length) { | ||
| gtw_cfg_size = copier->gtw_cfg.config_length << 2; | ||
| gtw_cfg = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, | ||
| gtw_cfg_size); | ||
| if (!gtw_cfg) { | ||
| ret = -ENOMEM; | ||
| goto error_cd; | ||
| } | ||
|
|
||
| ret = memcpy_s(gtw_cfg, gtw_cfg_size, &copier->gtw_cfg.config_data, | ||
| gtw_cfg_size); | ||
|
Contributor
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. why we can't directly copy data into cd->gtw_cfg with: ret = memcpy_s(&cd->gtw_cfg, gtw_cfg_size, &copier->gtw_cfg.config_data, |
||
| if (ret) { | ||
| comp_err(dev, "Unable to copy gateway config from copier blob"); | ||
| goto error; | ||
| } | ||
|
|
||
| cd->gtw_cfg = gtw_cfg; | ||
| } | ||
|
|
||
| for (i = 0; i < IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT; i++) | ||
|
|
@@ -148,6 +174,8 @@ static int copier_init(struct processing_module *mod) | |
| dev->state = COMP_STATE_READY; | ||
| return 0; | ||
| error: | ||
| rfree(gtw_cfg); | ||
| error_cd: | ||
| rfree(cd); | ||
| return ret; | ||
| } | ||
|
|
@@ -172,6 +200,8 @@ static int copier_free(struct processing_module *mod) | |
| break; | ||
| } | ||
|
|
||
| if (cd) | ||
| rfree(cd->gtw_cfg); | ||
| rfree(cd); | ||
|
|
||
| return 0; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use
rmalloc()- you overwrite it completely 5 lines later