From: Peter Hurley <peter-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
To: Johan Hovold <jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Greg KH
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Chris Ruehl <chris.ruehl-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>,
Alan Stern
<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
Alan Cox <alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Alan Cox <alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [RFC 2/4] tty: fix DTR/RTS not being dropped on hang up
Date: Wed, 13 Feb 2013 20:11:13 -0500 [thread overview]
Message-ID: <1360804273.3385.23.camel@thor.lan> (raw)
In-Reply-To: <1360783973.8499.48.camel-AsKIXgLx6sE@public.gmane.org>
On Wed, 2013-02-13 at 14:32 -0500, Peter Hurley wrote:
> On Wed, 2013-02-13 at 18:27 +0100, Johan Hovold wrote:
> > Move HUPCL handling to port shutdown so that DTR/RTS is dropped also on
> > hang up.
> >
> > Currently a hung up port will return immediately from
> > tty_port_close_start leaving DTR/RTS unchanged.
> > ---
> > drivers/tty/tty_port.c | 22 ++++++++++++----------
> > 1 file changed, 12 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
> > index 57a061e..ffe3689 100644
> > --- a/drivers/tty/tty_port.c
> > +++ b/drivers/tty/tty_port.c
> > @@ -198,11 +198,20 @@ EXPORT_SYMBOL(tty_port_tty_set);
> >
> > static void tty_port_shutdown(struct tty_port *port)
> > {
> > + struct tty_struct *tty = port->tty;
> > +
> > mutex_lock(&port->mutex);
> > if (port->console)
> > goto out;
> >
> > if (test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) {
> > + /*
> > + * Drop DTR/RTS if HUPCL is set. This causes any attached
> > + * modem to hang up the line.
> > + */
> > + if (!tty || tty->termios.c_cflag & HUPCL)
> > + tty_port_lower_dtr_rts(port);
> > +
>
> port->ops->shutdown() requires the hardware to reset anyway, including
> the DTR/RTS state.
Ok, after reviewing this further, I like this more.
For one, there is more flexibility for tty drivers that have a custom
close() routine (ie, one that doesn't call tty_port_close()). At the
same time, every call site of tty_port_close_start() needs to be checked
to ensure it does not assume (or does not require) DTR to be dropped:
char/pcmcia/synclink_cs.c: if (tty_port_close_start(port, tty, filp) == 0)
tty/synclinkmp.c: if (tty_port_close_start(&info->port, tty, filp) == 0)
tty/rocket.c: if (tty_port_close_start(port, tty, filp) == 0)
tty/amiserial.c: if (tty_port_close_start(port, tty, filp) == 0)
tty/n_gsm.c: if (tty_port_close_start(&dlci->port, tty, filp) == 0)
tty/mxser.c: if (tty_port_close_start(port, tty, filp) == 0)
tty/synclink_gt.c: if (tty_port_close_start(&info->port, tty, filp) == 0)
tty/serial/serial_core.c: if (tty_port_close_start(port, tty, filp) == 0)
tty/synclink.c: if (tty_port_close_start(&info->port, tty, filp) == 0)
In the case of the serial core, this actually fixes the code excerpt
below where tty_port_close_start() prematurely drops DTR before the uart
can stop_rx() or wait_until_sent().
static void uart_close(struct tty_struct *tty, struct file *filp)
{
struct uart_state *state = tty->driver_data;
struct tty_port *port;
struct uart_port *uport;
unsigned long flags;
if (!state)
return;
uport = state->uart_port;
port = &state->port;
pr_debug("uart_close(%d) called\n", uport->line);
if (tty_port_close_start(port, tty, filp) == 0)
return;
/*
* At this point, we stop accepting input. To do this, we
* disable the receive line status interrupts.
*/
if (port->flags & ASYNC_INITIALIZED) {
unsigned long flags;
spin_lock_irqsave(&uport->lock, flags);
uport->ops->stop_rx(uport);
spin_unlock_irqrestore(&uport->lock, flags);
/*
* Before we drop DTR, make sure the UART transmitter
* has completely drained; this is especially
* important if there is a transmit FIFO!
*/
uart_wait_until_sent(tty, uport->timeout);
}
mutex_lock(&port->mutex);
uart_shutdown(tty, state);
uart_flush_buffer(tty);
Regards,
Peter Hurley
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-02-14 1:11 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <510B2C09.7020700@gtsys.com.hk>
2013-02-13 14:25 ` USB Ooops PL2303 when unplug while use (linux v3.7.3) Johan Hovold
2013-02-13 14:28 ` [PATCH] USB: serial: fix null-pointer dereferences on disconnect Johan Hovold
[not found] ` <1360765731-23164-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-13 14:34 ` Felipe Balbi
2013-02-13 14:48 ` Johan Hovold
2013-02-13 16:41 ` Greg KH
2013-02-13 16:53 ` [PATCH resend] " Johan Hovold
2013-02-13 17:27 ` [RFC 0/4] tty: port hangup and close issues Johan Hovold
2013-02-13 17:27 ` [RFC 1/4] tty: clean up port shutdown Johan Hovold
2013-02-13 17:27 ` [RFC 2/4] tty: fix DTR/RTS not being dropped on hang up Johan Hovold
[not found] ` <1360776446-31371-3-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-13 18:06 ` [RFC v2 " Johan Hovold
2013-02-13 19:32 ` [RFC " Peter Hurley
[not found] ` <1360783973.8499.48.camel-AsKIXgLx6sE@public.gmane.org>
2013-02-14 1:11 ` Peter Hurley [this message]
[not found] ` <1360804273.3385.23.camel-AsKIXgLx6sE@public.gmane.org>
2013-02-14 9:04 ` Johan Hovold
2013-02-13 17:27 ` [RFC 3/4] tty: clean up port drain-delay handling Johan Hovold
2013-02-14 1:39 ` Peter Hurley
2013-02-14 9:12 ` Johan Hovold
2013-02-13 17:27 ` [RFC 4/4] tty: fix close of uninitialised ports Johan Hovold
2013-02-13 17:36 ` [RFC 0/4] tty: port hangup and close issues Alan Cox
[not found] ` <20130213173630.63e29b47-+KEw/ACL1GZE/aiTQr5FLb0Ud+EcFu5g@public.gmane.org>
2013-02-13 18:05 ` Johan Hovold
[not found] ` <1360776446-31371-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-20 16:02 ` [PATCH 0/4] TTY: port hangup and close fixes Johan Hovold
2013-02-20 16:02 ` [PATCH 1/4] TTY: clean up port shutdown Johan Hovold
2013-02-20 16:02 ` [PATCH 2/4] TTY: fix DTR not being dropped on hang up Johan Hovold
2013-02-23 14:18 ` Peter Hurley
2013-02-26 10:59 ` Johan Hovold
2013-02-20 16:02 ` [PATCH 3/4] TTY: clean up port drain-delay handling Johan Hovold
[not found] ` <1361376172-31860-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-20 16:02 ` [PATCH 4/4] TTY: fix close of uninitialised ports Johan Hovold
2013-02-21 1:53 ` [PATCH 0/4] TTY: port hangup and close fixes Peter Hurley
2013-02-13 18:40 ` USB Ooops PL2303 when unplug while use (linux v3.7.3) Peter Hurley
[not found] ` <1360780808.8499.43.camel-AsKIXgLx6sE@public.gmane.org>
2013-02-14 17:43 ` Johan Hovold
2013-02-22 10:03 ` USB: serial: port lifetimes (was: Re: USB Ooops PL2303 when unplug while use (linux v3.7.3)) Johan Hovold
2013-02-22 15:17 ` Alan Stern
2013-02-22 17:11 ` Johan Hovold
2013-02-22 17:35 ` Alan Stern
[not found] ` <Pine.LNX.4.44L0.1302221218270.1365-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-02-22 17:44 ` Greg KH
2013-02-22 18:21 ` Peter Hurley
[not found] ` <1361557284.5752.25.camel-AsKIXgLx6sE@public.gmane.org>
2013-02-22 18:57 ` Alan Stern
2013-02-23 16:05 ` Johan Hovold
2013-02-23 16:23 ` Johan Hovold
2013-02-23 16:34 ` Johan Hovold
2013-02-23 17:31 ` Alan Stern
2013-02-23 18:12 ` Johan Hovold
2013-02-23 21:20 ` Alan Stern
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=1360804273.3385.23.camel@thor.lan \
--to=peter-wagbzjegnqdsbiue7sb01tbpr1lh4cv8@public.gmane.org \
--cc=alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org \
--cc=chris.ruehl-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.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).