Skip to content

Commit 73d7277

Browse files
committed
drivers: usb: dwc2: Use fifo sizes from devicetree
Dynamically allocating fifo sizes leads to very complex code that yields subpar results. DWC2 controller has very specific requirements related to configured FIFO sizes that significantly increase the complexity: * each fifo has specific upper bound on both size and starting location (fixed for each silicon) * assigned locations must be contiguous * assigned locations cannot be changed on-the-fly Zephyr tried to dynamically assign fifos using simple but essentially broken algorithm that: * assumed 1-to-1 endpoint number to TxFIFO mapping DWC2 controller can be configured with non-contiguous IN endpoint numbers, but TxFIFOs are always contiguous. * allocated minimum required space for each endpoint There is no benefit in using less SPRAM than hardware has available, but using only 128 locations per bulk endpoint significantly limits maximum transfer rate when using DMA. At least 256 locations allows DMA to load next packet data before previous packet is transmitted on the bus. Actual performance degradation depends on clock rates and latencies. MSC on nRF54H20 using bulk endpoints with only 128 locations can achieve no more than 15.6 MB/s throughput, while with 256 locations speeds up to 36.9 MB/s are possible (running otherwise identical software). * used one-size-fits-all defaults for RxFIFO Remedied with some upper limits calculated at runtime, but the limit was not taking into account complete configuration. * was unable to effectively handle multiple alternate settings This did lead to set interface failures where e.g. HID interface with wMaxPacketSize > 64 was not using the highest numbered IN endpoint within active configuration. Instead of trying to come up with bandaid for each issue that would significantly complicate the code, just shift the responsibility towards firmware developer. While for many typical applications board defaults are perfectly fine, the application developer may want to come up with specific devicetree overrides best suited for their use case. Signed-off-by: Tomasz Moń <[email protected]>
1 parent 7e8ce63 commit 73d7277

File tree

2 files changed

+125
-228
lines changed

2 files changed

+125
-228
lines changed

0 commit comments

Comments
 (0)