linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: edward.cragg@codethink.co.uk
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-meson@googlegroups.com, linux-kernel@codethink.co.uk,
	Ben Dooks <ben.dooks@codethink.co.uk>,
	linux-serial@vger.kernel.org, Jiri Slaby <jslaby@suse.com>,
	carlo@caione.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/9] ARM: meson: serial: don't reset port on uart startup
Date: Wed, 18 Nov 2015 14:41:12 +0000	[thread overview]
Message-ID: <1447857679-30158-3-git-send-email-ben.dooks@codethink.co.uk> (raw)
In-Reply-To: <1447857679-30158-1-git-send-email-ben.dooks@codethink.co.uk>

When the uart startup entry is called, do not reset the port as this
could cause issues with anything left in the FIFO from a previous operation
such as a console write. Move the hardware reset to probe time and simply
clear the errors before enabling the port.

This fixes the issue where the console could become corrupted as there
where characters left in the output or output fifo when a user process
such as systemd would open/close the uart to transmit characters.

For example, you get:
    [    3.252263] systemd[1]: Dete

instead of:
    [    3.338801] systemd[1]: Detected architecture arm.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/tty/serial/meson_uart.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index b9f0829..b87eb97 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -241,10 +241,9 @@ static const char *meson_uart_type(struct uart_port *port)
 	return (port->type == PORT_MESON) ? "meson_uart" : NULL;
 }
 
-static int meson_uart_startup(struct uart_port *port)
+static void meson_uart_reset(struct uart_port *port)
 {
 	u32 val;
-	int ret = 0;
 
 	val = readl(port->membase + AML_UART_CONTROL);
 	val |= (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR);
@@ -252,6 +251,18 @@ static int meson_uart_startup(struct uart_port *port)
 
 	val &= ~(AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR);
 	writel(val, port->membase + AML_UART_CONTROL);
+}
+
+static int meson_uart_startup(struct uart_port *port)
+{
+	u32 val;
+	int ret = 0;
+
+	val = readl(port->membase + AML_UART_CONTROL);
+	val |= AML_UART_CLR_ERR;
+	writel(val, port->membase + AML_UART_CONTROL);
+	val &= ~AML_UART_CLR_ERR;
+	writel(val, port->membase + AML_UART_CONTROL);
 
 	val |= (AML_UART_RX_EN | AML_UART_TX_EN);
 	writel(val, port->membase + AML_UART_CONTROL);
@@ -581,6 +592,12 @@ static int meson_uart_probe(struct platform_device *pdev)
 	meson_ports[pdev->id] = port;
 	platform_set_drvdata(pdev, port);
 
+	/* reset port before registering (and possibly registering console) */
+	if (meson_uart_request_port(port) >= 0) {
+		meson_uart_reset(port);
+		meson_uart_release_port(port);
+	}
+
 	ret = uart_add_one_port(&meson_uart_driver, port);
 	if (ret)
 		meson_ports[pdev->id] = NULL;
-- 
2.6.2

  parent reply	other threads:[~2015-11-18 14:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 14:41 AMLogic Meson serial driver fixes Ben Dooks
2015-11-18 14:41 ` [PATCH 1/9] ARM: meson: serial: release region on port release Ben Dooks
2015-11-18 14:41 ` Ben Dooks [this message]
2015-11-18 14:41 ` [PATCH 3/9] ARM: meson: serial: tx_empty fails to check for transmitter busy Ben Dooks
2015-11-18 14:41 ` [PATCH 4/9] ARM: meson: serial: ensure console port uart enabled Ben Dooks
2015-11-18 14:41 ` [PATCH 5/9] ARM: meson: serial: only disable tx irq on stop Ben Dooks
2015-11-18 14:41 ` [PATCH 6/9] ARM: meson: serial: use meson_uart_tx_empty() to wait for empty Ben Dooks
2015-11-18 14:41 ` [PATCH 7/9] ARM: meson: serial: disable rx/tx irqs during console write Ben Dooks
2015-11-18 14:41 ` [PATCH 8/9] ARM: meson: serial: ensure tx irq on if more work to do Ben Dooks
2015-11-18 14:41 ` [PATCH 9/9] ARM: meson: serial: check for tx-irq enabled in irq code Ben Dooks
2015-11-23 11:52 ` [linux-meson] AMLogic Meson serial driver fixes Carlo Caione

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=1447857679-30158-3-git-send-email-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=carlo@caione.org \
    --cc=edward.cragg@codethink.co.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@codethink.co.uk \
    --cc=linux-meson@googlegroups.com \
    --cc=linux-serial@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).