-
Notifications
You must be signed in to change notification settings - Fork 350
dax: set instance lifespan from prepare to reset #10526
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
Open
checkupup
wants to merge
1
commit into
thesofproject:main
Choose a base branch
from
checkupup:main_dax_alloc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+65
−34
Open
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 |
|---|---|---|
|
|
@@ -181,6 +181,51 @@ static void dax_buffer_produce(struct dax_buffer *dax_buff, uint32_t bytes) | |
| dax_buff->free = dax_buff->size - dax_buff->avail; | ||
| } | ||
|
|
||
| static void destroy_instance(struct processing_module *mod) | ||
| { | ||
| struct sof_dax *dax_ctx = module_get_private_data(mod); | ||
|
|
||
| dax_free(dax_ctx); /* free internal dax instance in dax_ctx */ | ||
| dax_buffer_release(mod, &dax_ctx->persist_buffer); | ||
| dax_buffer_release(mod, &dax_ctx->scratch_buffer); | ||
| } | ||
|
|
||
| static int establish_instance(struct processing_module *mod) | ||
| { | ||
| int ret = 0; | ||
| struct comp_dev *dev = mod->dev; | ||
| struct sof_dax *dax_ctx = module_get_private_data(mod); | ||
| uint32_t persist_sz; | ||
| uint32_t scratch_sz; | ||
|
|
||
| persist_sz = dax_query_persist_memory(dax_ctx); | ||
| if (dax_buffer_alloc(mod, &dax_ctx->persist_buffer, persist_sz) != 0) { | ||
| comp_err(dev, "allocate %u bytes failed for persist", persist_sz); | ||
| ret = -ENOMEM; | ||
| goto err; | ||
| } | ||
| scratch_sz = dax_query_scratch_memory(dax_ctx); | ||
| if (dax_buffer_alloc(mod, &dax_ctx->scratch_buffer, scratch_sz) != 0) { | ||
| comp_err(dev, "allocate %u bytes failed for scratch", scratch_sz); | ||
| ret = -ENOMEM; | ||
| goto err; | ||
| } | ||
| ret = dax_init(dax_ctx); | ||
| if (ret != 0) { | ||
| comp_err(dev, "dax instance initialization failed, ret %d", ret); | ||
| goto err; | ||
| } | ||
| dax_ctx->update_flags |= DAX_ENABLE_MASK; | ||
|
|
||
| comp_info(dev, "allocated: persist %u, scratch %u. version: %s", | ||
| persist_sz, scratch_sz, dax_get_version()); | ||
| return 0; | ||
|
|
||
| err: | ||
| destroy_instance(mod); | ||
| return ret; | ||
| } | ||
|
|
||
| static int set_tuning_file(struct processing_module *mod, void *value, uint32_t size) | ||
| { | ||
| int ret = 0; | ||
|
|
@@ -463,17 +508,23 @@ static void check_and_update_settings(struct processing_module *mod) | |
| } | ||
| } | ||
|
|
||
| static int sof_dax_reset(struct processing_module *mod) { | ||
| struct sof_dax *dax_ctx = module_get_private_data(mod); | ||
|
|
||
| /* dax instance will be established on prepare(), and destroyed on reset() */ | ||
| destroy_instance(mod); | ||
|
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. maybe also add although I'm not sure if it can be reached. We can always be safe. |
||
| dax_buffer_release(mod, &dax_ctx->input_buffer); | ||
| dax_buffer_release(mod, &dax_ctx->output_buffer); | ||
| return 0; | ||
| } | ||
|
|
||
| static int sof_dax_free(struct processing_module *mod) | ||
| { | ||
| struct sof_dax *dax_ctx = module_get_private_data(mod); | ||
|
|
||
| if (dax_ctx) { | ||
| dax_free(dax_ctx); | ||
| dax_buffer_release(mod, &dax_ctx->persist_buffer); | ||
| dax_buffer_release(mod, &dax_ctx->scratch_buffer); | ||
| sof_dax_reset(mod); | ||
| dax_buffer_release(mod, &dax_ctx->tuning_file_buffer); | ||
| dax_buffer_release(mod, &dax_ctx->input_buffer); | ||
| dax_buffer_release(mod, &dax_ctx->output_buffer); | ||
| mod_data_blob_handler_free(mod, dax_ctx->blob_handler); | ||
| dax_ctx->blob_handler = NULL; | ||
| mod_free(mod, dax_ctx); | ||
|
|
@@ -484,12 +535,9 @@ static int sof_dax_free(struct processing_module *mod) | |
|
|
||
| static int sof_dax_init(struct processing_module *mod) | ||
| { | ||
| int ret; | ||
| struct comp_dev *dev = mod->dev; | ||
| struct module_data *md = &mod->priv; | ||
| struct sof_dax *dax_ctx; | ||
| uint32_t persist_sz; | ||
| uint32_t scratch_sz; | ||
|
|
||
| md->private = mod_zalloc(mod, sizeof(struct sof_dax)); | ||
| if (!md->private) { | ||
|
|
@@ -509,35 +557,12 @@ static int sof_dax_init(struct processing_module *mod) | |
| dax_ctx->blob_handler = mod_data_blob_handler_new(mod); | ||
| if (!dax_ctx->blob_handler) { | ||
| comp_err(dev, "create blob handler failed"); | ||
| ret = -ENOMEM; | ||
| goto err; | ||
| } | ||
|
|
||
| persist_sz = dax_query_persist_memory(dax_ctx); | ||
| if (dax_buffer_alloc(mod, &dax_ctx->persist_buffer, persist_sz) != 0) { | ||
| comp_err(dev, "allocate %u bytes failed for persist", persist_sz); | ||
| ret = -ENOMEM; | ||
| goto err; | ||
| } | ||
| scratch_sz = dax_query_scratch_memory(dax_ctx); | ||
| if (dax_buffer_alloc(mod, &dax_ctx->scratch_buffer, scratch_sz) != 0) { | ||
| comp_err(dev, "allocate %u bytes failed for scratch", scratch_sz); | ||
| ret = -ENOMEM; | ||
| goto err; | ||
| } | ||
| ret = dax_init(dax_ctx); | ||
| if (ret != 0) { | ||
| comp_err(dev, "dax instance initialization failed, ret %d", ret); | ||
| goto err; | ||
| mod_free(mod, dax_ctx); | ||
| module_set_private_data(mod, NULL); | ||
| return -ENOMEM; | ||
| } | ||
|
|
||
| comp_info(dev, "allocated: persist %u, scratch %u. version: %s", | ||
| persist_sz, scratch_sz, dax_get_version()); | ||
| return 0; | ||
|
|
||
| err: | ||
| sof_dax_free(mod); | ||
| return ret; | ||
| } | ||
|
|
||
| static int check_media_format(struct processing_module *mod) | ||
|
|
@@ -631,6 +656,11 @@ static int sof_dax_prepare(struct processing_module *mod, struct sof_source **so | |
| if (ret != 0) | ||
| return ret; | ||
|
|
||
| /* dax instance will be established on prepare(), and destroyed on reset() */ | ||
| ret = establish_instance(mod); | ||
| if (ret != 0) | ||
| return ret; | ||
|
|
||
| dax_ctx->sof_period_bytes = dev->frames * | ||
| dax_ctx->output_media_format.num_channels * | ||
| dax_ctx->output_media_format.bytes_per_sample; | ||
|
|
@@ -855,6 +885,7 @@ static const struct module_interface dolby_dax_audio_processing_interface = { | |
| .prepare = sof_dax_prepare, | ||
| .process = sof_dax_process, | ||
| .set_configuration = sof_dax_set_configuration, | ||
| .reset = sof_dax_reset, | ||
| .free = sof_dax_free, | ||
| }; | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
recommend to add a comment here