diff mbox

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

Message ID 1466101475-8851-1-git-send-email-bjorn.andersson@linaro.org (mailing list archive)
State Changes Requested
Delegated to: Andy Gross
Headers show

Commit Message

Bjorn Andersson June 16, 2016, 6:24 p.m. UTC
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 | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Nicolas Dechesne June 17, 2016, 10:02 a.m. UTC | #1
On Thu, Jun 16, 2016 at 9:24 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> 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>


Tested-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>

I no longer see this type of corruption on serial console

[    6.325118] ALSA device �[    6.333338] Freeing unused kernel
memory: 572K (ffffffc000c10000 - ffffffc000c9f000)
[   13.800269]  remoteproc2: remote processor a20400�[  OK  ] Started
Start the WCN core.
[ �         Starting Update UTMP about System Runlevel Changes...
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Boyd June 20, 2016, 11:54 p.m. UTC | #2
On 06/16, Bjorn Andersson wrote:
> 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>
> ---

Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Nicolas Dechesne June 21, 2016, 9:43 a.m. UTC | #3
On Fri, Jun 17, 2016 at 1:02 PM, Nicolas Dechesne
<nicolas.dechesne@linaro.org> wrote:
> <bjorn.andersson@linaro.org> wrote:
>> 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>
>
>
> Tested-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
>
> I no longer see this type of corruption on serial console
>
> [    6.325118] ALSA device �[    6.333338] Freeing unused kernel
> memory: 572K (ffffffc000c10000 - ffffffc000c9f000)
> [   13.800269]  remoteproc2: remote processor a20400�[  OK  ] Started
> Start the WCN core.
> [ �         Starting Update UTMP about System Runlevel Changes...


oops. today i tried on APQ8064 boards , both IFC6410Plus and SD
600eval, and I can no longer 'type' into the serial console, I can get
debug messages though. Reverting this change 'fixes' the problem.
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Srinivas Kandagatla June 22, 2016, 9:59 a.m. UTC | #4
On 21/06/16 10:43, Nicolas Dechesne wrote:
> On Fri, Jun 17, 2016 at 1:02 PM, Nicolas Dechesne
> <nicolas.dechesne@linaro.org> wrote:
>> <bjorn.andersson@linaro.org> wrote:
>>> 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>
>>
>>
>> Tested-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
>>
>> I no longer see this type of corruption on serial console
>>
>> [    6.325118] ALSA device �[    6.333338] Freeing unused kernel
>> memory: 572K (ffffffc000c10000 - ffffffc000c9f000)
>> [   13.800269]  remoteproc2: remote processor a20400�[  OK  ] Started
>> Start the WCN core.
>> [ �         Starting Update UTMP about System Runlevel Changes...
>
>
> oops. today i tried on APQ8064 boards , both IFC6410Plus and SD
> 600eval, and I can no longer 'type' into the serial console, I can get
> debug messages though. Reverting this change 'fixes' the problem.

Am also hitting the same issue as Nico on IFC6410 with this patch.


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

Patch

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);