-
Notifications
You must be signed in to change notification settings - Fork 366
dax: fix race condition on the tuning buffer #11056
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -29,11 +29,13 @@ uint32_t dax_query_period_frames(struct sof_dax *dax_ctx) | |
|
|
||
| int dax_free(struct sof_dax *dax_ctx) | ||
| { | ||
| dax_ctx->p_dax = NULL; | ||
| return 0; | ||
| } | ||
|
|
||
| int dax_init(struct sof_dax *dax_ctx) | ||
| { | ||
| dax_ctx->p_dax = dax_ctx->persist_buffer.addr; | ||
| return 0; | ||
| } | ||
|
|
||
|
|
@@ -81,7 +83,7 @@ int dax_set_ctc_enable(int32_t enable, struct sof_dax *dax_ctx) | |
|
|
||
| const char *dax_get_version(void) | ||
| { | ||
| return ""; | ||
| return "mock_version"; | ||
|
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. does C guarantee that this string is allocated in some permanent section and not on stack?
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. Yes, string literals are guaranteed to have static storage duration in C. |
||
| } | ||
|
|
||
| void *dax_find_params(uint32_t query_id, | ||
|
|
||
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 suppose you're implicitly using the fact, that this function only runs in IPC context, when its priority is lower than the processing function? Although IIRC you also support running in DP mode, not sure this priority promise will also always hold for that case. So I suppose you'd need to take the lock in the critical part of the processing function too - where this tuning buffer is used there.
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.
Good point, and I agree we should not rely on an IPC-priority assumption, especially with DP mode in mind.
Also, the active buffer (dax_ctx->tuning_file_buffer) is only switched from the processing path (check_and_update_settings() -> set_tuning_file()), so we do not need to lock the other parts of the processing function.
I think I should add a lock in
dax_set_param_wrapperas well to prevent access to same tuning buffer object.