linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] serial: tegra: fix CREAD handling for PIO
@ 2020-07-10 13:59 Johan Hovold
  2020-07-10 13:59 ` [PATCH 1/2] " Johan Hovold
  2020-07-10 13:59 ` [PATCH 2/2] serial: tegra: drop bogus NULL tty-port checks Johan Hovold
  0 siblings, 2 replies; 5+ messages in thread
From: Johan Hovold @ 2020-07-10 13:59 UTC (permalink / raw)
  To: Laxman Dewangan, Greg Kroah-Hartman
  Cc: Jiri Slaby, Thierry Reding, Jonathan Hunter, linux-serial,
	linux-tegra, linux-kernel, Johan Hovold

Stumbled over these two; compile-tested only.

Johan


Johan Hovold (2):
  serial: tegra: fix CREAD handling for PIO
  serial: tegra: drop bogus NULL tty-port checks

 drivers/tty/serial/serial-tegra.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

-- 
2.26.2


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

* [PATCH 1/2] serial: tegra: fix CREAD handling for PIO
  2020-07-10 13:59 [PATCH 0/2] serial: tegra: fix CREAD handling for PIO Johan Hovold
@ 2020-07-10 13:59 ` Johan Hovold
  2020-07-14 15:52   ` Thierry Reding
  2020-07-10 13:59 ` [PATCH 2/2] serial: tegra: drop bogus NULL tty-port checks Johan Hovold
  1 sibling, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2020-07-10 13:59 UTC (permalink / raw)
  To: Laxman Dewangan, Greg Kroah-Hartman
  Cc: Jiri Slaby, Thierry Reding, Jonathan Hunter, linux-serial,
	linux-tegra, linux-kernel, Johan Hovold, stable,
	Shardar Shariff Md, Krishna Yarlagadda

Commit 33ae787b74fc ("serial: tegra: add support to ignore read") added
support for dropping input in case CREAD isn't set, but for PIO the
ignore_status_mask wasn't checked until after the character had been
put in the receive buffer.

Note that the NULL tty-port test is bogus and will be removed by a
follow-on patch.

Fixes: 33ae787b74fc ("serial: tegra: add support to ignore read")
Cc: stable <stable@vger.kernel.org>     # 5.4
Cc: Shardar Shariff Md <smohammed@nvidia.com>
Cc: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/serial-tegra.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index 8de8bac9c6c7..b3bbee6b6702 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -653,11 +653,14 @@ static void tegra_uart_handle_rx_pio(struct tegra_uart_port *tup,
 		ch = (unsigned char) tegra_uart_read(tup, UART_RX);
 		tup->uport.icount.rx++;
 
-		if (!uart_handle_sysrq_char(&tup->uport, ch) && tty)
-			tty_insert_flip_char(tty, ch, flag);
+		if (uart_handle_sysrq_char(&tup->uport, ch))
+			continue;
 
 		if (tup->uport.ignore_status_mask & UART_LSR_DR)
 			continue;
+
+		if (tty)
+			tty_insert_flip_char(tty, ch, flag);
 	} while (1);
 }
 
-- 
2.26.2


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

* [PATCH 2/2] serial: tegra: drop bogus NULL tty-port checks
  2020-07-10 13:59 [PATCH 0/2] serial: tegra: fix CREAD handling for PIO Johan Hovold
  2020-07-10 13:59 ` [PATCH 1/2] " Johan Hovold
@ 2020-07-10 13:59 ` Johan Hovold
  2020-07-14 15:52   ` Thierry Reding
  1 sibling, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2020-07-10 13:59 UTC (permalink / raw)
  To: Laxman Dewangan, Greg Kroah-Hartman
  Cc: Jiri Slaby, Thierry Reding, Jonathan Hunter, linux-serial,
	linux-tegra, linux-kernel, Johan Hovold

The struct tty_port is part of the uart state and will never be NULL in
the receive helpers. Drop the bogus NULL checks and rename the
pointer-variables "port" to differentiate them from struct tty_struct
pointers (which can be NULL).

