Buffer overrun/underrun issue in FX3 DMA architecture also known as Backflow
This issue is often observed in systems where the GPIF II interface which collects the data from external processor / FPGA / Image sensor which has no flow-control. Here the GPIF block in FX3 writes the received data to the internal buffers continuously without checking it availability, so if the USB host is not capable of reading data in a timely fashion buffer over-run will happen in the GPIF socket & it will end up in the buffer loss & DMA channel crash.
Following are some good design practices to avoid backflow issue:
1. DMA buffering:
a, Try to utilize the maximum DMA buffering in many to one DMA architecture.
b, Do not use very large DMA buffers, make it a multiple of maxpacketsize * max burst length. i.e. maxpacketzise = 1024, Burst = 16, Then make the DMA buffer size 16 * 1024 / 16 * 1024 * 2.
c, Always use maximum USB 3.0 Bursts.
2. Try to minimize the short packets / ZLPs in the system because this will cause the host application xferdata queue to terminate instantly.
3. It is not recommended to add any delay causing elements (Like Debug prints, Buffer parsing & manipulation) in the DMA callback. If it is necessary do it In the application thread using CyU3PDmaChannelGetBuffer() & CyU3PDmaChannelCommitBuffer() APIs with minimal processing.
4. It is also dependent on the Power modes in the PC & the current CPU load, Always use High Performance mode in PC.
5. Disabling LPM features improves the system performance,
6. Always use the latest version of the USB 3.0 host controller drivers,
Hope this will help!!
Thanks & Regards