tty: serial: msm_serial: avoid system lockup condition [Linux 4.4.187]

This Linux kernel change "tty: serial: msm_serial: avoid system lockup condition" is included in the Linux 4.4.187 release. This change is authored by Jorge Ramirez-Ortiz <jorge.ramirez-ortiz [at] linaro.org> on Mon Jun 10 19:23:08 2019 +0200. The commit for this change in Linux stable tree is e14829d (patch) which is from upstream commit ba3684f. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream ba3684f.

tty: serial: msm_serial: avoid system lockup condition

[ Upstream commit ba3684f99f1b25d2a30b6956d02d339d7acb9799 ]

The function msm_wait_for_xmitr can be taken with interrupts
disabled. In order to avoid a potential system lockup - demonstrated
under stress testing conditions on SoC QCS404/5 - make sure we wait
for a bounded amount of time.

Tested on SoC QCS404.

Signed-off-by: Jorge Ramirez-Ortiz <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/tty/serial/msm_serial.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 5f0ded6..eaeb098 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -222,10 +222,14 @@ static void msm_request_rx_dma(struct msm_port *msm_port, resource_size_t base)

 static inline void msm_wait_for_xmitr(struct uart_port *port)
 {
+   unsigned int timeout = 500000;
+
    while (!(msm_read(port, UART_SR) & UART_SR_TX_EMPTY)) {
        if (msm_read(port, UART_ISR) & UART_ISR_TX_READY)
            break;
        udelay(1);
+       if (!timeout--)
+           break;
    }
    msm_write(port, UART_CR_CMD_RESET_TX_READY, UART_CR);
 }

Leave a Reply

Your email address will not be published. Required fields are marked *