sof icon indicating copy to clipboard operation
sof copied to clipboard

ipc: do not hold a spinlock when calling schedule_ipc_worker()

Open kv2019i opened this issue 5 months ago • 1 comments

Calling schedule_ipc_worker() with spinlock held is not stricly required. schedule_ipc_worker() calls k_work_schedule_for_queue() and the Zephyr workqueue has an internal lock protecting the workqueue structures. Keeping spinlock held during the call does lead to complex scenarios to debug and verify as schedule_ipc_worker() itself is dispatched from a work queue.

Simplify the flow and release spinlock before rescheduling the worker. In ipc_work_handler(), this leaves a small window where the message is just sent after we release the spinlock, and before we call schedule_ipc_worker(). This is however harmless, as in worst case the IPC worker is woken up one extra time.

kv2019i avatar Aug 15 '25 16:08 kv2019i

Discussed with @lyakh . He'd like to see a concrete case where this causes failures and I don't have one at this point. Putting as draft for now to prevent merge until we have better consensus.

kv2019i avatar Aug 18 '25 07:08 kv2019i