raiden00pl commented on PR #21746:
URL: https://github.com/apache/nuttx/pull/21746#issuecomment-6893096621
@xiaoxiang781216 @yangsong8-a1 @Donny9
This change hangs CONFIG_CONSOLE_NETDEV (drivers/serial/netdev_console.c)
on SMP.
uart_writev() (and the echo in uart_readv()) calls the DMA hook while
holding uart_spinlock():
uart_writev() → uart_spinlock(dev, true) → uart_dmatxavail() →
uart_xmitchars_dma() → netdev_console_dmasend() → psock_send()
psock_send() sleeps until the packet is sent, and the task can wake up on
another CPU. netdev_console_dmasend() then calls uart_xmitchars_done() →
uart_datasent() → uart_poll_notify() → uart_spinlock(). rspinlock_t is owned by
the CPU, not the task. The lock is still owned by the CPU the task slept on, so
the nested lock is not treated as recursive and the task spins forever, with
interrupts off, on a lock it holds itself.
Instrumented uart_spinlock() (holder tid and caller) on qemu-intel64 shows
exactly this:
SPIN cpu0 tid7 uart_poll_notify, lock owner cpu1 count 1, holder tid7
uart_writev
The old enter_critical_section() was released when the task blocked and
taken again when it resumed, so this worked before. Without CONFIG_SMP the task
cannot change CPU, so the nested lock is always recursive and there is no hang.
Reproduce: qemu-intel64, CONFIG_SMP=y, CONFIG_CONSOLE_NETDEV over UDP
(e1000). Type commands on the console; after a few dozen echoed characters the
console hangs. Reverting 6b1092ae312 and 4289e5ee527 on current master fixes
it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]