summaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorFugang Duan <b38611@freescale.com>2014-11-05 13:13:02 +0800
committerNitin Garg <nitin.garg@freescale.com>2015-01-15 21:18:27 -0600
commitc9dab38cbb1fe1c9b4e26a6dfd1d28ebc4e86227 (patch)
treed382d2a06d21b6a5fa7003568b10d96cef32243c /drivers/tty
parent468d45014378b1eae4ed4e8bdd7657ea8e47e9e4 (diff)
MLK-9798 tty: serial: imx: fix the dma overwrite and buffer index issue
This reverts commit 0f7c43a163521ea081d7743c9a55314e7deba728. And add another change that mod the variable "last_completed_idx" after it increasing. Signed-off-by: Fugang Duan <B38611@freescale.com>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/imx.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 0da3430c045e..62c0e4ce2992 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -921,13 +921,13 @@ static void dma_rx_work(struct work_struct *w)
if (sport->rx_buf.last_completed_idx < sport->rx_buf.cur_idx) {
dma_rx_push_data(sport, tty, sport->rx_buf.last_completed_idx + 1,
- sport->rx_buf.cur_idx + 1);
+ sport->rx_buf.cur_idx);
} else if (sport->rx_buf.last_completed_idx == (IMX_RXBD_NUM - 1)) {
- dma_rx_push_data(sport, tty, 0, sport->rx_buf.cur_idx + 1);
+ dma_rx_push_data(sport, tty, 0, sport->rx_buf.cur_idx);
} else {
dma_rx_push_data(sport, tty, sport->rx_buf.last_completed_idx + 1,
IMX_RXBD_NUM);
- dma_rx_push_data(sport, tty, 0, sport->rx_buf.cur_idx + 1);
+ dma_rx_push_data(sport, tty, 0, sport->rx_buf.cur_idx);
}
}
@@ -967,18 +967,20 @@ static void dma_rx_callback(void *data)
status = dmaengine_tx_status(chan, (dma_cookie_t)0, &state);
count = RX_BUF_SIZE - state.residue;
+ sport->rx_buf.buf_info[sport->rx_buf.cur_idx].filled = true;
+ sport->rx_buf.buf_info[sport->rx_buf.cur_idx].rx_bytes = count;
+ sport->rx_buf.cur_idx++;
+ sport->rx_buf.cur_idx %= IMX_RXBD_NUM;
+ dev_dbg(sport->port.dev, "We get %d bytes.\n", count);
- if (count > 0) {
- sport->rx_buf.buf_info[sport->rx_buf.cur_idx].filled = true;
- sport->rx_buf.buf_info[sport->rx_buf.cur_idx].rx_bytes = count;
- sport->rx_buf.cur_idx++;
- sport->rx_buf.cur_idx %= IMX_RXBD_NUM;
- dev_dbg(sport->port.dev, "We get %d bytes.\n", count);
-
- if (sport->rx_buf.cur_idx == sport->rx_buf.last_completed_idx)
- dev_err(sport->port.dev, "overwrite!\n");
+ if (sport->rx_buf.cur_idx == sport->rx_buf.last_completed_idx)
+ dev_err(sport->port.dev, "overwrite!\n");
+ if (count) {
schedule_work(&sport->tsk_dma_rx);
+ } else {
+ sport->rx_buf.last_completed_idx++;
+ sport->rx_buf.last_completed_idx %= IMX_RXBD_NUM;
}
}
@@ -991,7 +993,7 @@ static int start_rx_dma(struct imx_port *sport)
sport->rx_buf.period_len = RX_BUF_SIZE;
sport->rx_buf.buf_len = IMX_RXBD_NUM * RX_BUF_SIZE;
sport->rx_buf.cur_idx = 0;
- sport->rx_buf.last_completed_idx = 0;
+ sport->rx_buf.last_completed_idx = -1;
desc = dmaengine_prep_dma_cyclic(chan, sport->rx_buf.dmaaddr,
sport->rx_buf.buf_len, sport->rx_buf.period_len,
DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT);