mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: "Richard Röjfors" <richard.rojfors@pelagicore.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Greg Kroah-Hartman" <gregkh@suse.de>
Subject: [PATCH 19/25] serial: timbuart: make sure last byte is sent when port is closed
Date: Fri, 21 May 2010 09:51:48 -0700	[thread overview]
Message-ID: <1274460714-11277-19-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20100521165113.GB11216@kroah.com>

From: Richard Röjfors <richard.rojfors@pelagicore.com>

Fix a problem in early versions of the FPGA IP.

In certain situations the IP reports that the FIFO is empty, but a byte is
still clocked out.  If a flush is done at that point the currently clocked
byte is canceled.

This causes incompatibilities with the upper layers when a port is closed,
it waits until the FIFO is empty and then closes the port.  During close
the FIFO is flushed -> the last byte is not sent properly.

Now the FIFO is only flushed if it is reported to be non-empty.  Which
makes the currently clocked out byte to finish.

[akpm@linux-foundation.org: fix build]
Signed-off-by: Richard Röjfors <richard.rojfors@pelagicore.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/serial/timbuart.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/serial/timbuart.c b/drivers/serial/timbuart.c
index 62f389f..67ca642 100644
--- a/drivers/serial/timbuart.c
+++ b/drivers/serial/timbuart.c
@@ -68,12 +68,22 @@ static void timbuart_start_tx(struct uart_port *port)
 	tasklet_schedule(&uart->tasklet);
 }
 
+static unsigned int timbuart_tx_empty(struct uart_port *port)
+{
+	u32 isr = ioread32(port->membase + TIMBUART_ISR);
+
+	return (isr & TXBE) ? TIOCSER_TEMT : 0;
+}
+
 static void timbuart_flush_buffer(struct uart_port *port)
 {
-	u8 ctl = ioread8(port->membase + TIMBUART_CTRL) | TIMBUART_CTRL_FLSHTX;
+	if (!timbuart_tx_empty(port)) {
+		u8 ctl = ioread8(port->membase + TIMBUART_CTRL) |
+			TIMBUART_CTRL_FLSHTX;
 
-	iowrite8(ctl, port->membase + TIMBUART_CTRL);
-	iowrite32(TXBF, port->membase + TIMBUART_ISR);
+		iowrite8(ctl, port->membase + TIMBUART_CTRL);
+		iowrite32(TXBF, port->membase + TIMBUART_ISR);
+	}
 }
 
 static void timbuart_rx_chars(struct uart_port *port)
@@ -195,13 +205,6 @@ void timbuart_tasklet(unsigned long arg)
 	dev_dbg(uart->port.dev, "%s leaving\n", __func__);
 }
 
-static unsigned int timbuart_tx_empty(struct uart_port *port)
-{
-	u32 isr = ioread32(port->membase + TIMBUART_ISR);
-
-	return (isr & TXBE) ? TIOCSER_TEMT : 0;
-}
-
 static unsigned int timbuart_get_mctrl(struct uart_port *port)
 {
 	u8 cts = ioread8(port->membase + TIMBUART_CTRL);
-- 
1.7.0.3


  parent reply	other threads:[~2010-05-21 16:53 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-21 16:51 [GIT PATCH] TTY patches for 2.6.35 Greg KH
2010-05-21 16:51 ` [PATCH 01/25] serial: bfin_sport_uart: work around anomaly 05000473 (make 32bit fifo read atomic) Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 02/25] serial: bfin_sport_uart: shorten the SPORT TX waiting loop Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 03/25] serial: bfin_sport_uart: remove unused peripheral pin lists Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 04/25] serial: bfin_sport_uart: add missing mapbase initialization Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 05/25] serial: bfin_sport_uart: rename early platform driver class string Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 06/25] serial: bfin_sport_uart: add support for CTS/RTS via GPIOs Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 07/25] serial: bfin_sport_uart: protect changes to uart_port Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 08/25] serial: bfin_sport_uart: zero sport_uart_port if allocated dynamically Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 09/25] serial: bfin_sport_uart: drop useless status masks Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 10/25] serial: bfin_sport_uart: only enable SPORT TX if data is to be sent Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 11/25] serial: bfin_sport_uart: pull in bfin_sport.h for SPORT defines Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 12/25] serial: bfin_sport_uart: drop the experimental markings Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 13/25] serial: bfin_sport_uart: drop redundant cpu depends Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 14/25] serial: TTY: new ldiscs for staging Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 15/25] tty: n_gsm line discipline Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 16/25] tty: n_gsm: depends on NET Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 17/25] serial: uartlite: move from byte accesses to word accesses Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 18/25] serial: two branches the same in timbuart_set_mctrl() Greg Kroah-Hartman
2010-05-21 16:51 ` Greg Kroah-Hartman [this message]
2010-05-21 16:51 ` [PATCH 20/25] serial: Add driver for the Altera JTAG UART Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 21/25] serial: Add driver for the Altera UART Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 22/25] tty: fix obsolete comment on tty_insert_flip_string_fixed_flag Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 23/25] serial: bfin_sport_uart: Use resource size to fix off-by-one error Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 24/25] serial: isicomm: handle running out of slots Greg Kroah-Hartman
2010-05-21 16:51 ` [PATCH 25/25] serial: Tidy REMOTE_DEBUG Greg Kroah-Hartman

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=1274460714-11277-19-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.rojfors@pelagicore.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

Powered by JetHome