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

RX data lost on rk3399 onboard 8250 uart dma mode when transfer large frame and high baud rate. #212

Open
chenlujia888 opened this issue Apr 27, 2020 · 0 comments

Comments

@chenlujia888
Copy link

Hi, I'm using RK3399 onboard serial port to transfer (receive) large data on high baudrate, but the data is lost periodically.
the rx data flow baudrate is 8M bps (8000000 bps), and the frame size is 50K bytes. So I firstly enable dma in the rk3399.dtsi file:

uart4: serial@ff370000 { 
    dmas = <&dmac_peri 8>, <&dmac_peri 9>;
    dma-names = "tx", "rx";
}

when I start to receive the data, only the last 7k+ bytes of every frame can be received, the first 40k data of every frame is lost.

I looked into the kernel source code, and find out the cause to this problem.
source file: drivers/tty/serial/8250/8250_dma.c

int serial8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
{
	unsigned int rfl, i = 0, fcr = 0, cur_index = 0;
	unsigned char buf[MAX_FIFO_SIZE];
	struct uart_port	*port = &p->port;
	struct tty_port		*tty_port = &p->port.state->port;
	struct dma_tx_state	state;
	struct uart_8250_dma	*dma = p->dma;


	if ((iir & 0xf) != UART_IIR_RX_TIMEOUT)
		return 0;

the driver only transfer data to user space only when RX_TIMEOUT flag is set. It means the last data in the dma buffer before the end of serial frame is transferred, any previous data is overwritten.
The history git commit message proved this:

serial: 8250: support new dma transfer

The old mode uses soft timer to update received data,
which costs much cpu resource, even though there is no
data. The new mode is based on uart time out, it updates
data only when transfer completes.

Change-Id: Id12e351ff00015e4bfb36f416731ce4af5330001
Signed-off-by: Huibin Hong <[email protected]>

Hopefully this bug can be fixed officially. Thanks.

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

No branches or pull requests

1 participant