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


##########
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:
   I'd also like to add that on other chips that you have a fix similar to mine 
on kinetis chips, so you may have ran into this same issue in the past:
   - from 2 years ago: 
https://github.com/apache/nuttx/blame/master/arch/arm/src/kinetis/kinetis_lpserial.c#L1665
   - from 5 years ago: 
https://github.com/apache/nuttx/blame/master/arch/arm/src/kinetis/kinetis_serial.c#L1834
   
   so to be clear, we shouldn't add the `!= 0` to the debugassert, we should 
instead add your fix:
   ```
   return (RXDMA_BUFFER_SIZE - (int)dmaresidual) % RXDMA_BUFFER_SIZE;
   ```
   , or my equivalent one I posted above.
   I can do so in a separate PR but I want to make sure we're on the same page 
and both agree that this scenario can and does happen



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