From: Peter Hurley <peter@hurleysoftware.com>
To: David Miller <davem@davemloft.net>
Cc: sasha.levin@oracle.com, samuel@sortiz.org,
gregkh@linuxfoundation.org, jslaby@suse.cz,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ircomm: release tty before sleeping potentially indefintely
Date: Sun, 03 Mar 2013 23:24:23 -0500 [thread overview]
Message-ID: <1362371063.3221.185.camel@thor.lan> (raw)
In-Reply-To: <20130303.213601.1201168888595187293.davem@davemloft.net>
On Sun, 2013-03-03 at 21:36 -0500, David Miller wrote:
> From: Peter Hurley <peter@hurleysoftware.com>
> Date: Sun, 03 Mar 2013 20:06:18 -0500
>
> > But regardless, this function __cannot__ sleep holding the tty_lock().
>
> So drop it across the schedule(), but recheck the termios after
> regrabbing it.
I'll have to do some research on that.
1) The code is using a deliberate snapshot.
if (tty->termios.c_cflag & CLOCAL) {
IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __func__ );
do_clocal = 1;
}
.....
while (1) {
.........
/*
* Check if link is ready now. Even if CLOCAL is
* specified, we cannot return before the IrCOMM link is
* ready
*/
if (!test_bit(ASYNCB_CLOSING, &port->flags) &&
(do_clocal || tty_port_carrier_raised(port)) &&
self->state == IRCOMM_TTY_READY)
{
break;
}
2) The only reason this driver isn't using tty_port_block_til_ready() is
the lone state check:
self->state == IRCOMM_TTY_READY
I take it IRDA has some kind of virtual cabling protocol. But it's
unclear why this can't be implemented in the driver without duplicating
tty_port_block_til_ready(). For example, if the device can't do CLOCAL
open (meaning no underlying device attached prior to open) then why
specify that in the driver flags? Additionally, CLOCAL can be masked out
by the driver's set_termios() method. And then it could implement the
state check in its .carrier_raised() method.
3) The do_clocal snapshot is universally employed by every tty driver. I
don't mean that as some kind of lame excuse. But if this should change,
it should change across every tty driver with a really good reason.
4) Rechecking termios will change the way the user-space open() for this
device behaves. And I need to think more on how that might or might not
be a problem.
5) The code behavior pre-dates the 2005 check-in so I'll probably have
to do some code archaeology.
That's probably going to take some time.
In the meantime, while reviewing that code, I noticed there's a handful
of serious bugs in that one function that I'll send a patchset for.
Plus, someone could be back to me on if and why the driver needs to be
virtually cabled to open().
Regards,
Peter Hurley
next prev parent reply other threads:[~2013-03-04 4:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-03 22:35 [PATCH] ircomm: release tty before sleeping potentially indefintely Sasha Levin
2013-03-03 22:47 ` David Miller
2013-03-03 23:17 ` Sasha Levin
2013-03-04 0:31 ` David Miller
2013-03-04 0:04 ` Peter Hurley
2013-03-04 0:33 ` David Miller
2013-03-04 1:06 ` Peter Hurley
2013-03-04 2:36 ` David Miller
2013-03-04 4:24 ` Peter Hurley [this message]
2013-03-05 16:09 ` [PATCH 0/4] other ircomm_tty fixes (was Re: [PATCH] ircomm: release tty before sleeping potentially indefintely) Peter Hurley
2013-03-05 16:09 ` [PATCH 1/4] net/irda: Fix port open counts Peter Hurley
2013-03-05 16:09 ` [PATCH 2/4] net/irda: Hold port lock while bumping blocked_open Peter Hurley
2013-03-05 16:09 ` [PATCH 3/4] net/irda: Use barrier to set task state Peter Hurley
2013-03-05 16:09 ` [PATCH 4/4] net/irda: Raise dtr in non-blocking open Peter Hurley
2013-03-06 4:44 ` [PATCH 0/4] other ircomm_tty fixes David Miller
2013-03-04 4:30 ` [PATCH] ircomm: release tty before sleeping potentially indefintely Peter Hurley
2013-03-04 2:23 ` Peter Hurley
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=1362371063.3221.185.camel@thor.lan \
--to=peter@hurleysoftware.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=samuel@sortiz.org \
--cc=sasha.levin@oracle.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).