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

Commit 660cc575 authored by Chandana Kishori Chiluveru's avatar Chandana Kishori Chiluveru Committed by Gerrit - the friendly Code Review server
Browse files

serial: msm_geni_serial: Add delay for rx invalid transfer



Check for RX data in rx buffer for faulty transfer and add
delay of 2 msecs delay in order for dma rx transfer
to be actually completed.

Also dump required qup registers when the uart dma rx data is
seen as all zeros.

Change-Id: Ifaa0cb7d22b8419ffacfee7212b0a28ed8ebf2a1
Signed-off-by: default avatarChandana Kishori Chiluveru <cchiluve@codeaurora.org>
parent 7265cb7f
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -1712,6 +1712,40 @@ static int msm_geni_serial_handle_tx(struct uart_port *uport, bool done,
	return 0;
}

static void check_rx_buf(char *buf, struct uart_port *uport, int size)
{
	struct msm_geni_serial_port *msm_port = GET_DEV_PORT(uport);
	unsigned int rx_data;
	bool fault = false;

	rx_data = *(u32 *)buf;
	/* check for first 4 bytes of RX data for faulty zero pattern */
	if (rx_data == 0x0) {
		if (size <= 4) {
			fault = true;
		} else {
			/*
			 * check for last 4 bytes of data in RX buffer for
			 * faulty pattern
			 */
			if (memcmp(buf+(size-4), "\x0\x0\x0\x0", 4) == 0)
				fault = true;
		}

		if (fault) {
			IPC_LOG_MSG(msm_port->ipc_log_rx,
				"RX Invalid packet %s\n", __func__);
			geni_se_dump_dbg_regs(&msm_port->serial_rsc,
				uport->membase, msm_port->ipc_log_misc);
			/*
			 * Add 2 msecs delay in order for dma rx transfer
			 * to be actually completed.
			 */
			udelay(2000);
		}
	}
}

static int msm_geni_serial_handle_dma_rx(struct uart_port *uport, bool drop_rx)
{
	struct msm_geni_serial_port *msm_port = GET_DEV_PORT(uport);
@@ -1740,6 +1774,10 @@ static int msm_geni_serial_handle_dma_rx(struct uart_port *uport, bool drop_rx)
					__func__, rx_bytes);
		goto exit_handle_dma_rx;
	}

	/* Check RX buffer data for faulty pattern*/
	check_rx_buf((char *)msm_port->rx_buf, uport, rx_bytes);

	if (drop_rx)
		goto exit_handle_dma_rx;