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

Commit 6b796ba3 authored by Mukesh Kumar Savaliya's avatar Mukesh Kumar Savaliya
Browse files

msm_serial_hs_lite : Prevent pushing extra bytes to the top layer



 In scenarios where hslite UART communicating with peer UART device it
 may happen that we many not receive all the sent bytes at one go. This
 can happen when the peer is not able to send complete payload at once
 due to smaller FIFO size or rescheduled by high priority threads. Unless
 its Last chunk, driver assumes it will receive and push 4 bytes to the
 tty Layer which is not correct always. There is an issue that we are not
 verifying the bytes pushed to the tty layer and always assumes its either
 in multiple of 4 or its a last chunk having less than 4 bytes.

 For example, 1 Byte FIFO size on peer device tries to send total 10 bytes
 of data but after 7 bytes it may get delayed sending remaining 3 bytes
 due to ISR or high priority threads. In this case hslite driver will
 receive 7 Bytes + 1 wrongly padded byte + 3 bytes remaining. Hence,
 totally user space receives 11 bytes instead 10 Bytes.

 This change makes sure that it reads the data and push the same number of
 bytes to the top layer without any extra padding.

Change-Id: I12754a2c95ee7e3d85dd020093d99b01a2a2831a
Signed-off-by: default avatarMukesh Kumar Savaliya <msavaliy@codeaurora.org>
parent c1b67407
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -2,7 +2,7 @@
 * drivers/serial/msm_serial.c - driver for msm7k serial device and console
 * drivers/serial/msm_serial.c - driver for msm7k serial device and console
 *
 *
 * Copyright (C) 2007 Google, Inc.
 * Copyright (C) 2007 Google, Inc.
 * Copyright (c) 2010-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2010-2016, The Linux Foundation. All rights reserved.
 *
 *
 * This software is licensed under the terms of the GNU General Public
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * License version 2, as published by the Free Software Foundation, and
@@ -554,6 +554,7 @@ static void handle_rx(struct uart_port *port, unsigned int misr)
	unsigned int vid;
	unsigned int vid;
	unsigned int sr;
	unsigned int sr;
	int count = 0;
	int count = 0;
	int copied = 0;
	struct msm_hsl_port *msm_hsl_port = UART_TO_MSM(port);
	struct msm_hsl_port *msm_hsl_port = UART_TO_MSM(port);


	vid = msm_hsl_port->ver_id;
	vid = msm_hsl_port->ver_id;
@@ -609,9 +610,9 @@ static void handle_rx(struct uart_port *port, unsigned int misr)


		/* TODO: handle sysrq */
		/* TODO: handle sysrq */
		/* if (!uart_handle_sysrq_char(port, c)) */
		/* if (!uart_handle_sysrq_char(port, c)) */
		tty_insert_flip_string(tty->port, (char *) &c,
		copied = tty_insert_flip_string(tty->port, (char *) &c,
				       (count > 4) ? 4 : count);
				       (count > 4) ? 4 : count);
		count -= 4;
		count -= copied;
	}
	}


	tty_flip_buffer_push(tty->port);
	tty_flip_buffer_push(tty->port);