diff --git a/drivers/tty/serial/msm_geni_serial.c b/drivers/tty/serial/msm_geni_serial.c index e9488f2d0822..d449d54e03cd 100644 --- a/drivers/tty/serial/msm_geni_serial.c +++ b/drivers/tty/serial/msm_geni_serial.c @@ -1686,6 +1686,40 @@ exit_handle_tx: 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); @@ -1714,6 +1748,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;