diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c index d4ece0e56954..51dce6d43890 100644 --- a/drivers/tty/serial/msm_serial_hs.c +++ b/drivers/tty/serial/msm_serial_hs.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -1237,16 +1238,27 @@ static void msm_hs_set_termios(struct uart_port *uport, unsigned int msm_hs_tx_empty(struct uart_port *uport) { unsigned int data; + unsigned int isr; unsigned int ret = 0; struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport); msm_hs_resource_vote(msm_uport); data = msm_hs_read(uport, UART_DM_SR); + isr = msm_hs_read(uport, UART_DM_ISR); msm_hs_resource_unvote(msm_uport); - MSM_HS_DBG("%s(): SR Reg Read 0x%x", __func__, data); + MSM_HS_INFO("%s(): SR:0x%x ISR:0x%x ", __func__, data, isr); - if (data & UARTDM_SR_TXEMT_BMSK) + if (data & UARTDM_SR_TXEMT_BMSK) { ret = TIOCSER_TEMT; + } else + /* + * Add an extra sleep here because sometimes the framework's + * delay (based on baud rate) isn't good enough. + * Note that this won't happen during every port close, only + * on select occassions when the userspace does back to back + * write() and close(). + */ + usleep_range(5000, 7000); return ret; }