linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: serial: fsl_lpuart: Fix Tx DMA edge case
@ 2016-10-06 22:13 Aaron Brice
  2016-10-07 18:06 ` Stefan Agner
  2016-10-10 11:12 ` Bhuvanchandra DV
  0 siblings, 2 replies; 3+ messages in thread
From: Aaron Brice @ 2016-10-06 22:13 UTC (permalink / raw)
  To: gregkh, jslaby, bhuvanchandra.dv, stefan
  Cc: linux-serial, linux-kernel, linux-arm-kernel

In the case where head == 0 on the circular buffer, there should be one
DMA buffer, not two.  The second zero-length buffer would break the
lpuart driver, transfer would never complete.

Signed-off-by: Aaron Brice <aaron.brice@datasoft.com>
---
 drivers/tty/serial/fsl_lpuart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index de9d510..76103f2 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -328,7 +328,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
 
 	sport->dma_tx_bytes = uart_circ_chars_pending(xmit);
 
-	if (xmit->tail < xmit->head) {
+	if (xmit->tail < xmit->head || xmit->head == 0) {
 		sport->dma_tx_nents = 1;
 		sg_init_one(sgl, xmit->buf + xmit->tail, sport->dma_tx_bytes);
 	} else {
@@ -359,7 +359,6 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
 	sport->dma_tx_in_progress = true;
 	sport->dma_tx_cookie = dmaengine_submit(sport->dma_tx_desc);
 	dma_async_issue_pending(sport->dma_tx_chan);
-
 }
 
 static void lpuart_dma_tx_complete(void *arg)
-- 
2.7.4

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

* Re: [PATCH] tty: serial: fsl_lpuart: Fix Tx DMA edge case
  2016-10-06 22:13 [PATCH] tty: serial: fsl_lpuart: Fix Tx DMA edge case Aaron Brice
@ 2016-10-07 18:06 ` Stefan Agner
  2016-10-10 11:12 ` Bhuvanchandra DV
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Agner @ 2016-10-07 18:06 UTC (permalink / raw)
  To: Aaron Brice, gregkh
  Cc: jslaby, bhuvanchandra.dv, linux-serial, linux-kernel, linux-arm-kernel

On 2016-10-06 15:13, Aaron Brice wrote:
> In the case where head == 0 on the circular buffer, there should be one
> DMA buffer, not two.  The second zero-length buffer would break the
> lpuart driver, transfer would never complete.

That looks right, and seems to work fine here:

Acked-by: Stefan Agner <stefan@agner.ch>
Tested-by: Stefan Agner <stefan@agner.ch>

@Greg, would be good if this would still make it into 4.9.

--
Stefan

> 
> Signed-off-by: Aaron Brice <aaron.brice@datasoft.com>
> ---
>  drivers/tty/serial/fsl_lpuart.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index de9d510..76103f2 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -328,7 +328,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
>  
>  	sport->dma_tx_bytes = uart_circ_chars_pending(xmit);
>  
> -	if (xmit->tail < xmit->head) {
> +	if (xmit->tail < xmit->head || xmit->head == 0) {
>  		sport->dma_tx_nents = 1;
>  		sg_init_one(sgl, xmit->buf + xmit->tail, sport->dma_tx_bytes);
>  	} else {
> @@ -359,7 +359,6 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
>  	sport->dma_tx_in_progress = true;
>  	sport->dma_tx_cookie = dmaengine_submit(sport->dma_tx_desc);
>  	dma_async_issue_pending(sport->dma_tx_chan);
> -
>  }
>  
>  static void lpuart_dma_tx_complete(void *arg)

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

* Re: [PATCH] tty: serial: fsl_lpuart: Fix Tx DMA edge case
  2016-10-06 22:13 [PATCH] tty: serial: fsl_lpuart: Fix Tx DMA edge case Aaron Brice
  2016-10-07 18:06 ` Stefan Agner
@ 2016-10-10 11:12 ` Bhuvanchandra DV
  1 sibling, 0 replies; 3+ messages in thread
From: Bhuvanchandra DV @ 2016-10-10 11:12 UTC (permalink / raw)
  To: Aaron Brice, gregkh, jslaby, stefan
  Cc: linux-serial, linux-kernel, linux-arm-kernel

On 10/07/16 03:43, Aaron Brice wrote:

> In the case where head == 0 on the circular buffer, there should be one
> DMA buffer, not two.  The second zero-length buffer would break the
> lpuart driver, transfer would never complete.

Tested-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>

>
> Signed-off-by: Aaron Brice <aaron.brice@datasoft.com>
> ---
>   drivers/tty/serial/fsl_lpuart.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index de9d510..76103f2 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -328,7 +328,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
>   
>   	sport->dma_tx_bytes = uart_circ_chars_pending(xmit);
>   
> -	if (xmit->tail < xmit->head) {
> +	if (xmit->tail < xmit->head || xmit->head == 0) {
>   		sport->dma_tx_nents = 1;
>   		sg_init_one(sgl, xmit->buf + xmit->tail, sport->dma_tx_bytes);
>   	} else {
> @@ -359,7 +359,6 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
>   	sport->dma_tx_in_progress = true;
>   	sport->dma_tx_cookie = dmaengine_submit(sport->dma_tx_desc);
>   	dma_async_issue_pending(sport->dma_tx_chan);
> -
>   }
>   
>   static void lpuart_dma_tx_complete(void *arg)

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

end of thread, other threads:[~2016-10-10 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-06 22:13 [PATCH] tty: serial: fsl_lpuart: Fix Tx DMA edge case Aaron Brice
2016-10-07 18:06 ` Stefan Agner
2016-10-10 11:12 ` Bhuvanchandra DV

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