Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB "fast buffer switching" on stm32 usbfs devices #6352

Merged
merged 4 commits into from
Oct 4, 2023

Conversation

KevinOConnor
Copy link
Collaborator

This adds support for "fast buffer switching" on the USB peripheral of stm32f1, stm32g0, and stm32f0 devices.

This feature can improve the USB transfer rates on these devices. It's unlikely to be noticed on traditional emulated serial over USB setups, but it can have a notable impact when using USB to CANBUS bridge configurations.

When the micro-controller is configured to behave as a canbus adapter, the gs_usb linux kernel protocol requires many small USB packets to be transferred. Optimizing the USB buffer handling can notably improve overall transfer rates. In particular, I've found that, prior to these changes, the USB to CANBUS bridge setup was bottlenecked by USB transfers on some machines (such as the rpi3) - thus preventing those setups from utilizing the full bandwidth of 1Mbit/s canbus.

-Kevin

Replace the set_stat_x_bits() functions with a single calc_epr_bits()
function.  This new function supports setting bits other than the stat
field in the epr register.

Signed-off-by: Kevin O'Connor <[email protected]>
The usbfs device supports two buffers for each endpoint - typically
one for rx and one for tx.  Add support for explicit handling of both
buffers.  This is in preparation for improved "double buffering"
support.

Signed-off-by: Kevin O'Connor <[email protected]>
Implement the usbfs fast buffer switching mechanism on the "bulk out"
endpoint.  This can improve the overall USB throughput and bus
utilization.

Signed-off-by: Kevin O'Connor <[email protected]>
Implement the usbfs fast buffer switching mechanism on the "bulk in"
endpoint.  This can improve the overall USB throughput and bus
utilization.

Signed-off-by: Kevin O'Connor <[email protected]>
@KevinOConnor KevinOConnor force-pushed the work-stm32usbfs-20230924 branch from f2b23c1 to cd8d57c Compare October 4, 2023 03:26
@KevinOConnor KevinOConnor merged commit cd8d57c into master Oct 4, 2023
3 checks passed
@KevinOConnor KevinOConnor deleted the work-stm32usbfs-20230924 branch October 4, 2023 03:27
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant