Files
nuttx/drivers
wangshaoxin 43d26e2890 drivers/rptun: solve the poweroff stuck problem
The rpmsg_ioctl() function will first obtain the read lock before
traversing g_rpmsg, then the rpmsg_dev_destory function will try
to obtain the write lock.

At this time, rpmsg_ioctl does not release the read lock, resulting
in a deadlock.

To solve this problem, add a standardalone list for the rptun instance
to avoid hold the rpmsg lock when execute rptun_poweroff()

Backtrace:
Thread 14 nsh_main
0  0x4412b9da in up_switch_context (tcb=0xeac03380, rtcb=0xe7f02480) at sim/sim_switchcontext.c:95
1  0x43fbe5e4 in nxsem_wait_slow (sem=0x5179d570 <g_rpmsg_lock+16>) at semaphore/sem_wait.c:170
2  0x43fbeacf in nxsem_wait (sem=0x5179d570 <g_rpmsg_lock+16>) at semaphore/sem_wait.c:272
3  0x44671a26 in down_write (rwsem=0x5179d560 <g_rpmsg_lock>) at semaphore/sem_rw.c:248
4  0x4401e255 in rpmsg_device_destory (rpmsg=0xe7b03280) at rpmsg/rpmsg.c:469
5  0x4402f5fe in rptun_dev_stop (rproc=0xe7b033e4, stop_ns=true) at rptun/rptun.c:973
6  0x4402aa28 in rptun_ioctl (rpmsg=0xe7b03280, cmd=11109, arg=0) at rptun/rptun.c:661
7  0x4401ba1e in rpmsg_dev_ioctl_ (rpmsg=0xe7b03280, cmd=11109, arg=0) at rpmsg/rpmsg.c:137
8  0x4401ee88 in rpmsg_ioctl (cpuname=0x0, cmd=11109, arg=0) at rpmsg/rpmsg.c:562
9  0x44030cb0 in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1183
10 0x43f27be2 in board_power_off (status=0) at sim/sim_head.c:211
11 0x446fd933 in boardctl (cmd=65283, arg=0) at boardctl.c:401
12 0x44313b95 in cmd_poweroff (vtbl=0xe7600e80, argc=1, argv=0xe7824350) at nsh_syscmds.c:368
13 0x442d148c in nsh_command (vtbl=0xe7600e80, argc=1, argv=0xe7824350) at nsh_command.c:1275
14 0x442f65f5 in nsh_execute (vtbl=0xe7600e80, argc=1, argv=0xe7824350, param=0xe78242b0) at nsh_parse.c:716
15 0x44304fb4 in nsh_parse_command (vtbl=0xe7600e80, cmdline=0xe7601338 "poweroff") at nsh_parse.c:2809
16 0x44305a50 in nsh_parse (vtbl=0xe7600e80, cmdline=0xe7601338 "poweroff") at nsh_parse.c:2919
17 0x442bdc91 in nsh_session (pstate=0xe7600e80, login=1, argc=1, argv=0xe7814870) at nsh_session.c:246
18 0x442bbbe5 in nsh_consolemain (argc=1, argv=0xe7814870) at nsh_consolemain.c:75
19 0x4422b4bb in nsh_main (argc=1, argv=0xe7814870) at nsh_main.c:74
20 0x440ee098 in nxtask_startup (entrypt=0x4422b39a <nsh_main>, argc=1, argv=0xe7814870) at sched/task_startup.c:72
21 0x43fa1d6e in nxtask_start () at task/task_start.c:116
22 0x4412982c in pre_start () at sim/sim_initialstate.c:53
23 0x00000000 in ?? ()

Signed-off-by: wangshaoxin <wangshaoxin@xiaomi.com>
2026-01-08 12:05:46 +08:00
..
2025-12-10 23:54:44 +08:00
2025-12-01 14:38:02 +01:00