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

   ## Summary                                                                   
   
                                                                                
   
   This PR reduces byte-at-a-time buffer copies in several buffered data paths 
by  
   copying contiguous chunks instead.                                           
   
                                                                                
   
   The changes cover:                                                           
   
                                                                                
   
   - PL2303 USB device serial TX/RX buffering                                   
   
   - CDC ACM USB host serial TX buffering                                       
   
   - FT232R USB host serial TX buffering                                        
   
   - RAM note driver reads                                                      
   
   - ncompress input buffer compaction                                          
   
                                                                                
   
   ## Details                                                                   
   
                                                                                
   
   ### PL2303 USB device serial                                                 
   
                                                                                
   
   The PL2303 driver previously moved data between USB requests and UART 
circular  
   buffers one byte at a time.                                                  
   
                                                                                
   
   This PR changes both directions to copy contiguous ring-buffer segments with 
   
   `memcpy()`:                                                                  
   
                                                                                
   
   - TX: UART TX ring buffer -> USB request buffer                              
   
   - RX: USB OUT request buffer -> UART RX ring buffer                          
   
                                                                                
   
   The copy length is still capped by the USB request size, ring boundary, and  
   
   available RX ring space.  The RX path keeps the existing one-empty-slot rule 
   
   used to distinguish full and empty circular-buffer states.                   
   
                                                                                
   
   ### CDC ACM and FT232R USB host serial                                       
   
                                                                                
   
   The CDC ACM and FT232R host drivers previously filled USB bulk TX buffers by 
   
   advancing through the UART TX ring one byte per loop iteration.              
   
                                                                                
   
   This PR changes those workers to:                                            
   
                                                                                
   
   1. compute the current contiguous UART TX ring segment,                      
   
   2. cap the copy by the remaining USB packet space,                           
   
   3. copy the segment with `memcpy()`,                                         
   
   4. advance the TX tail by the copied length.                                 
   
                                                                                
   
   The existing USB transfer submission and `uart_datasent()` accounting remain 
   
   unchanged.                                                                   
   
                                                                                
   
   ### RAM note driver                                                          
   
                                                                                
   
   The RAM note driver read path previously copied note payloads out of the     
   
   circular buffer one byte at a time.                                          
   
                                                                                
   
   This PR changes the payload copy to use `memcpy()` over contiguous circular  
   
   buffer segments.  The existing `NOTE_ALIGN()` consumption semantics are      
   
   preserved, and the read path now matches the write path's bulk-copy style.   
   
                                                                                
   
   ### ncompress                                                                
   
                                                                                
   
   The ncompress decoder previously compacted its input buffer with a manual 
byte  
   loop after consuming a byte-aligned prefix.                                  
   
                                                                                
   
   This PR changes that compaction to use `memmove()`, which directly expresses 
the
   overlapping-copy semantics.  The call is guarded so it is skipped when no    
   
   buffered input remains.                                                      
   
                                                                                
   
   ## Motivation                                                                
   
                                                                                
   
   These paths may move tens to hundreds of bytes at a time.  Replacing manual  
   
   byte loops with `memcpy()` / `memmove()` lets the C library or compiler use  
   
   optimized block-copy implementations and reduces loop overhead in serial, 
note, 
   and decompression data paths.                                                
   
                                                                                
   
   ## Validation                                                                
   
                                                                                
   
   sim/usbdev


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