Linux-Serial Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/1] serial: 8250: Fix TX interrupt handling condition in 8250_fsl.c
@ 2020-09-21  8:43 drolevar
  2020-09-21  8:43 ` [PATCH 1/1] " drolevar
  0 siblings, 1 reply; 3+ messages in thread
From: drolevar @ 2020-09-21  8:43 UTC (permalink / raw)
  To: linux-serial; +Cc: gregkh, Andrij Abyzov

From: Andrij Abyzov <aabyzov@slb.com>

This is a port of the commit
db1b5bc047b3cadaedab3826bba82c3d9e023c4b ("Fix TX interrupt handling condition")
to the FSL-specifific interrupt handling routine.

Especially essential in case of RS 485 operation.

Andrij Abyzov (1):
  serial: 8250: Fix TX interrupt handling condition in 8250_fsl.c

 drivers/tty/serial/8250/8250_fsl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.25.1


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

* [PATCH 1/1] serial: 8250: Fix TX interrupt handling condition in 8250_fsl.c
  2020-09-21  8:43 [PATCH 0/1] serial: 8250: Fix TX interrupt handling condition in 8250_fsl.c drolevar
@ 2020-09-21  8:43 ` drolevar
  2020-09-27 12:16   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: drolevar @ 2020-09-21  8:43 UTC (permalink / raw)
  To: linux-serial; +Cc: gregkh, Andrij Abyzov

From: Andrij Abyzov <aabyzov@slb.com>

This is a port of the commit
db1b5bc047b3cadaedab3826bba82c3d9e023c4b ("Fix TX interrupt handling condition")
to the FSL-specifific interrupt handling routine.

Interrupt handler checked THRE bit (transmitter holding register
empty) in LSR to detect if TX fifo is empty.
In case when there is only receive interrupts the TX handling
got called because THRE bit in LSR is set when there is no
transmission (FIFO empty). TX handling caused TX stop, which in
RS-485 half-duplex mode actually resets receiver FIFO. This is not
desired during reception because of possible data loss.

The fix is to check if THRI is set in IER in addition of the TX
fifo status. THRI in IER is set when TX is started and cleared
when TX is stopped.
This ensures that TX handling is only called when there is really
transmission on going and an interrupt for THRE and not when there
are only RX interrupts.

Signed-off-by: Andrij Abyzov <aabyzov@slb.com>
---
 drivers/tty/serial/8250/8250_fsl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c
index 0d0c80905c58..ceac6cfce4c7 100644
--- a/drivers/tty/serial/8250/8250_fsl.c
+++ b/drivers/tty/serial/8250/8250_fsl.c
@@ -71,7 +71,7 @@ int fsl8250_handle_irq(struct uart_port *port)
 
 	serial8250_modem_status(up);
 
-	if (lsr & UART_LSR_THRE)
+	if ((lsr & UART_LSR_THRE) && (up->ier & UART_IER_THRI))
 		serial8250_tx_chars(up);
 
 	up->lsr_saved_flags = orig_lsr;
-- 
2.25.1


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

* Re: [PATCH 1/1] serial: 8250: Fix TX interrupt handling condition in 8250_fsl.c
  2020-09-21  8:43 ` [PATCH 1/1] " drolevar
@ 2020-09-27 12:16   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2020-09-27 12:16 UTC (permalink / raw)
  To: drolevar; +Cc: linux-serial, Andrij Abyzov

On Mon, Sep 21, 2020 at 10:43:13AM +0200, drolevar@gmail.com wrote:
> From: Andrij Abyzov <aabyzov@slb.com>
> 
> This is a port of the commit
> db1b5bc047b3cadaedab3826bba82c3d9e023c4b ("Fix TX interrupt handling condition")
> to the FSL-specifific interrupt handling routine.

See the kernel documentation file "submitting patches" for how to
reference commits within changelogs.  This paragraph should look
something like:

	This is the port of the commit db1b5bc047b3 ("serial: 8250: Fix TX
	interrupt handling condition") to the 8250_fsl irq handling logic.

Right?

> Interrupt handler checked THRE bit (transmitter holding register
> empty) in LSR to detect if TX fifo is empty.
> In case when there is only receive interrupts the TX handling
> got called because THRE bit in LSR is set when there is no
> transmission (FIFO empty). TX handling caused TX stop, which in
> RS-485 half-duplex mode actually resets receiver FIFO. This is not
> desired during reception because of possible data loss.
> 
> The fix is to check if THRI is set in IER in addition of the TX
> fifo status. THRI in IER is set when TX is started and cleared
> when TX is stopped.
> This ensures that TX handling is only called when there is really
> transmission on going and an interrupt for THRE and not when there
> are only RX interrupts.
> 
> Signed-off-by: Andrij Abyzov <aabyzov@slb.com>
> ---
>  drivers/tty/serial/8250/8250_fsl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c
> index 0d0c80905c58..ceac6cfce4c7 100644
> --- a/drivers/tty/serial/8250/8250_fsl.c
> +++ b/drivers/tty/serial/8250/8250_fsl.c
> @@ -71,7 +71,7 @@ int fsl8250_handle_irq(struct uart_port *port)
>  
>  	serial8250_modem_status(up);
>  
> -	if (lsr & UART_LSR_THRE)
> +	if ((lsr & UART_LSR_THRE) && (up->ier & UART_IER_THRI))
>  		serial8250_tx_chars(up);

Does this fix up a bug that has always been there, or was caused by a
specific kernel change?  If a specific one, please list that on the
Fixes: line.

Can you fix this up and resend?

thanks,

greg k-h

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21  8:43 [PATCH 0/1] serial: 8250: Fix TX interrupt handling condition in 8250_fsl.c drolevar
2020-09-21  8:43 ` [PATCH 1/1] " drolevar
2020-09-27 12:16   ` Greg KH

Linux-Serial Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-serial/0 linux-serial/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-serial linux-serial/ https://lore.kernel.org/linux-serial \
		linux-serial@vger.kernel.org
	public-inbox-index linux-serial

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-serial


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git