All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty/serial: atmel: fix hardware handshake selection
@ 2016-04-12 12:51 ` Alexandre Belloni
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2016-04-12 12:51 UTC (permalink / raw)
  To: Nicolas Ferre, Greg Kroah-Hartman
  Cc: linux-kernel, linux-arm-kernel, Jiri Slaby, linux-serial,
	Cyrille Pitchen, Alexandre Belloni

Commit 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
hardware handshake is enabled") actually allowed to enable hardware
handshaking.
Before, the CRTSCTS flags was silently ignored.

As the DMA controller can't drive RTS (as explain in the commit message).
Ensure that hardware flow control stays disabled when DMA is used and FIFOs
are not available.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/tty/serial/atmel_serial.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index d9439e6ab719..954941dd8124 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -274,6 +274,13 @@ static bool atmel_use_dma_rx(struct uart_port *port)
 	return atmel_port->use_dma_rx;
 }
 
+static bool atmel_use_fifo(struct uart_port *port)
+{
+	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
+
+	return atmel_port->fifo_size;
+}
+
 static unsigned int atmel_get_lines_status(struct uart_port *port)
 {
 	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
@@ -2090,7 +2097,12 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 		mode |= ATMEL_US_USMODE_RS485;
 	} else if (termios->c_cflag & CRTSCTS) {
 		/* RS232 with hardware handshake (RTS/CTS) */
-		mode |= ATMEL_US_USMODE_HWHS;
+		if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
+			dev_info(port->dev, "not enabling hardware flow control because DMA is used");
+			termios->c_cflag &= ~CRTSCTS;
+		} else {
+			mode |= ATMEL_US_USMODE_HWHS;
+		}
 	} else {
 		/* RS232 without hadware handshake */
 		mode |= ATMEL_US_USMODE_NORMAL;
-- 
2.8.0.rc3

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

* [PATCH] tty/serial: atmel: fix hardware handshake selection
@ 2016-04-12 12:51 ` Alexandre Belloni
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2016-04-12 12:51 UTC (permalink / raw)
  To: linux-arm-kernel

Commit 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
hardware handshake is enabled") actually allowed to enable hardware
handshaking.
Before, the CRTSCTS flags was silently ignored.

As the DMA controller can't drive RTS (as explain in the commit message).
Ensure that hardware flow control stays disabled when DMA is used and FIFOs
are not available.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/tty/serial/atmel_serial.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index d9439e6ab719..954941dd8124 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -274,6 +274,13 @@ static bool atmel_use_dma_rx(struct uart_port *port)
 	return atmel_port->use_dma_rx;
 }
 
