mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] serial/lpuart: Do not enable UART FIFO
@ 2018-04-12 21:41 Andrey Smirnov
  2018-04-16  7:03 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Smirnov @ 2018-04-12 21:41 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Using FIFO in LPUART results in subtle serial input draining issues
which are quite difficult to reproduce and troubleshoot. Since the
change offered only moderate performance gain revert the code to
operate in no-FIFO mode to avoid FIFO-related problems alltogether.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/serial/serial_lpuart.c |  4 +---
 include/serial/lpuart.h        | 21 +++++----------------
 2 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index 52fb6d39c..8f87f7b9c 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -170,9 +170,7 @@ static int lpuart_serial_probe(struct device_d *dev)
 
 	cdev->linux_console_name = "ttyLP";
 
-	lpuart_setup_with_fifo(lpuart->base,
-			       clk_get_rate(lpuart->clk),
-			       15);
+	lpuart_setup(lpuart->base, clk_get_rate(lpuart->clk));
 
 	ret = console_register(cdev);
 	if (!ret) {
diff --git a/include/serial/lpuart.h b/include/serial/lpuart.h
index 917f644a5..a920291de 100644
--- a/include/serial/lpuart.h
+++ b/include/serial/lpuart.h
@@ -238,22 +238,17 @@ static inline void lpuart_setbrg(void __iomem *base,
 	writeb(bfra, base + UARTCR4);
 }
 
-static inline void lpuart_setup_with_fifo(void __iomem *base,
-					  unsigned int refclock,
-					  unsigned int twfifo)
+static inline void lpuart_setup(void __iomem *base,
+				unsigned int refclock)
 {
 	/* Disable UART */
 	writeb(0, base + UARTCR2);
 	writeb(0, base + UARTMODEM);
 	writeb(0, base + UARTCR1);
 
-	if (twfifo) {
-		writeb(UARTPFIFO_TXFE | UARTPFIFO_RXFE, base + UARTPFIFO);
-		writeb((u8)twfifo, base + UARTTWFIFO);
-	} else {
-		writeb(0, base + UARTPFIFO);
-		writeb(0, base + UARTTWFIFO);
-	}
+	writeb(0, base + UARTPFIFO);
+	writeb(0, base + UARTTWFIFO);
+
 	writeb(1, base + UARTRWFIFO);
 	writeb(UARTCFIFO_RXFLUSH | UARTCFIFO_TXFLUSH, base + UARTCFIFO);
 
@@ -262,12 +257,6 @@ static inline void lpuart_setup_with_fifo(void __iomem *base,
 	writeb(UARTCR2_TE | UARTCR2_RE, base + UARTCR2);
 }
 
-static inline void lpuart_setup(void __iomem *base,
-				unsigned int refclock)
-{
-	lpuart_setup_with_fifo(base, refclock, 0x00);
-}
-
 static inline void lpuart_putc(void __iomem *base, int c)
 {
 	if (!(readb(base + UARTCR2) & UARTCR2_TE))
-- 
2.14.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] serial/lpuart: Do not enable UART FIFO
  2018-04-12 21:41 [PATCH] serial/lpuart: Do not enable UART FIFO Andrey Smirnov
@ 2018-04-16  7:03 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-04-16  7:03 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Thu, Apr 12, 2018 at 02:41:43PM -0700, Andrey Smirnov wrote:
> Using FIFO in LPUART results in subtle serial input draining issues
> which are quite difficult to reproduce and troubleshoot. Since the
> change offered only moderate performance gain revert the code to
> operate in no-FIFO mode to avoid FIFO-related problems alltogether.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>

Applied, thanks

Sascha

> ---
>  drivers/serial/serial_lpuart.c |  4 +---
>  include/serial/lpuart.h        | 21 +++++----------------
>  2 files changed, 6 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
> index 52fb6d39c..8f87f7b9c 100644
> --- a/drivers/serial/serial_lpuart.c
> +++ b/drivers/serial/serial_lpuart.c
> @@ -170,9 +170,7 @@ static int lpuart_serial_probe(struct device_d *dev)
>  
>  	cdev->linux_console_name = "ttyLP";
>  
> -	lpuart_setup_with_fifo(lpuart->base,
> -			       clk_get_rate(lpuart->clk),
> -			       15);
> +	lpuart_setup(lpuart->base, clk_get_rate(lpuart->clk));
>  
>  	ret = console_register(cdev);
>  	if (!ret) {
> diff --git a/include/serial/lpuart.h b/include/serial/lpuart.h
> index 917f644a5..a920291de 100644
> --- a/include/serial/lpuart.h
> +++ b/include/serial/lpuart.h
> @@ -238,22 +238,17 @@ static inline void lpuart_setbrg(void __iomem *base,
>  	writeb(bfra, base + UARTCR4);
>  }
>  
> -static inline void lpuart_setup_with_fifo(void __iomem *base,
> -					  unsigned int refclock,
> -					  unsigned int twfifo)
> +static inline void lpuart_setup(void __iomem *base,
> +				unsigned int refclock)
>  {
>  	/* Disable UART */
>  	writeb(0, base + UARTCR2);
>  	writeb(0, base + UARTMODEM);
>  	writeb(0, base + UARTCR1);
>  
> -	if (twfifo) {
> -		writeb(UARTPFIFO_TXFE | UARTPFIFO_RXFE, base + UARTPFIFO);
> -		writeb((u8)twfifo, base + UARTTWFIFO);
> -	} else {
> -		writeb(0, base + UARTPFIFO);
> -		writeb(0, base + UARTTWFIFO);
> -	}
> +	writeb(0, base + UARTPFIFO);
> +	writeb(0, base + UARTTWFIFO);
> +
>  	writeb(1, base + UARTRWFIFO);
>  	writeb(UARTCFIFO_RXFLUSH | UARTCFIFO_TXFLUSH, base + UARTCFIFO);
>  
> @@ -262,12 +257,6 @@ static inline void lpuart_setup_with_fifo(void __iomem *base,
>  	writeb(UARTCR2_TE | UARTCR2_RE, base + UARTCR2);
>  }
>  
> -static inline void lpuart_setup(void __iomem *base,
> -				unsigned int refclock)
> -{
> -	lpuart_setup_with_fifo(base, refclock, 0x00);
> -}
> -
>  static inline void lpuart_putc(void __iomem *base, int c)
>  {
>  	if (!(readb(base + UARTCR2) & UARTCR2_TE))
> -- 
> 2.14.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-04-16  7:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-12 21:41 [PATCH] serial/lpuart: Do not enable UART FIFO Andrey Smirnov
2018-04-16  7:03 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox