nuttx/drivers/usbdev
raiden00pl 58d1d9f9d6 drivers/usbdev/cdcacm: serialize the TX ring drain with the class spinlock
cdcacm_sndpacket() runs from task context and from the bulk IN
completion callback, which may be interrupt context.  cdcuart_dmasend()
advances the xmit tail non-atomically, so a completion arriving mid
setup re-sends the same region and advances the tail past the head,
re-transmitting a ring of stale data.

c497c5feb0 dropped the critical section that used to cover this.
Restore it with priv->lock held across the setup and EP_SUBMIT; the
submit must stay inside to keep request order.  cdcuart_dmasend() now
runs with the lock held, so its own acquisition is removed.

The race needs the writer to keep the ring non-empty across
completions, so it only appears at high sustained write rates.  On
nRF52840, 131072-byte writes were received as ~147600 bytes - one extra
CDCACM_TXBUFSIZE of stale data per hit.  With this change the host
receives exactly what was sent.

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-08-09 02:04:26 +08:00
..
adb.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
cdcacm.c drivers/usbdev/cdcacm: serialize the TX ring drain with the class spinlock 2026-08-09 02:04:26 +08:00
cdcacm.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
cdcacm_desc.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
cdcecm.c drivers/usbdev: re-assert soft connect in cdcecm/cdcncm disconnect() 2026-07-30 01:38:22 +08:00
cdcecm.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
cdcncm.c drivers/usbdev: re-assert soft connect in cdcecm/cdcncm disconnect() 2026-07-30 01:38:22 +08:00
CMakeLists.txt drivers/usbdev: add UVC gadget class driver 2026-03-29 12:35:22 -03:00
composite.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
composite.h driver/usbdev: Use small lock to protect composite device 2025-12-13 16:45:06 +08:00
composite_desc.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
dfu.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
Kconfig drivers/usbdev: add UVC gadget class driver 2026-03-29 12:35:22 -03:00
Make.defs drivers/usbdev: add UVC gadget class driver 2026-03-29 12:35:22 -03:00
mtp.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
pl2303.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
rndis.c drivers/usbdev/rndis: Fix reported MTU OID sizes 2026-08-04 17:39:56 -03:00
rndis_std.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
usbdev_desc.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
usbdev_fs.c drivers/: Multiple Drivers Are Registered With World Writable Part 3 2026-07-16 09:49:07 -03:00
usbdev_fs.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
usbdev_req.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
usbdev_strings.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
usbdev_trace.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbdev_trprintf.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbmsc.c usbmsc: fix composite-mode class requests and Hi>Di stall behavior 2026-07-16 15:49:05 +08:00
usbmsc.h drivers/usbdev: Use small lock to protect usbdev msc 2025-12-13 16:45:06 +08:00
usbmsc_desc.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usbmsc_scsi.c usbmsc: fix composite-mode class requests and Hi>Di stall behavior 2026-07-16 15:49:05 +08:00
uvc.c drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00