This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 08d19a6659d1976934ecdcce97d81faa7973738e Author: wangjianyu3 <[email protected]> AuthorDate: Mon Nov 9 21:42:18 2026 +0800 usbdev/cdcacm: send up to the request buffer size actually allocated cdcuart_sendbuf() and cdcuart_dmasend() capped each bulk-IN request to MIN(CONFIG_CDCACM_BULKIN_REQLEN, ep->maxpacket), but the lower half splits an oversized submission into maxpacket-sized packets itself, so the cap wasted most of the allocated buffer (e.g. 4096 vs 512 on HS with CONFIG_CDCACM_BULKIN_REQLEN=4096). Record the actual per-request capacity in wrreqlen at allocation time and have both send paths use it. Assisted-by: OpenCode:claude-sonnet-5 Signed-off-by: wangjianyu3 <[email protected]> --- drivers/usbdev/cdcacm.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/usbdev/cdcacm.c b/drivers/usbdev/cdcacm.c index 83bb3205fad..f068f48777f 100644 --- a/drivers/usbdev/cdcacm.c +++ b/drivers/usbdev/cdcacm.c @@ -107,6 +107,11 @@ struct cdcacm_dev_s #endif bool rxenabled; /* true: UART RX "interrupts" enabled */ bool ispolling; + size_t wrreqlen; /* Per-request TX buffer capacity as + * sized by cdcacm_bind(); the send + * paths use this instead of + * re-deriving it from + * ep->maxpacket. */ spinlock_t lock; struct cdc_linecoding_s linecoding; /* Buffered line status */ @@ -371,9 +376,13 @@ static ssize_t cdcuart_sendbuf(FAR struct uart_dev_s *dev, size_t nbytes; int ret; - /* Get the maximum number of bytes that will fit into one bulk IN request */ + /* Use the full per-request buffer capacity. Capping to ep->maxpacket + * was wrong: the lower half splits an oversized submission into + * maxpacket-sized packets itself, so the cap wasted most of the + * BULKIN_REQLEN buffer. + */ - reqlen = MIN(CONFIG_CDCACM_BULKIN_REQLEN, ep->maxpacket); + reqlen = priv->wrreqlen; /* Peek at the request in the container at the head of the list */ @@ -1386,6 +1395,10 @@ static int cdcacm_bind(FAR struct usbdevclass_driver_s *driver, reqlen = CONFIG_CDCACM_BULKIN_REQLEN; } + /* Record the actual per-request capacity for the send paths. */ + + priv->wrreqlen = reqlen; + for (i = 0; i < CONFIG_CDCACM_NWRREQS; i++) { wrcontainer = &priv->wrreqs[i]; @@ -3044,9 +3057,9 @@ static void cdcuart_dmasend(FAR struct uart_dev_s *dev) size_t reqlen; int ret; - /* Get the maximum number of bytes that will fit into one bulk IN request */ + /* Use the full per-request buffer capacity (see cdcuart_sendbuf). */ - reqlen = MIN(CONFIG_CDCACM_BULKIN_REQLEN, ep->maxpacket); + reqlen = priv->wrreqlen; /* Peek at the request in the container at the head of the list */
