summaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorDilip Kota <c_dkota@codeaurora.org>2014-02-07 15:03:58 +0530
committerNaveen Kaje <nkaje@codeaurora.org>2014-03-14 00:24:22 -0600
commit638b50f3bbb0c6b15b7bc0c5ff788560f2c44ed3 (patch)
tree62dca3c72544170f3334e6b1c26bec6d7033b027 /drivers/tty
parent40394ea70959a873aa166d44881ddbd08403c188 (diff)
msm_serial_hs: Remove code dependency on flag tty_flush_receive
Removing code dependency on the flag and check the circular buffer directly and make sure that spin lock is taken appropriately in the tx lower half. This avoids the condition that can cause 1. tx lower half 2. submit tx command to race. CRs-Fixed: 621210 Change-Id: I344a72c3eb9770391576fa0e8f0a8da1ee50ea5b Signed-off-by: Dilip Kota <c_dkota@codeaurora.org> Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/msm_serial_hs.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c
index 5607191b3a4c..a95d387e1b02 100644
--- a/drivers/tty/serial/msm_serial_hs.c
+++ b/drivers/tty/serial/msm_serial_hs.c
@@ -253,7 +253,6 @@ struct msm_hs_port {
struct workqueue_struct *hsuart_wq; /* hsuart workqueue */
struct mutex clk_mutex; /* mutex to guard against clock off/clock on */
struct work_struct disconnect_rx_endpoint; /* disconnect rx_endpoint */
- bool tty_flush_receive;
enum uart_core_type uart_type;
unsigned long bam_handle;
resource_size_t bam_mem;
@@ -1854,12 +1853,13 @@ static void msm_serial_hs_tx_tlet(unsigned long tlet_ptr)
* Do the work buffer related work in BAM
* mode that is equivalent to legacy mode
*/
+ spin_lock_irqsave(&(msm_uport->uport.lock), flags);
- if (!msm_uport->tty_flush_receive)
+ if (!uart_circ_empty(tx_buf))
tx_buf->tail = (tx_buf->tail +
tx->tx_count) & ~UART_XMIT_SIZE;
else
- msm_uport->tty_flush_receive = false;
+ MSM_HS_DBG("%s:circ buffer is empty\n", __func__);
tx->dma_in_flight = 0;
@@ -1876,7 +1876,6 @@ static void msm_serial_hs_tx_tlet(unsigned long tlet_ptr)
if (uart_circ_chars_pending(tx_buf) < WAKEUP_CHARS)
uart_write_wakeup(uport);
- spin_lock_irqsave(&(msm_uport->uport.lock), flags);
if (msm_uport->tx.flush == FLUSH_STOP) {
msm_uport->tx.flush = FLUSH_SHUTDOWN;
wake_up(&msm_uport->tx.wait);
@@ -2052,14 +2051,6 @@ static void msm_hs_enable_ms_locked(struct uart_port *uport)
}
-static void msm_hs_flush_buffer(struct uart_port *uport)
-{
- struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
-
- if (msm_uport->tx.dma_in_flight)
- msm_uport->tty_flush_receive = true;
-}
-
/*
* Standard API, Break Signal
*
@@ -2304,11 +2295,9 @@ static irqreturn_t msm_hs_isr(int irq, void *dev)
/* Do not update tx_buf.tail if uart_flush_buffer already
* called in serial core
*/
- if (!msm_uport->tty_flush_receive)
+ if (!uart_circ_empty(tx_buf))
tx_buf->tail = (tx_buf->tail +
tx->tx_count) & ~UART_XMIT_SIZE;
- else
- msm_uport->tty_flush_receive = false;
tx->dma_in_flight = 0;
@@ -2734,8 +2723,6 @@ static int msm_hs_startup(struct uart_port *uport)
tx->tx_ready_int_en = 0;
tx->dma_in_flight = 0;
rx->rx_cmd_exec = false;
- msm_uport->tty_flush_receive = false;
- MSM_HS_DBG("%s: Setting tty_flush_receive to false\n", __func__);
if (!is_blsp_uart(msm_uport)) {
tx->xfer.complete_func = msm_hs_dmov_tx_callback;
@@ -3800,7 +3787,7 @@ static struct uart_ops msm_hs_ops = {
.config_port = msm_hs_config_port,
.release_port = msm_hs_release_port,
.request_port = msm_hs_request_port,
- .flush_buffer = msm_hs_flush_buffer,
+ .flush_buffer = NULL,
.ioctl = msm_hs_ioctl,
};