FAILED: patch "[PATCH] serial: uartps: Fix stuck ISR if RX disabled with non-empty" failed to apply to 4.4-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 7abab1605139bc41442864c18f9573440f7ca105 Mon Sep 17 00:00:00 2001
From: Anssi Hannula <[email protected]>
Date: Fri, 15 Feb 2019 18:45:08 +0200
Subject: [PATCH] serial: uartps: Fix stuck ISR if RX disabled with non-empty
FIFO
If RX is disabled while there are still unprocessed bytes in RX FIFO, cdns_uart_handle_rx() called from interrupt handler will get stuck in the receive loop as read bytes will not get removed from the RX FIFO and CDNS_UART_SR_RXEMPTY bit will never get set.
Avoid the stuck handler by checking first if RX is disabled. port->lock protects against race with RX-disabling functions.
This HW behavior was mentioned by Nathan Rossi in 43e98facc4a3 ("tty:
xuartps: Fix RX hang, and TX corruption in termios call") which fixed a similar issue in cdns_uart_set_termios().
The behavior can also be easily verified by e.g. setting CDNS_UART_CR_RX_DIS at the beginning of cdns_uart_handle_rx() - the following loop will then get stuck.
Resetting the FIFO using RXRST would not set RXEMPTY either so simply issuing a reset after RX-disable would not work.
I observe this frequently on a ZynqMP board during heavy RX load at 1M baudrate when the reader process exits and thus RX gets disabled.
drivers/tty/serial/xilinx_uartps.c +7 -1
@@ -364,7 +364,13 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id)cdns_uart_handle_tx (dev_id); isrstatus &= ~CDNS_UART_IXR_TXEMPTY ; } -if (isrstatus &CDNS_UART_IXR_RXMASK ) + +/* +* Skip RX processing if RX is disabled as RXEMPTY will never be set +* as read bytes will not be removed from the FIFO. +*/ +if (isrstatus &CDNS_UART_IXR_RXMASK && + !(readl (port->membase +CDNS_UART_CR ) &CDNS_UART_CR_RX_DIS ))cdns_uart_handle_rx (dev_id, isrstatus);spin_unlock (&port->lock);