ipc: ipc-helper: use list_mutex to guard buffer list in userspace LL#10762
ipc: ipc-helper: use list_mutex to guard buffer list in userspace LL#10762kv2019i wants to merge 1 commit into
Conversation
In user-space LL builds (CONFIG_SOF_USERSPACE_LL), irq_local_disable() is a privileged operation. In ipc_comp_free(), use sys_mutex_lock/unlock on the per-component list_mutex to protect buffer list iteration instead. This follows the same locking pattern as PPL_LOCK/PPL_UNLOCK used in pipeline_disconnect(). Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
|
For context, part of #10558 |
There was a problem hiding this comment.
Pull request overview
This PR updates ipc_comp_free() to avoid using irq_local_disable() in user-space LL builds (CONFIG_SOF_USERSPACE_LL), where disabling IRQs is a privileged operation, by guarding component buffer-list iteration with the per-component list_mutex instead.
Changes:
- Add a
CONFIG_SOF_USERSPACE_LLconditional path that locks/unlocksicd->cd->list_mutexaround producer/consumer buffer list iteration inipc_comp_free(). - Keep the existing
irq_local_disable()/irq_local_enable()path for non-user-space builds.
| #ifdef CONFIG_SOF_USERSPACE_LL | ||
| sys_mutex_lock(&icd->cd->list_mutex, K_FOREVER); | ||
| #else | ||
| irq_local_disable(flags); | ||
| #endif |
There was a problem hiding this comment.
I wonder if we can just replace irq_local_disable() regardless of user or not.
There was a problem hiding this comment.
@kv2019i how will buffer walking during actual pipeline processing in
sof/src/audio/pipeline/pipeline-stream.c
Line 135 in 58c5c5d
There was a problem hiding this comment.
Hmm, this is an oversight. The LL thread priority will protect once LL walk has started, but indeed this does not protect against the case where LL tick happens in middle of ipc_comp_free(). Let me work on improving this.
In principle @lgirdwood we could apply this for all builds, but this does increase regression risk and above case is a good example.
| #ifdef CONFIG_SOF_USERSPACE_LL | ||
| sys_mutex_lock(&icd->cd->list_mutex, K_FOREVER); | ||
| #else |
lgirdwood
left a comment
There was a problem hiding this comment.
I'm good, but just wondered if we should just go full change here and have every config do the same. Not sure if you have already tried.
In user-space LL builds (CONFIG_SOF_USERSPACE_LL), irq_local_disable() is a privileged operation. In ipc_comp_free(), use sys_mutex_lock/unlock on the per-component list_mutex to protect buffer list iteration instead.
This follows the same locking pattern as PPL_LOCK/PPL_UNLOCK used in pipeline_disconnect().