This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit db56a96812e9e16f1752fec4e46b02b80b56c073
Author: Sarthak Pandey <[email protected]>
AuthorDate: Thu Oct 22 23:01:53 2026 +0530

    serial/serial_dma: don't set nbuffer if head is 0 on ring buffer wrap
    
    When the TX circular buffer wraps around with head == 0,
    uart_xmitchars_dma() previously set nbuffer to the start of the buffer
    even though nlength was 0. This caused underlying DMA drivers to treat
    it as an active split transfer with zero length.
    
    Set nbuffer to NULL and nlength to 0 when head is 0.
    
    Signed-off-by: Sarthak Pandey <[email protected]>
---
 drivers/serial/serial_dma.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_dma.c b/drivers/serial/serial_dma.c
index a2a800cba68..836717f78f3 100644
--- a/drivers/serial/serial_dma.c
+++ b/drivers/serial/serial_dma.c
@@ -118,8 +118,16 @@ void uart_xmitchars_dma(FAR uart_dev_t *dev)
     {
       xfer->buffer  = &dev->xmit.buffer[dev->xmit.tail];
       xfer->length  = dev->xmit.size - dev->xmit.tail;
-      xfer->nbuffer = dev->xmit.buffer;
-      xfer->nlength = dev->xmit.head;
+      if (dev->xmit.head > 0)
+        {
+          xfer->nbuffer = dev->xmit.buffer;
+          xfer->nlength = dev->xmit.head;
+        }
+      else
+        {
+          xfer->nbuffer = NULL;
+          xfer->nlength = 0;
+        }
     }
 
   uart_dmasend(dev);

Reply via email to