Skip to content

ptl: userspace: handle userspace module IPC in the DP thread#10952

Open
serhiy-katsyuba-intel wants to merge 1 commit into
thesofproject:mainfrom
serhiy-katsyuba-intel:userspace_crash_fix
Open

ptl: userspace: handle userspace module IPC in the DP thread#10952
serhiy-katsyuba-intel wants to merge 1 commit into
thesofproject:mainfrom
serhiy-katsyuba-intel:userspace_crash_fix

Conversation

@serhiy-katsyuba-intel

Copy link
Copy Markdown
Contributor

The current k_work_user_q-based worker used for userspace IPC processing does not work in the multicore case. An assert is triggered in k_thread_cpu_pin() when a userspace module is created on a secondary core.

k_thread_cpu_pin() only works for a thread that is not currently running. Unfortunately, k_work_user_queue_start() not only initializes the queue but also immediately starts its worker thread on core 0. By the time k_thread_cpu_pin() is called, the worker thread may still be running (in our test it always is) and has not yet reached the wait condition in its loop where it goes to sleep.

Wrapping the k_thread_cpu_pin() call in k_thread_suspend() and k_thread_resume() does not help either: this time the firmware hangs (sometimes, depending on the log level) in k_thread_suspend() due to a race. If the worker thread reaches its wait condition just before the IPI (triggered by k_thread_suspend()) is processed, k_thread_suspend() waits forever for the thread to become suspended.

A possible fix would be to create a work queue per core and pin their threads from core 0, e.g. from secondary_core_init(). Or, more simply, switch to the implementation that uses the DP thread, as is done here.

The current k_work_user_q-based worker used for userspace IPC processing
does not work in the multicore case. An assert is triggered in
k_thread_cpu_pin() when a userspace module is created on a secondary core.

k_thread_cpu_pin() only works for a thread that is not currently running.
Unfortunately, k_work_user_queue_start() not only initializes the queue
but also immediately starts its worker thread on core 0. By the time
k_thread_cpu_pin() is called, the worker thread may still be running (in
our test it always is) and has not yet reached the wait condition in its
loop where it goes to sleep.

Wrapping the k_thread_cpu_pin() call in k_thread_suspend() and
k_thread_resume() does not help either: this time the firmware hangs
(sometimes, depending on the log level) in k_thread_suspend() due to a
race. If the worker thread reaches its wait condition just before the IPI
(triggered by k_thread_suspend()) is processed, k_thread_suspend() waits
forever for the thread to become suspended.

A possible fix would be to create a work queue per core and pin their
threads from core 0, e.g. from secondary_core_init(). Or, more simply,
switch to the implementation that uses the DP thread, as is done here.

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enables processing of userspace module IPC via the DP thread on Panther Lake (ACE30 PTL), avoiding the existing k_work_user_q-based worker approach that breaks in multicore scenarios.

Changes:

  • Enable CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD for the intel_adsp_ace30_ptl board configuration.

CONFIG_DYNAMIC_THREAD_ALLOC=y
CONFIG_DYNAMIC_THREAD_PREFER_ALLOC=y
CONFIG_SOF_STACK_SIZE=8192
CONFIG_SOF_USERSPACE_MOD_IPC_BY_DP_THREAD=y
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.

2 participants