From: Doug Anderson <dianders@chromium.org>
To: Greg KH <greg@kroah.com>
Cc: Jiri Slaby <jirislaby@gmail.com>,
Stephen Warren <swarren@nvidia.com>,
Olof Johansson <olof@lixom.net>,
Greg Kroah-Hartman <gregkh@suse.de>,
Alan Cox <alan@linux.intel.com>,
Allen Martin <AMartin@nvidia.com>,
Tom Warren <twarren@nvidia.com>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Doug Anderson <dianders@chromium.org>
Subject: [PATCH v3] TTY: serial_core: Fix crash if DCD drop during suspend
Date: Wed, 19 Oct 2011 11:52:01 -0700 [thread overview]
Message-ID: <1319050321-14330-1-git-send-email-dianders@chromium.org> (raw)
In-Reply-To: <20111018212105.GA10426@kroah.com>
This crash was showing up 100% of the time on Tegra CPUs when an
agetty was running on the serial port and the console was not running
on the serial port. The reason the Tegra saw it so reliably is that
the Tegra CPU internally ties DTR to DCD/DSR. That means when we
dropped DTR during suspend we would get always get an immediate DCD
drop.
The specific order of operations that were running:
* uart_suspend_port() would be called to put the uart in suspend mode
* we'd drop DTR (ops->set_mctrl(uport, 0)).
* the DTR drop would be looped back in the CPU to be a DCD drop.
* the DCD drop would look to the serial driver as a hangup
* the hangup would call uart_shutdown()
* ... suspend / resume happens ...
* uart_resume_port() would be called and run the code in the
(port->flags & ASYNC_SUSPENDED) block, which would startup the port
(and enable tx again).
* Since the UART would be available for tx, we'd immediately get
an interrupt, eventually calling transmit_chars()
* The transmit_chars() function would crash. The first crash would
be a dereference of a NULL tty member, but since the port has been
shutdown that was just a symptom.
I have proposed a patch that would fix the Tegra CPUs here (see
https://lkml.org/lkml/2011/10/11/444 - tty/serial: Prevent drop of DCD
on suspend for Tegra UARTs). However, even with that fix it is still
possible for systems that have an externally visible DCD line to see a
crash if the DCD drops at just the right time during suspend: thus
this patch is still useful.
Signed-off-by: Doug Anderson <dianders@chromium.org>
Acked-by: Alan Cox <alan@linux.intel.com>
---
v3: Applies against linux-next (needed after 6a3e492b)
drivers/tty/serial/serial_core.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 9dc44a5..0406d7f 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -249,6 +249,13 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
}
/*
+ * It's possible for shutdown to be called after suspend if we get
+ * a DCD drop (hangup) at just the right time. Clear suspended bit so
+ * we don't try to resume a port that has been shutdown.
+ */
+ clear_bit(ASYNCB_SUSPENDED, &port->flags);
+
+ /*
* Free the transmit buffer page.
*/
if (state->xmit.buf) {
--
1.7.3.1
prev parent reply other threads:[~2011-10-19 19:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-07 21:59 [PATCH] TTY: serial_core: Fix crash if agetty() run on non-console serial port Doug Anderson
2011-10-08 8:49 ` Jiri Slaby
2011-10-08 15:55 ` Doug Anderson
2011-10-10 20:28 ` Doug Anderson
2011-10-12 0:25 ` [PATCH v2] TTY: serial_core: Fix crash if DCD drop during suspend Doug Anderson
2011-10-12 11:57 ` Alan Cox
2011-10-18 21:21 ` Greg KH
2011-10-19 18:52 ` Doug Anderson [this message]
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=1319050321-14330-1-git-send-email-dianders@chromium.org \
--to=dianders@chromium.org \
--cc=AMartin@nvidia.com \
--cc=alan@linux.intel.com \
--cc=greg@kroah.com \
--cc=gregkh@suse.de \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=olof@lixom.net \
--cc=swarren@nvidia.com \
--cc=twarren@nvidia.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).