diff options
author | Joshua Cha <joshuac@nvidia.com> | 2011-11-15 21:17:53 +0900 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:50:05 -0800 |
commit | 15b18ddbdd48111a05af1cdcc19789a280e82425 (patch) | |
tree | f8c9c844c82506320b2bcb6d6e52695a8f3f789a /drivers/tty/serial | |
parent | d812b830adff1ec2beb3311bcd0f15ca1c6e9372 (diff) |
serial: tegra: add timeout in tegra_uart_hw_deinit
If tx empty is not available because there is no peer device or
no response due to HW malfunction, we have infinite loop in
checking tx empty condition.
To enter suspend mode, retry timeout count is added.
Bug 901950
Change-Id: Ic3827faccba3509456e5e695e74d7394b12029a5
Reviewed-on: http://git-master/r/64426
Tested-by: Joshua Cha <joshuac@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Rebase-Id: R3e2d6323b031559c74621595447cc0d02187d1da
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r-- | drivers/tty/serial/tegra_hsuart.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/tty/serial/tegra_hsuart.c b/drivers/tty/serial/tegra_hsuart.c index 277361698d08..ab41cc5db9e6 100644 --- a/drivers/tty/serial/tegra_hsuart.c +++ b/drivers/tty/serial/tegra_hsuart.c @@ -90,6 +90,8 @@ const int dma_req_sel[] = { #define TEGRA_UART_TX_TRIG_4B 0x20 #define TEGRA_UART_TX_TRIG_1B 0x30 +#define TX_EMPTY_TIMEOUT_CNT 5000 + struct tegra_uart_port { struct uart_port uport; char port_name[32]; @@ -621,12 +623,19 @@ static void tegra_stop_rx(struct uart_port *u) static void tegra_uart_hw_deinit(struct tegra_uart_port *t) { unsigned long flags; + int retry = 0; /* Disable interrupts */ uart_writeb(t, 0, UART_IER); - while ((uart_readb(t, UART_LSR) & UART_LSR_TEMT) != UART_LSR_TEMT); + while ((uart_readb(t, UART_LSR) & UART_LSR_TEMT) != UART_LSR_TEMT) { udelay(200); + if (retry++ > TX_EMPTY_TIMEOUT_CNT) { + dev_err(t->uport.dev, "%s: Tx Empty timeout! (%d)\n", + __func__, TX_EMPTY_TIMEOUT_CNT); + break; + } + } spin_lock_irqsave(&t->uport.lock, flags); |