jlaitine opened a new pull request, #20133:
URL: https://github.com/apache/nuttx/pull/20133

   ## Summary
   
   Fix a potential deadlock in the DMA driver. DMA completion callbacks may 
immediately submit another transfer, for example:
   
   imx9_dmaterminate()
     -> imx9_dma_txcallback()
       -> imx9_dma_txavailable()
         -> uart_xmitchars_dma()
           -> imx9_dma_send()
             -> imx9_dmach_stop()
            -> imx9_dmaterminate()
   
   Resulting dmaterminate to take the same spinlock again. Fix this by moving 
the spin_unlock_irqrestore_nopreempt before calling the callback. It is not 
necessary to keep dma channel locked during the callback; the channel is 
already free at this point.
   
   This doesn't directly affect arch/arm/imx9 (the cortex-m version) because it 
is not SMP (the spinlock is reduced to blocking irqs), but it is worth fixing 
at the same to keep drivers in sync.
   
   ## Impact
   
   Impacts only imx9 platfrom, fixes a deadlock.
   
   ## Testing
   
   Tested on arm64/imx9, where the deadlock has been found. The issue has been 
reproducecd by enabling eDMA TX and eDMA RX for an uart channel and pushing 
single character TX transmits to the channel. At some point the system locks 
up, at which point the above call chain can be observed with a jtag debugger.
   
   There is no trace for this, due to spinlock related deadlock doesn't produce 
anything visible, it just locks up.
   
   Also tested on the imxrt-1180-evk, (support for which is WIP) that it 
doesn't cause regression there.
   


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