Skip to content

Commit 4a6cd66

Browse files
committed
ipc: ipc-helper: make ipc_comp_free() user-space compatible
Use the component mutex when code is run in user-space instead of directly blocking interrupts. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent bfa1096 commit 4a6cd66

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/ipc/ipc-helper.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,16 @@ __cold int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
335335
return -EINVAL;
336336
}
337337

338+
/* Lock buffer lists to prevent racing with the LL scheduler.
339+
* In user-space builds, irq_local_disable() is a privileged
340+
* operation, so use the per-component list_mutex instead
341+
* (same pattern as PPL_LOCK in pipeline_disconnect()).
342+
*/
343+
#ifdef CONFIG_SOF_USERSPACE_LL
344+
k_mutex_lock(icd->cd->list_mutex, K_FOREVER);
345+
#else
338346
irq_local_disable(flags);
347+
#endif
339348
comp_dev_for_each_producer_safe(icd->cd, buffer, safe) {
340349
comp_buffer_set_sink_component(buffer, NULL);
341350
/* This breaks the list, but we anyway delete all buffers */
@@ -348,7 +357,11 @@ __cold int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
348357
comp_buffer_reset_source_list(buffer);
349358
}
350359

360+
#ifdef CONFIG_SOF_USERSPACE_LL
361+
k_mutex_unlock(icd->cd->list_mutex);
362+
#else
351363
irq_local_enable(flags);
364+
#endif
352365

353366
/* free component and remove from list */
354367
comp_free(icd->cd);

0 commit comments

Comments
 (0)