sof
sof copied to clipboard
ipc: do not hold a spinlock when calling schedule_ipc_worker()
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.