From 4ea9c5999ccb17607da21e11ae9c72782edb5a2e Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Wed, 12 Feb 2020 08:37:20 -0500 Subject: [PATCH] fixes for 4.14 Signed-off-by: Sasha Levin --- ...s-add-a-timeout-to-the-tx-empty-wait.patch | 69 +++++++++++++++++++ queue-4.14/series | 1 + 2 files changed, 70 insertions(+) create mode 100644 queue-4.14/serial-uartps-add-a-timeout-to-the-tx-empty-wait.patch diff --git a/queue-4.14/serial-uartps-add-a-timeout-to-the-tx-empty-wait.patch b/queue-4.14/serial-uartps-add-a-timeout-to-the-tx-empty-wait.patch new file mode 100644 index 00000000000..4c2cdc93a6e --- /dev/null +++ b/queue-4.14/serial-uartps-add-a-timeout-to-the-tx-empty-wait.patch @@ -0,0 +1,69 @@ +From 28e9b4cd255e3bbb49f0dd6e1fc234e76d046c03 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 10 Feb 2020 10:18:25 -0700 +Subject: serial: uartps: Add a timeout to the tx empty wait + +From: Shubhrajyoti Datta + +[ Upstream commit 277375b864e8147975b064b513f491e2a910e66a ] + +In case the cable is not connected then the target gets into +an infinite wait for tx empty. +Add a timeout to the tx empty wait. + +Reported-by: Jean-Francois Dagenais +Signed-off-by: Shubhrajyoti Datta +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/xilinx_uartps.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c +index 0dbfd02e3b196..9826a15bfd871 100644 +--- a/drivers/tty/serial/xilinx_uartps.c ++++ b/drivers/tty/serial/xilinx_uartps.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + + #define CDNS_UART_TTY_NAME "ttyPS" + #define CDNS_UART_NAME "xuartps" +@@ -39,6 +40,7 @@ + #define CDNS_UART_NR_PORTS 2 + #define CDNS_UART_FIFO_SIZE 64 /* FIFO size */ + #define CDNS_UART_REGISTER_SPACE 0x1000 ++#define TX_TIMEOUT 500000 + + /* Rx Trigger level */ + static int rx_trigger_level = 56; +@@ -685,16 +687,20 @@ static void cdns_uart_set_termios(struct uart_port *port, + unsigned int cval = 0; + unsigned int baud, minbaud, maxbaud; + unsigned long flags; +- unsigned int ctrl_reg, mode_reg; ++ unsigned int ctrl_reg, mode_reg, val; ++ int err; + + spin_lock_irqsave(&port->lock, flags); + + /* Wait for the transmit FIFO to empty before making changes */ + if (!(readl(port->membase + CDNS_UART_CR) & + CDNS_UART_CR_TX_DIS)) { +- while (!(readl(port->membase + CDNS_UART_SR) & +- CDNS_UART_SR_TXEMPTY)) { +- cpu_relax(); ++ err = readl_poll_timeout(port->membase + CDNS_UART_SR, ++ val, (val & CDNS_UART_SR_TXEMPTY), ++ 1000, TX_TIMEOUT); ++ if (err) { ++ dev_err(port->dev, "timed out waiting for tx empty"); ++ return; + } + } + +-- +2.20.1 + diff --git a/queue-4.14/series b/queue-4.14/series index 2a0c5d401c3..ad19021729f 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -140,3 +140,4 @@ perf-core-fix-mlock-accounting-in-perf_mmap.patch rxrpc-fix-service-call-disconnection.patch asoc-pcm-update-fe-be-trigger-order-based-on-the-com.patch hv_sock-remove-the-accept-port-restriction.patch +serial-uartps-add-a-timeout-to-the-tx-empty-wait.patch -- 2.47.3