Fixes: 962963e4ee23 ("serial: tegra: Switch to using struct tty_port")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/serial-tegra.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index b3bbee6b6702..04d1b0807e66 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -635,7 +635,7 @@ static void tegra_uart_handle_tx_pio(struct tegra_uart_port *tup)
 }
 
 static void tegra_uart_handle_rx_pio(struct tegra_uart_port *tup,
-		struct tty_port *tty)
+		struct tty_port *port)
 {
 	do {
 		char flag = TTY_NORMAL;
@@ -659,13 +659,12 @@ static void tegra_uart_handle_rx_pio(struct tegra_uart_port *tup,
 		if (tup->uport.ignore_status_mask & UART_LSR_DR)
 			continue;
 
-		if (tty)
-			tty_insert_flip_char(tty, ch, flag);
+		tty_insert_flip_char(port, ch, flag);
 	} while (1);
 }
 
 static void tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup,
-				      struct tty_port *tty,
+				      struct tty_port *port,
 				      unsigned int count)
 {
 	int copied;
@@ -675,17 +674,13 @@ static void tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup,
 		return;
 
 	tup->uport.icount.rx += count;
-	if (!tty) {
-		dev_err(tup->uport.dev, "No tty port\n");
-		return;
-	}
 
 	if (tup->uport.ignore_status_mask & UART_LSR_DR)
 		return;
 
 	dma_sync_single_for_cpu(tup->uport.dev, tup->rx_dma_buf_phys,
 				count, DMA_FROM_DEVICE);
-	copied = tty_insert_flip_string(tty,
+	copied = tty_insert_flip_string(port,
 			((unsigned char *)(tup->rx_dma_buf_virt)), count);
 	if (copied != count) {
 		WARN_ON(1);
-- 
2.26.2


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

* Re: [PATCH 1/2] serial: tegra: fix CREAD handling for PIO
  2020-07-10 13:59 ` [PATCH 1/2] " Johan Hovold
@ 2020-07-14 15:52   ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2020-07-14 15:52 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Laxman Dewangan, Greg Kroah-Hartman, Jiri Slaby, Jonathan Hunter,
	linux-serial, linux-tegra, linux-kernel, stable,
	Shardar Shariff Md, Krishna Yarlagadda

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

On Fri, Jul 10, 2020 at 03:59:46PM +0200, Johan Hovold wrote:
> Commit 33ae787b74fc ("serial: tegra: add support to ignore read") added
> support for dropping input in case CREAD isn't set, but for PIO the
> ignore_status_mask wasn't checked until after the character had been
> put in the receive buffer.
> 
> Note that the NULL tty-port test is bogus and will be removed by a
> follow-on patch.
> 
> Fixes: 33ae787b74fc ("serial: tegra: add support to ignore read")
> Cc: stable <stable@vger.kernel.org>     # 5.4
> Cc: Shardar Shariff Md <smohammed@nvidia.com>
> Cc: Krishna Yarlagadda <kyarlagadda@nvidia.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/tty/serial/serial-tegra.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Looks good to me:

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 2/2] serial: tegra: drop bogus NULL tty-port checks
  2020-07-10 13:59 ` [PATCH 2/2] serial: tegra: drop bogus NULL tty-port checks Johan Hovold
@ 2020-07-14 15:52   ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2020-07-14 15:52 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Laxman Dewangan, Greg Kroah-Hartman, Jiri Slaby, Jonathan Hunter,
	linux-serial, linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

On Fri, Jul 10, 2020 at 03:59:47PM +0200, Johan Hovold wrote:
> The struct tty_port is part of the uart state and will never be NULL in
> the receive helpers. Drop the bogus NULL checks and rename the
> pointer-variables "port" to differentiate them from struct tty_struct
> pointers (which can be NULL).
> 
> Fixes: 962963e4ee23 ("serial: tegra: Switch to using struct tty_port")
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/tty/serial/serial-tegra.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2020-07-14 15:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10 13:59 [PATCH 0/2] serial: tegra: fix CREAD handling for PIO Johan Hovold
2020-07-10 13:59 ` [PATCH 1/2] " Johan Hovold
2020-07-14 15:52   ` Thierry Reding
2020-07-10 13:59 ` [PATCH 2/2] serial: tegra: drop bogus NULL tty-port checks Johan Hovold
2020-07-14 15:52   ` Thierry Reding

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