nuttx-update/net/usrsock
liangchaozhong cc940e8f69 net_lock:fix deadlock issue when running iperf tx test on usrsock
Issue Description:
deadlock happens when runnging iperf TCP tx on usrsock with the
following commands:
device command: iperf2 -c <PC IP address> -u -i 1 -p 1122  -t 10
PC command: iperf -s -u -i 1 -p 1122

iperf's thread holds net_lock before call usrsock_setup_request_callback
and waits for conn->resp.sem by calling
nxsem_wait_uninterruptible(&conn->resp.sem), while conn->resp.sem
can only be signaled in usrsock_response, who is waiting for net_lock in
tptun's thread.

Solution:
call net_lockedwait_uninterruptible to make sure net_lock can be
released when conn->resp.sem is not available.

Here's the backtrace:
up_block_task
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/sched/semaphore/sem_wait.c:185 (discriminator 2)
nxsem_wait_uninterruptible
nuttx/sched/semaphore/sem_wait.c:223 (discriminator 1)
usrsock_setup_request_callback
nuttx/net/usrsock/usrsock_conn.c:228
usrsock_setup_data_request_callback
nuttx/net/usrsock/usrsock_conn.c:257
usrsock_getsockopt
nuttx/net/usrsock/usrsock_getsockopt.c:202
psock_getsockopt
nuttx/net/socket/getsockopt.c:448
getsockopt
nuttx/net/socket/getsockopt.c:515
getsock_tcp_windowsize
external/iperf2/iperf2/src/tcp_window_size.c:165
reporter_reportsettings
external/iperf2/iperf2/src/ReportDefault.c:384
reporter_print
external/iperf2/iperf2/src/Reporter.c:1402
reporter_process_report
external/iperf2/iperf2/src/Reporter.c:860
reporter_process_report
external/iperf2/iperf2/src/Reporter.c:828
reporter_spawn
external/iperf2/iperf2/src/Reporter.c:720
thread_run_wrapper
external/iperf2/iperf2/compat/Thread.c:270
pthread_startup
nuttx/libs/libc/pthread/pthread_create.c:59 (discriminator 2)
pthread_start
nuttx/sched/pthread/pthread_create.c:182 (discriminator 4)

up_block_task
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/sched/semaphore/sem_wait.c:185 (discriminator 2)
sem_wait
nuttx/sched/semaphore/sem_wait.c:271
nxmutex_lock
nuttx/include/nuttx/mutex.h:165
nxrmutex_lock
nuttx/include/nuttx/mutex.h:369
usrsock_handle_req_response
nuttx/net/usrsock/usrsock_devif.c:466
usrsockdev_write
nuttx/drivers/usrsock/usrsock_dev.c:304
file_write
nuttx/fs/vfs/fs_write.c:90
usrsock_rpmsg_default_handler
apps/netutils/usrsock_rpmsg/usrsock_rpmsg_client.c:137
rpmsg_virtio_rx_callback
nuttx/openamp/open-amp/lib/rpmsg/rpmsg_virtio.c:371
virtqueue_notification
nuttx/openamp/open-amp/lib/virtio/virtqueue.c:706
rproc_virtio_notified
nuttx/openamp/open-amp/lib/remoteproc/remoteproc_virtio.c:337 (discriminator 2)
remoteproc_get_notification
nuttx/openamp/open-amp/lib/remoteproc/remoteproc.c:999
rptun_worker
nuttx/drivers/rptun/rptun.c:333
rptun_thread
nuttx/drivers/rptun/rptun.c:364 (discriminator 1)
nxtask_start
nuttx/sched/task/task_start.c:144

Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-28 16:27:21 +09:00
..
Kconfig net/usrsock: Split NET_USRSOCK_OTHER to NET_USRSOCK_ICMP[v6] 2022-11-22 20:45:26 +09:00
Make.defs move usrsock_dev.c to driver folder 2022-09-10 13:08:22 +08:00
usrsock.h net: Remove usrsock specific process from common code as much as possible 2022-11-28 16:32:41 +09:00
usrsock_accept.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_bind.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_close.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_conn.c net_lock:fix deadlock issue when running iperf tx test on usrsock 2023-01-28 16:27:21 +09:00
usrsock_connect.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_devif.c Revert "add holder for mutex" 2023-01-19 06:04:48 +09:00
usrsock_event.c usrsock: update state to connected when recv sento ready under connecting 2022-10-14 12:29:21 +09:00
usrsock_getpeername.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_getsockname.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_getsockopt.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_ioctl.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_listen.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_poll.c net: Remove usrsock specific process from common code as much as possible 2022-11-28 16:32:41 +09:00
usrsock_recvmsg.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_sendmsg.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_setsockopt.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_socket.c net: consistent the net sem wait naming conversion 2023-01-15 12:31:30 -03:00
usrsock_sockif.c net: Remove usrsock specific process from common code as much as possible 2022-11-28 16:32:41 +09:00