masayuki2009 commented on pull request #4403:
URL: https://github.com/apache/incubator-nuttx/pull/4403#issuecomment-905071324


   @Ouss4 
   In your case, modifyreg32() uses the critical section  API which would cause 
a deadlock if the driver-specific API took a spinlock. Furthermore, in 
cxd56_serial.c case, I remember that up_txint() is called recursively. In this 
case, if we apply the driver-specific spinlock it would also cause a deadlock. 
(Currently, driver-specific spinlock does not permit recursive lock).
   
   ```
   gdb) where 
   #0 0x0d009aa6 in up_testset2 (lock=lock@entry=0x2d05b0a8 <g_uart1priv+28> 
"\001") at chip/cxd56_testset.c:53 
   #1 0x0d009ab2 in up_testset (lock=lock@entry=0x2d05b0a8 <g_uart1priv+28> 
"\001") at chip/cxd56_testset.c:120 
   #2 0x0d004de8 in spin_lock (lock=0x2d05b0a8 <g_uart1priv+28> "\001") at 
semaphore/spinlock.c:77 
   #3 0x0d00411e in spin_lock_irqsave (lock=lock@entry=0x2d05b0a8 
<g_uart1priv+28> "\001") at irq/irq_spinlock.c:103 
   #4 0x0d0003e2 in up_txint (dev=0x2d05b050 <g_uart1port>, enable=<optimized 
out>) at chip/cxd56_serial.c:995 
   #5 0x0d007710 in uart_xmitchars (dev=dev@entry=0x2d05b050 <g_uart1port>) at 
serial/serial_io.c:91 
   #6 0x0d0003fa in up_txint (dev=0x2d05b050 <g_uart1port>, enable=<optimized 
out>) at chip/cxd56_serial.c:1006 
   #7 0x0d0074d8 in uart_write (filep=<optimized out>, buffer=0x2d06bba5 "", 
buflen=0) at serial/serial.c:1225 
   #8 0x0d00cc12 in nx_write (fd=<optimized out>, buf=buf@entry=0x2d06bba4, 
nbytes=nbytes@entry=1) at vfs/fs_write.c:138
   #9 0x0d00cc22 in write (fd=<optimized out>, buf=buf@entry=0x2d06bba4, 
nbytes=nbytes@entry=1) at vfs/fs_write.c:202 
   #10 0x0d00886c in lib_fflush (stream=stream@entry=0x2d06bb84, 
bforce=bforce@entry=1 '\001') at stdio/lib_libfflush.c:117 
   #11 0x0d02ea10 in fputs (s=0xd04cc46 <g_nshgreeting> "\nNuttShell (NSH) 
NuttX-10.1.0\n", stream=0x2d06bb84) at stdio/lib_fputs.c:130 
   #12 0x0d01ceb2 in nsh_session (pstate=0x2d06ca60, login=<optimized out>, 
argc=1, argv=0x2d06bdc8) at nsh_session.c:91 
   #13 0x0d01cbd8 in nsh_consolemain (argc=argc@entry=1, 
argv=argv@entry=0x2d06bdc8) at nsh_consolemain.c:100 
   #14 0x0d01cb82 in nsh_main (argc=1, argv=0x2d06bdc8) at nsh_main.c:153 
   #15 0x0d007ac2 in nxtask_startup (entrypt=0xd0104ed <spresense_main>, 
argc=1, argv=<optimized out>) at sched/task_startup.c:151 
   #16 0x0d005698 in nxtask_start () at task/task_start.c:130 
   ```


-- 
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]


Reply via email to