linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Soren Brinkmann <soren.brinkmann@xilinx.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.cz>,
	Michal Simek <michal.simek@xilinx.com>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	John Linn <john.linn@xilinx.com>,
	Soren Brinkmann <soren.brinkmann@xilinx.com>
Subject: [PATCH 06/10] tty: xuartps: Force enable the UART in xuartps_console_write
Date: Thu, 17 Oct 2013 14:08:09 -0700	[thread overview]
Message-ID: <1382044093-29905-7-git-send-email-soren.brinkmann@xilinx.com> (raw)
In-Reply-To: <1382044093-29905-1-git-send-email-soren.brinkmann@xilinx.com>

From: Lars-Peter Clausen <lars@metafoo.de>

It is possible that under certain circumstances xuartps_console_write is entered
while the UART disabled. When this happens the code will busy loop in
xuartps_console_putchar, since the character is never written and the TXEMPTY
flag is never set. The result is a system lockup. This patch force enables the
UART for the duration of xuartps_console_write to avoid this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: John Linn <john.linn@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
Squashed from these original patches:
	tty: xuartps: Force enable the UART in xuartps_console_write

	It is possible that under certain circumstances xuartps_console_write is entered
	while the UART disabled. When this happens the code will busy loop in
	xuartps_console_putchar, since the character is never written and the TXEMPTY
	flag is never set. The result is a system lockup. This patch force enables the
	UART for the duration of xuartps_console_write to avoid this.

	Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

and

	tty: xuartps: Fix bad register write in console_write

	The commit:
	serial: xilinx_uartps: Force enable the UART in xuartps_console_write
	(sha1: d21aec67c1c782314d20b3d619e76cf8aae593dc)
	caused  a new bug as the write to the control register had
	the offset and the value to write reversed.

	Reported-by: Jason Andrews <jasona@cadence.com>
	Signed-off-by: John Linn <john.linn@xilinx.com>
	Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
 drivers/tty/serial/xilinx_uartps.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 6e8ec6e9d5a2..fdc739b55eb3 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -953,7 +953,7 @@ static void xuartps_console_write(struct console *co, const char *s,
 {
 	struct uart_port *port = &xuartps_port[co->index];
 	unsigned long flags;
-	unsigned int imr;
+	unsigned int imr, ctrl;
 	int locked = 1;
 
 	if (oops_in_progress)
@@ -965,9 +965,19 @@ static void xuartps_console_write(struct console *co, const char *s,
 	imr = xuartps_readl(XUARTPS_IMR_OFFSET);
 	xuartps_writel(imr, XUARTPS_IDR_OFFSET);
 
+	/*
+	 * Make sure that the tx part is enabled. Set the TX enable bit and
+	 * clear the TX disable bit to enable the transmitter.
+	 */
+	ctrl = xuartps_readl(XUARTPS_CR_OFFSET);
+	xuartps_writel((ctrl & ~XUARTPS_CR_TX_DIS) | XUARTPS_CR_TX_EN,
+		XUARTPS_CR_OFFSET);
+
 	uart_console_write(port, s, count, xuartps_console_putchar);
 	xuartps_console_wait_tx(port);
 
+	xuartps_writel(ctrl, XUARTPS_CR_OFFSET);
+
 	/* restore interrupt state, it seems like there may be a h/w bug
 	 * in that the interrupt enable register should not need to be
 	 * written based on the data sheet
-- 
1.8.4.1

  parent reply	other threads:[~2013-10-17 21:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-17 21:08 [PATCH 00/10] tty: xuartps: Update Soren Brinkmann
2013-10-17 21:08 ` [PATCH 01/10] tty: xuartps: Use devm_clk_get() Soren Brinkmann
2013-10-17 21:08 ` [PATCH 02/10] tty: xuartps: Use devm_kzalloc Soren Brinkmann
2013-10-17 21:08 ` [PATCH 03/10] tty: xuartps: Implement BREAK detection, add SYSRQ support Soren Brinkmann
2013-12-02 20:42   ` Peter Hurley
2013-10-17 21:08 ` [PATCH 04/10] tty: xuartps: Add polled mode support for xuartps Soren Brinkmann
2013-10-17 21:08 ` [PATCH 05/10] tty: xuartps: support 64 byte FIFO size Soren Brinkmann
2013-10-17 21:08 ` Soren Brinkmann [this message]
2013-10-17 21:08 ` [PATCH 07/10] tty: xuartps: Updating set_baud_rate() Soren Brinkmann
2013-10-17 21:08 ` [PATCH 08/10] tty: xuartps: Dynamically adjust to input frequency changes Soren Brinkmann
2013-10-17 21:08 ` [PATCH 09/10] tty: xuartps: Implement suspend/resume callbacks Soren Brinkmann
2013-10-17 21:08 ` [PATCH 10/10] tty: xuartps: Update copyright information Soren Brinkmann

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=1382044093-29905-7-git-send-email-soren.brinkmann@xilinx.com \
    --to=soren.brinkmann@xilinx.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.linn@xilinx.com \
    --cc=jslaby@suse.cz \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=michal.simek@xilinx.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;
as well as URLs for NNTP newsgroup(s).