Skip to content

Audio: dax: cache control parameters from the configuration thread - #11350

Merged
lgirdwood merged 2 commits into
thesofproject:mainfrom
checkupup:main_dax_cache_params
Nov 3, 2026
Merged

lgirdwood merged 2 commits into
thesofproject:mainfrom
checkupup:main_dax_cache_params

Conversation

@checkupup

Copy link
Copy Markdown
Contributor

sof_dax_set_configuration() and sof_dax_process() run in different threads, but the configuration path currently writes struct sof_dax directly while the processing thread periodically uses it, causing unsynchronized concurrent access.

Instead, cache all control values and the tuning file in the configuration thread and apply them from sof_dax_process() only. Parameter parsing that touches the DAX context or the DAX library is also restricted to the processing thread, and dax_ctx is updated only after a cached value has been applied successfully. The tuning file is still only swapped into the DAX context for later use.

Instance priority registration uses the cached output device, because dax_ctx is not updated before the stream starts.

The DAX module can only run in a kernel-mode DP thread:

  - its shared state is serialised with k_spin_lock(), which needs
    privileged interrupt masking and is therefore not usable from a user
    thread,
  - the cross-instance DAX instance manager is a kernel-only static in
    base firmware .bss and is not mapped into a DP module memory domain,
  - not every helper it calls from module context (for instance
    comp_data_blob_set()) is exported as a syscall.

Reject it at build time with an explicit #error, and document the
constraint in the module Kconfig help. The guard also covers the LLEXT
variant.

Signed-off-by: junlai <jun.lai@dolby.com>
@sofci

sofci commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

sof_dax_set_configuration() and sof_dax_process() run in different
threads, but the configuration path currently writes struct sof_dax
directly while the processing thread periodically uses it, causing
unsynchronized concurrent access.

Instead, cache all control values and the tuning file in the
configuration thread and apply them from sof_dax_process() only.
Parameter parsing that touches the DAX context or the DAX library is
also restricted to the processing thread, and dax_ctx is updated only
after a cached value has been applied successfully. The tuning file is
still only swapped into the DAX context for later use.

Instance priority registration uses the cached output device, because
dax_ctx is not updated before the stream starts.

Signed-off-by: junlai <jun.lai@dolby.com>
* - a explicit persist/scratch/IO heap buffer size is required for user mode (default is 20KB)
*/
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
#error "Dolby DAX is not user-mode safe"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the not to distant future, all modules will run in userspace.
Are all the changes needed to support userspace in the open source module parts or both open and closed parts of the module ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runing DAX module in userspace (CONFIG_USERSPACE=y) works without issues, but the DAX module does not support CONFIG_SOF_USERSPACE_APLICATION=y (the "user-mode" mentioned in the comments). Only run DAX in userspace with an userspace proxy

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so its just the opensource code then that need updates and nothing blocking in the binary DAX library ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@lgirdwood

Copy link
Copy Markdown
Member

not tested by internal CI.

@lgirdwood
lgirdwood merged commit f92d998 into thesofproject:main Nov 3, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants