danielappiagyei-bc commented on code in PR #11020:
URL: https://github.com/apache/nuttx/pull/11020#discussion_r1373486112


##########
arch/arm/src/imxrt/imxrt_serial.c:
##########
@@ -1373,6 +1373,7 @@ static inline void imxrt_serialout(struct imxrt_uart_s 
*priv,
 static int imxrt_dma_nextrx(struct imxrt_uart_s *priv)
 {
   int dmaresidual = imxrt_dmach_getcount(priv->rxdma);
+  DEBUGASSERT(dmaresidual <= RXDMA_BUFFER_SIZE);

Review Comment:
   Appreciate the thorough work here david. I don't have an answer for why I'm 
experiencing the issue while you're not. I apologize for not having a branch 
with a minimum, reproducible example to give you, as I'm using my company's 
codebase as a test bed. Are you opposed to me just making a PR with my 
suggested fix? It is only an extra `if` statement with a simple conditional so 
performance really shouldn't be affected. It also does not make the existing 
code suddenly incorrect, so I don't see any negatives to it
   
   ```
   static unsigned int imxrt_dma_nextrx(struct imxrt_uart_s *priv)
   {
     unsigned int dmaresidual = imxrt_dmach_getcount(priv->rxdma);
     DEBUGASSERT(dmaresidual <= RXDMA_BUFFER_SIZE);
     if (dmaresidual == 0)
       {
         /* We've finished transferring RXDMA_BUFFER_SIZE bytes. The next byte
          * will be placed at the beginning of the buffer
          */
   
         return 0;
       }
     else
       {
         return RXDMA_BUFFER_SIZE - dmaresidual;
       }
   }
   ```
   
   This is essentially equivalent to what you did for `kinetis_serial.c`:
   ```
   return (RXDMA_BUFFER_SIZE - (int)dmaresidual) % RXDMA_BUFFER_SIZE;
   ```
   Note that `kinetis_edma.c` [also has a EDMA_TCD_DONE 
flag](https://github.com/apache/nuttx/blob/master/arch/arm/src/kinetis/kinetis_edma.c#L1051)
   
   The register description of the eDMA `DONE` flag I posted earlier does not 
say that it won't automatically be set for our configuration. I can post on the 
NXP support forum and ask them specifically about the IMXRT1064 and place the 
reply here.
   



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