]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tty: serial: msm: Don't reconfigure same baud rate
authorBjorn Andersson <bjorn.andersson@linaro.org>
Thu, 16 Jun 2016 18:24:35 +0000 (11:24 -0700)
committerNicolas Dechesne <nicolas.dechesne@linaro.org>
Thu, 16 Jun 2016 20:24:09 +0000 (23:24 +0300)
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@linaro.org>
drivers/tty/serial/msm_serial.c

index e1de4944e0ce5f8eae8ada1020086294c9a13fea..eeb9a9d806838f832d5dc6e23abacc9f398268ab 100644 (file)
@@ -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);
@@ -1039,11 +1040,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);
@@ -1101,8 +1107,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);