diff mbox series

[02/14] serial: tegra: add support to ignore read

Message ID 1565609303-27000-3-git-send-email-kyarlagadda@nvidia.com
State Deferred
Headers show
Series serial: tegra: Tegra186 support and fixes | expand

Commit Message

Krishna Yarlagadda Aug. 12, 2019, 11:28 a.m. UTC
From: Shardar Shariff Md <smohammed@nvidia.com>

Add support to ignore read characters if CREAD flag is not set.

Signed-off-by: Shardar Shariff Md <smohammed@nvidia.com>
Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
---
 drivers/tty/serial/serial-tegra.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Thierry Reding Aug. 13, 2019, 9:42 a.m. UTC | #1
On Mon, Aug 12, 2019 at 04:58:11PM +0530, Krishna Yarlagadda wrote:
> From: Shardar Shariff Md <smohammed@nvidia.com>
> 
> Add support to ignore read characters if CREAD flag is not set.
> 
> Signed-off-by: Shardar Shariff Md <smohammed@nvidia.com>
> Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
> ---
>  drivers/tty/serial/serial-tegra.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
> index 19f4c24..93d299e 100644
> --- a/drivers/tty/serial/serial-tegra.c
> +++ b/drivers/tty/serial/serial-tegra.c
> @@ -542,6 +542,9 @@ 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 (tup->uport.ignore_status_mask & UART_LSR_DR)
> +			continue;
> +
>  		if (!uart_handle_sysrq_char(&tup->uport, ch) && tty)
>  			tty_insert_flip_char(tty, ch, flag);

Is it a good idea to ignore even sysrq characters if CREAD is not set?
According to termios, CREAD enables the receiver, so technically if it
isn't set you can't even receive sysrq characters. But I don't know if
there are any rules regarding this.

Is this the same way that other drivers work?

Thierry

>  	} while (1);
> @@ -562,6 +565,10 @@ static void tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup,
>  		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,
>  				TEGRA_UART_RX_DMA_BUFFER_SIZE, DMA_FROM_DEVICE);
>  	copied = tty_insert_flip_string(tty,
> @@ -1190,6 +1197,11 @@ static void tegra_uart_set_termios(struct uart_port *u,
>  	tegra_uart_write(tup, tup->ier_shadow, UART_IER);
>  	tegra_uart_read(tup, UART_IER);
>  
> +	tup->uport.ignore_status_mask = 0;
> +	/* Ignore all characters if CREAD is not set */
> +	if ((termios->c_cflag & CREAD) == 0)
> +		tup->uport.ignore_status_mask |= UART_LSR_DR;
> +
>  	spin_unlock_irqrestore(&u->lock, flags);
>  }
>  
> -- 
> 2.7.4
>
Krishna Yarlagadda Aug. 27, 2019, 9:29 a.m. UTC | #2
> -----Original Message-----
> From: linux-tegra-owner@vger.kernel.org <linux-tegra-
> owner@vger.kernel.org> On Behalf Of Thierry Reding
> Sent: Tuesday, August 13, 2019 3:12 PM
> To: Krishna Yarlagadda <kyarlagadda@nvidia.com>
> Cc: gregkh@linuxfoundation.org; robh+dt@kernel.org;
> mark.rutland@arm.com; Jonathan Hunter <jonathanh@nvidia.com>; Laxman
> Dewangan <ldewangan@nvidia.com>; jslaby@suse.com; linux-
> serial@vger.kernel.org; devicetree@vger.kernel.org; linux-
> tegra@vger.kernel.org; linux-kernel@vger.kernel.org; Shardar Mohammed
> <smohammed@nvidia.com>
> Subject: Re: [PATCH 02/14] serial: tegra: add support to ignore read
> 
> On Mon, Aug 12, 2019 at 04:58:11PM +0530, Krishna Yarlagadda wrote:
> > From: Shardar Shariff Md <smohammed@nvidia.com>
> >
> > Add support to ignore read characters if CREAD flag is not set.
> >
> > Signed-off-by: Shardar Shariff Md <smohammed@nvidia.com>
> > Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
> > ---
> >  drivers/tty/serial/serial-tegra.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/tty/serial/serial-tegra.c
> > b/drivers/tty/serial/serial-tegra.c
> > index 19f4c24..93d299e 100644
> > --- a/drivers/tty/serial/serial-tegra.c
> > +++ b/drivers/tty/serial/serial-tegra.c
> > @@ -542,6 +542,9 @@ 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 (tup->uport.ignore_status_mask & UART_LSR_DR)
> > +			continue;
> > +
> >  		if (!uart_handle_sysrq_char(&tup->uport, ch) && tty)
> >  			tty_insert_flip_char(tty, ch, flag);
> 
> Is it a good idea to ignore even sysrq characters if CREAD is not set?
> According to termios, CREAD enables the receiver, so technically if it isn't set
> you can't even receive sysrq characters. But I don't know if there are any
> rules regarding this.
> 
> Is this the same way that other drivers work?
> 
> Thierry
> 
Looked into few drivers and sysrq characters are not ignored. This driver does
not support console driver. So this might not be needed.

KY
> >  	} while (1);
> > @@ -562,6 +565,10 @@ static void tegra_uart_copy_rx_to_tty(struct
> tegra_uart_port *tup,
> >  		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,
> >  				TEGRA_UART_RX_DMA_BUFFER_SIZE,
> DMA_FROM_DEVICE);
> >  	copied = tty_insert_flip_string(tty, @@ -1190,6 +1197,11 @@ static
> > void tegra_uart_set_termios(struct uart_port *u,
> >  	tegra_uart_write(tup, tup->ier_shadow, UART_IER);
> >  	tegra_uart_read(tup, UART_IER);
> >
> > +	tup->uport.ignore_status_mask = 0;
> > +	/* Ignore all characters if CREAD is not set */
> > +	if ((termios->c_cflag & CREAD) == 0)
> > +		tup->uport.ignore_status_mask |= UART_LSR_DR;
> > +
> >  	spin_unlock_irqrestore(&u->lock, flags);  }
> >
> > --
> > 2.7.4
> >
diff mbox series

Patch

diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index 19f4c24..93d299e 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -542,6 +542,9 @@  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 (tup->uport.ignore_status_mask & UART_LSR_DR)
+			continue;
+
 		if (!uart_handle_sysrq_char(&tup->uport, ch) && tty)
 			tty_insert_flip_char(tty, ch, flag);
 	} while (1);
@@ -562,6 +565,10 @@  static void tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup,
 		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,
 				TEGRA_UART_RX_DMA_BUFFER_SIZE, DMA_FROM_DEVICE);
 	copied = tty_insert_flip_string(tty,
@@ -1190,6 +1197,11 @@  static void tegra_uart_set_termios(struct uart_port *u,
 	tegra_uart_write(tup, tup->ier_shadow, UART_IER);
 	tegra_uart_read(tup, UART_IER);
 
+	tup->uport.ignore_status_mask = 0;
+	/* Ignore all characters if CREAD is not set */
+	if ((termios->c_cflag & CREAD) == 0)
+		tup->uport.ignore_status_mask |= UART_LSR_DR;
+
 	spin_unlock_irqrestore(&u->lock, flags);
 }