+static bool atmel_use_fifo(struct uart_port *port)
+{
+	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
+
+	return atmel_port->fifo_size;
+}
+
 static unsigned int atmel_get_lines_status(struct uart_port *port)
 {
 	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
@@ -2090,7 +2097,12 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
 		mode |= ATMEL_US_USMODE_RS485;
 	} else if (termios->c_cflag & CRTSCTS) {
 		/* RS232 with hardware handshake (RTS/CTS) */
-		mode |= ATMEL_US_USMODE_HWHS;
+		if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
+			dev_info(port->dev, "not enabling hardware flow control because DMA is used");
+			termios->c_cflag &= ~CRTSCTS;
+		} else {
+			mode |= ATMEL_US_USMODE_HWHS;
+		}
 	} else {
 		/* RS232 without hadware handshake */
 		mode |= ATMEL_US_USMODE_NORMAL;
-- 
2.8.0.rc3

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

* Re: [PATCH] tty/serial: atmel: fix hardware handshake selection
  2016-04-12 12:51 ` Alexandre Belloni
  (?)
@ 2016-04-15 12:52   ` Nicolas Ferre
  -1 siblings, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2016-04-15 12:52 UTC (permalink / raw)
  To: Alexandre Belloni, Greg Kroah-Hartman
  Cc: linux-kernel, linux-arm-kernel, Jiri Slaby, linux-serial,
	Cyrille Pitchen

Le 12/04/2016 14:51, Alexandre Belloni a écrit :
> Commit 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
> hardware handshake is enabled") actually allowed to enable hardware
> handshaking.
> Before, the CRTSCTS flags was silently ignored.
> 
> As the DMA controller can't drive RTS (as explain in the commit message).
> Ensure that hardware flow control stays disabled when DMA is used and FIFOs
> are not available.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Yes, I agree with the fix:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

We can also add the following tags:

Fixes: 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
hardware handshake is enabled")
Cc: stable <stable@vger.kernel.org> # v4.0+

Bye,

> ---
>  drivers/tty/serial/atmel_serial.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index d9439e6ab719..954941dd8124 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -274,6 +274,13 @@ static bool atmel_use_dma_rx(struct uart_port *port)
>  	return atmel_port->use_dma_rx;
>  }
>  
> +static bool atmel_use_fifo(struct uart_port *port)
> +{
> +	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
> +
> +	return atmel_port->fifo_size;
> +}
> +
>  static unsigned int atmel_get_lines_status(struct uart_port *port)
>  {
>  	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
> @@ -2090,7 +2097,12 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
>  		mode |= ATMEL_US_USMODE_RS485;
>  	} else if (termios->c_cflag & CRTSCTS) {
>  		/* RS232 with hardware handshake (RTS/CTS) */
> -		mode |= ATMEL_US_USMODE_HWHS;
> +		if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
> +			dev_info(port->dev, "not enabling hardware flow control because DMA is used");
> +			termios->c_cflag &= ~CRTSCTS;
> +		} else {
> +			mode |= ATMEL_US_USMODE_HWHS;
> +		}
>  	} else {
>  		/* RS232 without hadware handshake */
>  		mode |= ATMEL_US_USMODE_NORMAL;
> 


-- 
Nicolas Ferre

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

* Re: [PATCH] tty/serial: atmel: fix hardware handshake selection
@ 2016-04-15 12:52   ` Nicolas Ferre
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2016-04-15 12:52 UTC (permalink / raw)
  To: Alexandre Belloni, Greg Kroah-Hartman
  Cc: linux-kernel, linux-arm-kernel, Jiri Slaby, linux-serial,
	Cyrille Pitchen

Le 12/04/2016 14:51, Alexandre Belloni a écrit :
> Commit 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
> hardware handshake is enabled") actually allowed to enable hardware
> handshaking.
> Before, the CRTSCTS flags was silently ignored.
> 
> As the DMA controller can't drive RTS (as explain in the commit message).
> Ensure that hardware flow control stays disabled when DMA is used and FIFOs
> are not available.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Yes, I agree with the fix:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

We can also add the following tags:

Fixes: 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
hardware handshake is enabled")
Cc: stable <stable@vger.kernel.org> # v4.0+

Bye,

> ---
>  drivers/tty/serial/atmel_serial.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index d9439e6ab719..954941dd8124 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -274,6 +274,13 @@ static bool atmel_use_dma_rx(struct uart_port *port)
>  	return atmel_port->use_dma_rx;
>  }
>  
> +static bool atmel_use_fifo(struct uart_port *port)
> +{
> +	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
> +
> +	return atmel_port->fifo_size;
> +}
> +
>  static unsigned int atmel_get_lines_status(struct uart_port *port)
>  {
>  	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
> @@ -2090,7 +2097,12 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
>  		mode |= ATMEL_US_USMODE_RS485;
>  	} else if (termios->c_cflag & CRTSCTS) {
>  		/* RS232 with hardware handshake (RTS/CTS) */
> -		mode |= ATMEL_US_USMODE_HWHS;
> +		if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
> +			dev_info(port->dev, "not enabling hardware flow control because DMA is used");
> +			termios->c_cflag &= ~CRTSCTS;
> +		} else {
> +			mode |= ATMEL_US_USMODE_HWHS;
> +		}
>  	} else {
>  		/* RS232 without hadware handshake */
>  		mode |= ATMEL_US_USMODE_NORMAL;
> 


-- 
Nicolas Ferre

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

* [PATCH] tty/serial: atmel: fix hardware handshake selection
@ 2016-04-15 12:52   ` Nicolas Ferre
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Ferre @ 2016-04-15 12:52 UTC (permalink / raw)
  To: linux-arm-kernel

Le 12/04/2016 14:51, Alexandre Belloni a ?crit :
> Commit 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
> hardware handshake is enabled") actually allowed to enable hardware
> handshaking.
> Before, the CRTSCTS flags was silently ignored.
> 
> As the DMA controller can't drive RTS (as explain in the commit message).
> Ensure that hardware flow control stays disabled when DMA is used and FIFOs
> are not available.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Yes, I agree with the fix:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

We can also add the following tags:

Fixes: 1cf6e8fc8341 ("tty/serial: at91: fix RTS line management when
hardware handshake is enabled")
Cc: stable <stable@vger.kernel.org> # v4.0+

Bye,

> ---
>  drivers/tty/serial/atmel_serial.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index d9439e6ab719..954941dd8124 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -274,6 +274,13 @@ static bool atmel_use_dma_rx(struct uart_port *port)
>  	return atmel_port->use_dma_rx;
>  }
>  
> +static bool atmel_use_fifo(struct uart_port *port)
> +{
> +	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
> +
> +	return atmel_port->fifo_size;
> +}
> +
>  static unsigned int atmel_get_lines_status(struct uart_port *port)
>  {
>  	struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
> @@ -2090,7 +2097,12 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
>  		mode |= ATMEL_US_USMODE_RS485;
>  	} else if (termios->c_cflag & CRTSCTS) {
>  		/* RS232 with hardware handshake (RTS/CTS) */
> -		mode |= ATMEL_US_USMODE_HWHS;
> +		if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
> +			dev_info(port->dev, "not enabling hardware flow control because DMA is used");
> +			termios->c_cflag &= ~CRTSCTS;
> +		} else {
> +			mode |= ATMEL_US_USMODE_HWHS;
> +		}
>  	} else {
>  		/* RS232 without hadware handshake */
>  		mode |= ATMEL_US_USMODE_NORMAL;
> 


-- 
Nicolas Ferre

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

end of thread, other threads:[~2016-04-15 12:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-12 12:51 [PATCH] tty/serial: atmel: fix hardware handshake selection Alexandre Belloni
2016-04-12 12:51 ` Alexandre Belloni
2016-04-15 12:52 ` Nicolas Ferre
2016-04-15 12:52   ` Nicolas Ferre
2016-04-15 12:52   ` Nicolas Ferre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.