[PATCH v2] tty: serial: msm: Don't reconfigure same baud rate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



msm_set_termios() is called whenever the tty is opened. Setting the baud
rate requires a full reset of the msm serial block, even when the rate
is unchanged. In the case when the same uart is used as console this
reset will discard any console output data still being clocked out of
the TX fifo.

By skipping the rate-change in the case where the baud rate is unchanged
since last request we can avoid the reset and the discarding of the
data.

Signed-off-by: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx>
---
 drivers/tty/serial/msm_serial.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index b7d80bd57db9..206149f104fa 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -76,6 +76,7 @@ struct msm_port {
 	bool			break_detected;
 	struct msm_dma		tx_dma;
 	struct msm_dma		rx_dma;
+	unsigned int		last_baud;
 };
 
 static void msm_handle_tx(struct uart_port *port);
@@ -1072,11 +1073,16 @@ static void msm_set_termios(struct uart_port *port, struct ktermios *termios,
 	if (dma->chan) /* Terminate if any */
 		msm_stop_dma(port, dma);
 
-	/* calculate and set baud rate */
+	/* calculate and set baud rate, if changed from last request */
 	baud = uart_get_baud_rate(port, termios, old, 300, 4000000);
-	baud = msm_set_baud_rate(port, baud, &flags);
-	if (tty_termios_baud_rate(termios))
-		tty_termios_encode_baud_rate(termios, baud, baud);
+	if (baud != msm_port->last_baud) {
+		msm_port->last_baud = baud;
+
+		baud = msm_set_baud_rate(port, baud, &flags);
+		if (tty_termios_baud_rate(termios))
+			tty_termios_encode_baud_rate(termios, baud, baud);
+		uart_update_timeout(port, termios->c_cflag, baud);
+	}
 
 	/* calculate parity */
 	mr = msm_read(port, UART_MR2);
@@ -1134,8 +1140,6 @@ static void msm_set_termios(struct uart_port *port, struct ktermios *termios,
 	if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
 		port->read_status_mask |= UART_SR_RX_BREAK;
 
-	uart_update_timeout(port, termios->c_cflag, baud);
-
 	/* Try to use DMA */
 	msm_start_rx_dma(msm_port);
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-soc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux