From: Bryan Wu <cooloney@kernel.org>
To: alan@lxorguk.ukuu.org.uk
Cc: linux-kernel@vger.kernel.org,
Sonic Zhang <sonic.zhang@analog.com>,
Bryan Wu <cooloney@kernel.org>
Subject: [PATCH 05/18] Blackfin Serial Driver: fix bug - serial port transfer big file from host to target would have more lines
Date: Fri, 6 Mar 2009 14:42:47 +0800 [thread overview]
Message-ID: <1236321780-28718-6-git-send-email-cooloney@kernel.org> (raw)
In-Reply-To: <1236321780-28718-1-git-send-email-cooloney@kernel.org>
From: Sonic Zhang <sonic.zhang@analog.com>
Ignore receiving data if new position is in the same line of
current buffer tail and small.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
drivers/serial/bfin_5xx.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 8d34ccd..5a163f6 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -407,6 +407,15 @@ void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
spin_lock_irqsave(&uart->port.lock, flags);
+ /* 2D DMA RX buffer ring is used. Because curr_y_count and
+ * curr_x_count can't be read as an atomic operation,
+ * curr_y_count should be read before curr_x_count. When
+ * curr_x_count is read, curr_y_count may already indicate
+ * next buffer line. But, the position calculated here is
+ * still indicate the old line. The wrong position data may
+ * be smaller than current buffer tail, which cause garbages
+ * are received if it is not prohibit.
+ */
uart->rx_dma_nrows = get_dma_curr_ycount(uart->rx_dma_channel);
x_pos = get_dma_curr_xcount(uart->rx_dma_channel);
uart->rx_dma_nrows = DMA_RX_YCOUNT - uart->rx_dma_nrows;
@@ -417,7 +426,11 @@ void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
x_pos = 0;
pos = uart->rx_dma_nrows * DMA_RX_XCOUNT + x_pos;
- if (pos != uart->rx_dma_buf.tail) {
+ /* Ignore receiving data if new position is in the same line of
+ * current buffer tail and small.
+ */
+ if (pos > uart->rx_dma_buf.tail ||
+ uart->rx_dma_nrows < (uart->rx_dma_buf.tail/DMA_RX_XCOUNT)) {
uart->rx_dma_buf.head = pos;
bfin_serial_dma_rx_chars(uart);
uart->rx_dma_buf.tail = uart->rx_dma_buf.head;
@@ -455,11 +468,25 @@ static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id)
{
struct bfin_serial_port *uart = dev_id;
unsigned short irqstat;
+ int pos;
spin_lock(&uart->port.lock);
irqstat = get_dma_curr_irqstat(uart->rx_dma_channel);
clear_dma_irqstat(uart->rx_dma_channel);
- bfin_serial_dma_rx_chars(uart);
+
+ uart->rx_dma_nrows = get_dma_curr_ycount(uart->rx_dma_channel);
+ uart->rx_dma_nrows = DMA_RX_YCOUNT - uart->rx_dma_nrows;
+ if (uart->rx_dma_nrows == DMA_RX_YCOUNT)
+ uart->rx_dma_nrows = 0;
+
+ pos = uart->rx_dma_nrows * DMA_RX_XCOUNT;
+ if (pos > uart->rx_dma_buf.tail ||
+ uart->rx_dma_nrows < (uart->rx_dma_buf.tail/DMA_RX_XCOUNT)) {
+ uart->rx_dma_buf.head = pos;
+ bfin_serial_dma_rx_chars(uart);
+ uart->rx_dma_buf.tail = uart->rx_dma_buf.head;
+ }
+
spin_unlock(&uart->port.lock);
return IRQ_HANDLED;
--
1.5.6.3
next prev parent reply other threads:[~2009-03-06 6:46 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-06 6:42 [PATCH 00/18] Blackfin Serial Driver bug fixing and update Bryan Wu
2009-03-06 6:42 ` [PATCH 01/18] Blackfin Serial Driver: Add a debug function to serial driver Bryan Wu
2009-03-06 22:37 ` Andrew Morton
2009-03-06 6:42 ` [PATCH 02/18] Blackfin Serial Driver: use barrier instead of cpu_relax for Blackfin SMP like patch Bryan Wu
2009-03-06 22:37 ` Andrew Morton
2009-03-10 10:07 ` gyang
2009-03-10 10:25 ` Mike Frysinger
2009-03-10 16:48 ` Andrew Morton
2009-03-11 9:50 ` graff yang
2009-03-11 16:48 ` Andrew Morton
2009-03-06 6:42 ` [PATCH 03/18] Blackfin Serial Driver: fix a in dma circle rx buffer handling Bryan Wu
2009-03-06 22:38 ` Andrew Morton
2009-03-06 6:42 ` [PATCH 04/18] Blackfin Serial Driver: Change hardware flowcontrol from poll to interrupt driven Bryan Wu
2009-03-06 22:38 ` Andrew Morton
2009-03-06 22:49 ` Mike Frysinger
2009-03-06 23:00 ` Andrew Morton
2009-03-06 6:42 ` Bryan Wu [this message]
2009-03-06 22:38 ` [PATCH 05/18] Blackfin Serial Driver: fix bug - serial port transfer big file from host to target would have more lines Andrew Morton
2009-03-06 6:42 ` [PATCH 06/18] Blackfin Serial Driver: explain why we cannot cpu_relax() in early serial code Bryan Wu
2009-03-06 22:38 ` Andrew Morton
2009-03-06 6:42 ` [PATCH 07/18] Blackfin Serial Driver: BF538/9 Linux kernel Support Bryan Wu
2009-03-06 6:42 ` [PATCH 08/18] Blackfin Serial Driver: use "unsigned long" for flags with irq functions rather than "int" Bryan Wu
2009-03-06 6:42 ` [PATCH 09/18] Blackfin Serial Driver: irq funcs take an unsigned long for flags Bryan Wu
2009-03-06 6:42 ` [PATCH 10/18] Blackfin Serial Driver: fix compile error in PIO mode Bryan Wu
2009-03-06 6:42 ` [PATCH 11/18] Blackfin Serial Driver: update KGDB UART config name Bryan Wu
2009-03-06 6:42 ` [PATCH 12/18] Blackfin Serial Driver: fix building when debug is enabled but serial console is disabled Bryan Wu
2009-03-06 6:42 ` [PATCH 13/18] Blackfin Serial Driver: depend on KGDB_SERIAL_CONSOLE being set to N Bryan Wu
2009-03-06 6:42 ` [PATCH 14/18] Blackfin Serial Driver: use the DLAB macro to hide variant differences Bryan Wu
2009-03-06 22:38 ` Andrew Morton
2009-03-06 22:41 ` Mike Frysinger
2009-03-06 6:42 ` [PATCH 15/18] Blackfin Serial Driver: merge the upstream adeos/xenomai Bryan Wu
2009-03-06 22:38 ` Andrew Morton
2009-03-06 22:43 ` Mike Frysinger
2009-03-06 6:42 ` [PATCH 16/18] Blackfin Serial Driver: fix bug - up arrow key works abnormal for bf561 ezkit board Bryan Wu
2009-03-06 6:42 ` [PATCH 17/18] Blackfin Serial Driver: Fix bug - Enable hardware based CTS and RTS for bf548 Bryan Wu
2009-03-06 22:38 ` Andrew Morton
2009-03-06 6:43 ` [PATCH 18/18] Blackfin Serial Driver: update path to gpio header Bryan Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1236321780-28718-6-git-send-email-cooloney@kernel.org \
--to=cooloney@kernel.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=sonic.zhang@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox