We are using an IMX8M-MINI QUAD Core 1.8GHz, and kernel version 4.14.78.
We have discovered a problem of latency in the software driver of the uart device "/dev/ttymxc1".
We have checked the round trip delay of a byte transmitted and received on the uart device. The ttymxc1 was configured 8N1 with a custom baud rate of 31250, that is the frequency of a MIDI device (Musical Instrument Device Interface). We have measured a round trip delay of 13 ms. This delay is not acceptable for a MIDI device.
After some brief analysis, we have discovered that the problem was related to the file /driver/tty/serial/imx.c of the kernel (4.14.78). Moreover, the delay is located in the rx part of the uart driver (not in the tx part).
We have changed the define RXTL_UART from 16 to 1, in order to reduce the latency of the uart. After this modification we have measured a round trip delay of 10 ms. So, the modification of the RXTL_UART have reduced the delay, but has not solved the issue at all.
After that, we have changed the device tree and we have disabled the sdma for the uart2. So, finally, we have measured a round trip delay of 1 ms. This is the same round trip delay that we have measure with older hardware (imx6, with kernel version 3.10.17).
So, why the use of sdma on the uart2 introduce a round trip delay of 10ms?
Is there any way to get low latency with the sdma enabled?
As additional information we have discovered (with sdma) that the latency depend on baud rate:
- at 31250 we have measured a round trip delay of 10 ms
- at 115200 we have measured a round trip delay of 4 ms
So, in some way the sdma adds an rx delay that depends on frequency of the uart.
Thank you.