-
Notifications
You must be signed in to change notification settings - Fork 321
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
waves: store config blob in a cache in waves.c #8448
Conversation
ret); | ||
module_free_memory(mod, waves_codec->config_blob); | ||
waves_codec->config_blob_size = 0; | ||
return ret; |
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.
replace line 497 with
ret = -ENOMEM;
this can:
- keep same with if part.
- one return in line 502 is enough for this case.
|
||
if (waves_codec->config_blob) { | ||
ret = waves_effect_message(mod, waves_codec->config_blob, | ||
waves_codec->config_blob_size); |
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.
line 734 should align with line 733
10f7210
to
739a583
Compare
comp_err(dev, | ||
"waves_effect_cache_config_blob() failed to allocate %d bytes for config blob", | ||
size); | ||
ret = -ENOMEM; |
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.
I'd just do return -ENOMEM
here (and below) and also avoid a done
debug print in an error case, remove the ret
variable
} | ||
} | ||
comp_dbg(dev, "waves_effect_cache_config_blob() done"); | ||
return ret; |
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.
and just return 0
here
comp_dbg(dev, "waves_effect_apply_config_blob_cache()"); | ||
|
||
if (waves_codec->config_blob) { | ||
ret = waves_effect_message(mod, waves_codec->config_blob, |
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.
return waves_effect_message(...)
here and return 0
below
"waves_effect_cache_config_blob(): failed to copy config blob %d", | ||
ret); | ||
module_free_memory(mod, waves_codec->config_blob); | ||
waves_codec->config_blob_size = 0; |
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.
waves_codec->config_blob = NULL;
accordingly
@@ -492,6 +536,16 @@ static int waves_effect_message(struct processing_module *mod, void *data, uint3 | |||
return 0; | |||
} | |||
|
|||
static int waves_handle_param_message(struct processing_module *mod, void *data, uint32_t size) | |||
{ | |||
int ret = waves_effect_message(mod, data, size); |
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.
why not
int ret = waves_effect_cache_config_blob(mod, data, size);
if (!ret)
ret = waves_effect_message_from_cache(mod);
or even clearer, decouple these two actions:
- when
apply_config()
is called which means the external config is ready --> callwaves_effect_cache_config_blob()
to store into cache - when
prepare()
is called --> callwaves_effect_message_from_cache()
to load config blob from cache and set into module
(Note we don't always set config from external every time before prepare)
May need to consider if it is possible that the external config comes latter than prepare? The same for the current design as well (it seems to early return with error if config comes late for the current design, which can be acceptable by the cases we have now in reality) It is always the best practice that takes the above question into account.
@@ -659,6 +717,22 @@ static int waves_codec_init(struct processing_module *mod) | |||
return ret; | |||
} | |||
|
|||
/* apply config blob */ | |||
static int waves_effect_apply_config_blob_cache(struct processing_module *mod) |
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.
I beg to state that the commit complicates the design. After that there will be both waves_effect_apply_config() and waves_effect_apply_config_cache(). Moreover, waves_effect_config(), waves_effect_cache_config(), and waves_effect_message().
(Please correct me if there is devil in the details.) I do believe the logic is fair enough as I mentioned in the former comment. That is, two reaction chain in total which can be triggered from external:
- set config blob from external:
(...) -> waves_codec_set_configuration() -> waves_effect_apply_config() -> waves_effect_config_save_to_cache()
- start module (trigger prepare) from external:
(...) -> waves_codec_prepare() -> waves_effect_config_load_from_cache()
then handle what if...
- cache is empty when calling
waves_effect_config_load_from_cache()
? - module is processing when calling
waves_effect_config_save_to_cache()
?
@@ -41,7 +41,9 @@ struct waves_codec_data { | |||
uint32_t response_max_bytes; | |||
uint32_t request_max_bytes; | |||
void *response; | |||
struct module_config setup_cfg; | |||
struct module_config setup_cfg; |
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.
I feel certain that setup_cfg is no longer used
if (ret) | ||
comp_err(dev, "waves_codec_prepare() failed %d", ret); | ||
goto error; | ||
|
||
comp_dbg(dev, "waves_codec_prepare() done"); | ||
return ret; |
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.
this can be return 0
now
Store/apply config blob in a cache to avoid that cfg.data will be released after prepare. Signed-off-by: barry.jan <[email protected]>
@johnylin76 are all review comments aligned with the latest update ? |
Yes. Thanks |
Seems ready to go, let me kick the SOF CI once more to get a clean CI sheet. |
SOFCI TEST |
Store/apply config blob in a cache to avoid that
cfg.data will be released after prepare.