mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-08-21 06:23:35 +08:00
rt_data_queue_pop() holds the data queue spinlock while updating the ring state, then calls rt_data_queue_len(). The length function tries to acquire the same non-recursive spinlock again, causing an SMP deadlock when a pop leaves the queue non-empty. Add a private _data_queue_len_nolock() helper for callers which already hold the queue lock. Keep the public rt_data_queue_len() protected by one spinlock acquisition. This does not change the public API, ABI, queue state transitions, low-water mark wakeups, or event callback behavior. Tested on a four-core Spacemit K1 with cyclic HDMI playback and by building the SMP QEMU Virt64 RISC-V BSP with generic audio, Intel HDA and VirtIO Sound. Signed-off-by: GuEe-GUI <2991707448@qq.com>