linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: serial: msm: Don't read off end of tx fifo
@ 2016-06-03  0:48 Bjorn Andersson
  2016-06-03  3:59 ` Frank Rowand
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Bjorn Andersson @ 2016-06-03  0:48 UTC (permalink / raw)
  To: Andy Gross, David Brown, Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-arm-msm, linux-soc, linux-serial, linux-kernel,
	Frank Rowand, Nicolas Dechesne, Ivan Ivanov, Stephen Boyd,
	stable

For dm uarts in pio mode tx data is transferred to the fifo register 4
bytes at a time, but care is not taken when these 4 bytes spans the end
of the xmit buffer so the loop might read up to 3 bytes past the buffer
and then skip the actual data at the beginning of the buffer.

Fix this by, analogous to the DMA case, make sure the chunk doesn't
wrap the xmit buffer.

Fixes: 3a878c430fd6 ("tty: serial: msm: Add TX DMA support")
Cc: Andy Gross <andy.gross@linaro.org>
Cc: Ivan Ivanov <iivanov.xz@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: stable@vger.kernel.org
Reported-by: Frank Rowand <frowand.list@gmail.com>
Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/tty/serial/msm_serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index b7d80bd57db9..7d62610d9de5 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -726,7 +726,7 @@ static void msm_handle_tx(struct uart_port *port)
 		return;
 	}
 
-	pio_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE);
+	pio_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
 	dma_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
 
 	dma_min = 1;	/* Always DMA */
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tty: serial: msm: Don't read off end of tx fifo
  2016-06-03  0:48 [PATCH] tty: serial: msm: Don't read off end of tx fifo Bjorn Andersson
@ 2016-06-03  3:59 ` Frank Rowand
  2016-06-04  0:03 ` Stephen Boyd
  2016-06-05 18:44 ` Andy Gross
  2 siblings, 0 replies; 4+ messages in thread
From: Frank Rowand @ 2016-06-03  3:59 UTC (permalink / raw)
  To: Bjorn Andersson, Andy Gross, David Brown, Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-arm-msm, linux-soc, linux-serial, linux-kernel,
	Nicolas Dechesne, Ivan Ivanov, Stephen Boyd, stable

On 06/02/16 17:48, Bjorn Andersson wrote:
> For dm uarts in pio mode tx data is transferred to the fifo register 4
> bytes at a time, but care is not taken when these 4 bytes spans the end
> of the xmit buffer so the loop might read up to 3 bytes past the buffer
> and then skip the actual data at the beginning of the buffer.
> 
> Fix this by, analogous to the DMA case, make sure the chunk doesn't
> wrap the xmit buffer.
> 
> Fixes: 3a878c430fd6 ("tty: serial: msm: Add TX DMA support")
> Cc: Andy Gross <andy.gross@linaro.org>
> Cc: Ivan Ivanov <iivanov.xz@gmail.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: stable@vger.kernel.org
> Reported-by: Frank Rowand <frowand.list@gmail.com>
> Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  drivers/tty/serial/msm_serial.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
> index b7d80bd57db9..7d62610d9de5 100644
> --- a/drivers/tty/serial/msm_serial.c
> +++ b/drivers/tty/serial/msm_serial.c
> @@ -726,7 +726,7 @@ static void msm_handle_tx(struct uart_port *port)
>  		return;
>  	}
>  
> -	pio_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE);
> +	pio_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
>  	dma_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
>  
>  	dma_min = 1;	/* Always DMA */
> 

Thanks Bjorn.  This eliminates my symptoms on 4.6 and 4.7-rc1.

Tested-by: Frank Rowand <frank.rowand@am.sony.com>

-Frank

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tty: serial: msm: Don't read off end of tx fifo
  2016-06-03  0:48 [PATCH] tty: serial: msm: Don't read off end of tx fifo Bjorn Andersson
  2016-06-03  3:59 ` Frank Rowand
@ 2016-06-04  0:03 ` Stephen Boyd
  2016-06-05 18:44 ` Andy Gross
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2016-06-04  0:03 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, David Brown, Greg Kroah-Hartman, Jiri Slaby,
	linux-arm-msm, linux-soc, linux-serial, linux-kernel,
	Frank Rowand, Nicolas Dechesne, Ivan Ivanov, stable

On 06/02, Bjorn Andersson wrote:
> For dm uarts in pio mode tx data is transferred to the fifo register 4
> bytes at a time, but care is not taken when these 4 bytes spans the end
> of the xmit buffer so the loop might read up to 3 bytes past the buffer
> and then skip the actual data at the beginning of the buffer.
> 
> Fix this by, analogous to the DMA case, make sure the chunk doesn't
> wrap the xmit buffer.
> 
> Fixes: 3a878c430fd6 ("tty: serial: msm: Add TX DMA support")
> Cc: Andy Gross <andy.gross@linaro.org>
> Cc: Ivan Ivanov <iivanov.xz@gmail.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: stable@vger.kernel.org
> Reported-by: Frank Rowand <frowand.list@gmail.com>
> Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---

Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tty: serial: msm: Don't read off end of tx fifo
  2016-06-03  0:48 [PATCH] tty: serial: msm: Don't read off end of tx fifo Bjorn Andersson
  2016-06-03  3:59 ` Frank Rowand
  2016-06-04  0:03 ` Stephen Boyd
@ 2016-06-05 18:44 ` Andy Gross
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Gross @ 2016-06-05 18:44 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: David Brown, Greg Kroah-Hartman, Jiri Slaby, linux-arm-msm,
	linux-soc, linux-serial, linux-kernel, Frank Rowand,
	Nicolas Dechesne, Ivan Ivanov, Stephen Boyd, stable

On Thu, Jun 02, 2016 at 05:48:28PM -0700, Bjorn Andersson wrote:
> For dm uarts in pio mode tx data is transferred to the fifo register 4
> bytes at a time, but care is not taken when these 4 bytes spans the end
> of the xmit buffer so the loop might read up to 3 bytes past the buffer
> and then skip the actual data at the beginning of the buffer.
> 
> Fix this by, analogous to the DMA case, make sure the chunk doesn't
> wrap the xmit buffer.
> 
> Fixes: 3a878c430fd6 ("tty: serial: msm: Add TX DMA support")
> Cc: Andy Gross <andy.gross@linaro.org>
> Cc: Ivan Ivanov <iivanov.xz@gmail.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: stable@vger.kernel.org
> Reported-by: Frank Rowand <frowand.list@gmail.com>
> Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Acked-by: Andy Gross <andy.gross@linaro.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-05 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-03  0:48 [PATCH] tty: serial: msm: Don't read off end of tx fifo Bjorn Andersson
2016-06-03  3:59 ` Frank Rowand
2016-06-04  0:03 ` Stephen Boyd
2016-06-05 18:44 ` Andy Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).