serial: uartps: Add a timeout to the tx empty wait
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 <jeff.dagenais@gmail.com> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
107475685a
commit
277375b864
|
@ -26,12 +26,14 @@
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
|
#include <linux/iopoll.h>
|
||||||
|
|
||||||
#define CDNS_UART_TTY_NAME "ttyPS"
|
#define CDNS_UART_TTY_NAME "ttyPS"
|
||||||
#define CDNS_UART_NAME "xuartps"
|
#define CDNS_UART_NAME "xuartps"
|
||||||
#define CDNS_UART_MAJOR 0 /* use dynamic node allocation */
|
#define CDNS_UART_MAJOR 0 /* use dynamic node allocation */
|
||||||
#define CDNS_UART_FIFO_SIZE 64 /* FIFO size */
|
#define CDNS_UART_FIFO_SIZE 64 /* FIFO size */
|
||||||
#define CDNS_UART_REGISTER_SPACE 0x1000
|
#define CDNS_UART_REGISTER_SPACE 0x1000
|
||||||
|
#define TX_TIMEOUT 500000
|
||||||
|
|
||||||
/* Rx Trigger level */
|
/* Rx Trigger level */
|
||||||
static int rx_trigger_level = 56;
|
static int rx_trigger_level = 56;
|
||||||
|
@ -684,14 +686,18 @@ static void cdns_uart_set_termios(struct uart_port *port,
|
||||||
unsigned int cval = 0;
|
unsigned int cval = 0;
|
||||||
unsigned int baud, minbaud, maxbaud;
|
unsigned int baud, minbaud, maxbaud;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned int ctrl_reg, mode_reg;
|
unsigned int ctrl_reg, mode_reg, val;
|
||||||
|
int err;
|
||||||
|
|
||||||
/* Wait for the transmit FIFO to empty before making changes */
|
/* Wait for the transmit FIFO to empty before making changes */
|
||||||
if (!(readl(port->membase + CDNS_UART_CR) &
|
if (!(readl(port->membase + CDNS_UART_CR) &
|
||||||
CDNS_UART_CR_TX_DIS)) {
|
CDNS_UART_CR_TX_DIS)) {
|
||||||
while (!(readl(port->membase + CDNS_UART_SR) &
|
err = readl_poll_timeout(port->membase + CDNS_UART_SR,
|
||||||
CDNS_UART_SR_TXEMPTY)) {
|
val, (val & CDNS_UART_SR_TXEMPTY),
|
||||||
cpu_relax();
|
1000, TX_TIMEOUT);
|
||||||
|
if (err) {
|
||||||
|
dev_err(port->dev, "timed out waiting for tx empty");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_lock_irqsave(&port->lock, flags);
|
spin_lock_irqsave(&port->lock, flags);
|
||||||
|
|
Loading…
Reference in New Issue