userspace: proxy: suspend worker while reconfiguring it - #11050
userspace: proxy: suspend worker while reconfiguring it#11050serhiy-katsyuba-intel wants to merge 1 commit into
Conversation
k_thread_cpu_pin() must not be called on a running thread, and the worker must not execute while its memory domain is being modified. Suspend the worker thread before pinning it to the module core and before the module memory domain is set up, and resume it once the domain has been configured. This fixes a crash in tests with a userspace DP module on a secondary core: the worker thread started by k_work_user_queue_start() was still running on another core and had not yet reached its queue wait condition by the time k_thread_cpu_pin() was called. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
There was a problem hiding this comment.
Pull request overview
This PR prevents the shared userspace IPC worker thread from executing while its CPU affinity and memory domain membership are being reconfigured, addressing a crash caused by calling k_thread_cpu_pin() on a running thread in SMP scenarios.
Changes:
- Suspend the userspace IPC worker before CPU pinning and memory-domain updates, then resume it once the domain configuration step is complete.
- Add targeted error-path handling to ensure the worker is resumed when early failures occur (e.g., CPU pinning or domain partition setup failures).
- Enforce
CONFIG_SCHED_CPU_MASKfor multi-core builds in the non-DP-thread IPC path to ensure CPU pinning support is available.
lgirdwood
left a comment
There was a problem hiding this comment.
@serhiy-katsyuba-intel @lyakh worth checking we are doing this everywhere.
@lgirdwood don't think so. Most SOF threads never migrate. They are created with a |
k_thread_cpu_pin() must not be called on a running thread, and the worker must not execute while its memory domain is being modified. Suspend the worker thread before pinning it to the module core and before the module memory domain is set up, and resume it once the domain has been configured.
This fixes a crash in tests with a userspace DP module on a secondary core: the worker thread started by k_work_user_queue_start() was still running on another core and had not yet reached its queue wait condition by the time k_thread_cpu_pin() was called.