Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85f8d252 authored by Maria Yu's avatar Maria Yu Committed by Teng Fei Fan
Browse files

tty: serial: msm: Add timeout for waiting TX ready



At worst case, msm serial driver is stuck in waiting
TX ready, so have a 500ms timeout to avoid stuck
and only lost some log to uart.

Change-Id: I2984ed8ad094a040c8ae49ee6ffba5f0238ca336
Signed-off-by: default avatarMaria Yu <aiquny@codeaurora.org>
Signed-off-by: default avatarTeng Fei Fan <tengfei@codeaurora.org>
parent c1940edc
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -395,10 +395,22 @@ static void msm_request_rx_dma(struct msm_port *msm_port, resource_size_t base)

static inline void msm_wait_for_xmitr(struct uart_port *port)
{
	u32 count = 500000;

	while (!(msm_read(port, UART_SR) & UART_SR_TX_EMPTY)) {
		if (msm_read(port, UART_ISR) & UART_ISR_TX_READY)
			break;
		udelay(1);

		/* At worst case, it is stuck in this loop for waiting
		 * TX ready, have a 500ms timeout to avoid stuck here
		 * and only miss some log to uart.
		 */
		if (count-- == 0) {
			msm_write(port, UART_CR_CMD_RESET_TX, UART_CR);
			printk_deferred("uart may lost data, resetting TX!\n");
			break;
		}
	}
	msm_write(port, UART_CR_CMD_RESET_TX_READY, UART_CR);
}