Skip to content

usb: device_next: class: gs_usb: restart OUT transfers once a buffer is free - #261

Open
gfabiano wants to merge 1 commit into
CANnectivity:mainfrom
gfabiano:gs-usb-out-rearm
Open

gfabiano wants to merge 1 commit into
CANnectivity:mainfrom
gfabiano:gs-usb-out-rearm

Conversation

@gfabiano

@gfabiano gfabiano commented Oct 7, 2026

Copy link
Copy Markdown

Every completed OUT transfer is restarted with a buffer from the class pool. When the pool is empty at that moment, as when the host sends at full rate while frames wait for the IN endpoint, the restart fails and the OUT endpoint is never armed again: the host can no longer send on any channel until the device is enumerated again.

This defers the restart instead. The OUT endpoint is flagged as pending, the pool gets a destroy callback, and once a buffer is returned to it a work item restarts the pending transfer. Whichever path clears the flag (the request handler retrying the allocation, or the work item) restarts the transfer, so the endpoint is never enqueued twice.

Tested on an ESP32-S3 (udc_dwc2) with two gs_usb channels at full load in both directions: without the change the log shows failed to restart OUT transfer for ep 0x01 (err -12) and the host stops sending until the device is reconnected; with it, transmission resumes on both channels every time. Built with and without CONFIG_USBD_GS_USB_COMPATIBILITY_MODE.

…is free

Every completed OUT transfer is restarted with a buffer from the class
pool. When the pool is empty at that moment, as when the host sends at
full rate while frames wait for the IN endpoint, the restart failed and
the OUT endpoint was never armed again: the host could no longer send on
any channel until the device was enumerated again.

Defer the restart instead, and restart the transfer from a work item as
soon as a buffer is returned to the pool.

Signed-off-by: Giuseppe Fabiano <gfabiano40@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant