From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Bruno Prémont" <bonbons@linux-vserver.org>,
"Greg KH" <greg@kroah.com>,
"Kernel development list" <linux-kernel@vger.kernel.org>,
"USB list" <linux-usb@vger.kernel.org>,
"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: 2.6.31-rc5 regression: Oops when USB Serial disconnected while in use
Date: Fri, 21 Aug 2009 19:42:52 +0100 [thread overview]
Message-ID: <20090821194252.582ef5cd@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0908211326120.4029-100000@iolanthe.rowland.org>
> Then surely serial_open() should call serial->type->open() _after_
> tty_port_block_til_ready(), not before.
It needs the hardware active and running to do the block_til_ready
> Now the second user tries to do stuff but the hardware isn't ready.
> Instead this should go:
>
> serial_open() /* first user */
> tty_port_block_til_ready() /* returns immediately */
> serial->type->open() /* initializes the hardware */
>
> serial_open() /* second user */
> tty_port_block_til_ready() /* blocks */
If the first user succeeded then second should open immediately as the use
count is >= 1 already. It is re-opening the open device, unless the
hangup occurs first.
>
> serial_hangup() /* first connection drops */
> serial_do_down()
> serial->type-close() /* resets the hardware */
>
> ... tty_port_block_til_ready() returns
> serial->type->open() /* not skipped */
>
> Now the second user can proceed to use the hardware. Or have I
> misunderstood how this is intended to work?
Usual paths
open
block_til_ready
open returns 0
do stuff
close
open
block_til_ready
open returns 0
do stuff
hangup (closes hw side)
further stuff errors
close (does nothing to the hw side tty_port_close knows about
this)
open
block_til_ready
hangup
open returns error
close path called - knows about hangup in tty_close_port
Hence the reason it always calls the close path to cleanup hardware and
other resources even if open returns an error
>
> Alan Stern
>
> P.S.: Can you explain the reason why tty_port and tty_struct are two
> separate structures? Isn't the same port always associated with the
> same tty?
The tty structure is the virtual interface side, the tty_port is the
hardware device. Historically the port side varied randomly by device
preventing any commonality being extracted into helpers.
For most hardware the tty_port lifetime is the physical port lifetime,
the tty lifetime is open->final close (or a final kref drop afterwards)
It also means eventually that we can have a tty_port and things hung off
it for all hardware which means
- Most of the locking costs for receiving v hangup go away (as you
queue to the tty_port not the tty - ie move the tty_buffer struct)
- It becomes possible to have a proper generic console/debug console
without hacks and fake tty devices.
Most drivers tend to look like
open
test ASYNC_INITIALIZED
init hardware
[either in full or clean up partial]
set ASYNC_INITIALIZED)
any other alloc/counter magic
tty->private_data = my stuff
block_til_ready
return ok/error
close
if (hung_up)
return
if (tty->driver_data == NULL)
return
counts
clean up resources
if (last && test_clear INITIALIZED)
deinit-hardware
return ok/error
hangup
if (initialized & test_clear INITIALIZED) {
deinit hardware
}
which is where I was trying to get the USB code.
next prev parent reply other threads:[~2009-08-21 18:42 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-08 17:47 Bruno Prémont
2009-08-09 14:02 ` Ozan Çağlayan
2009-08-09 15:00 ` Alan Stern
2009-08-10 15:18 ` Alan Stern
2009-08-10 15:44 ` Greg KH
2009-08-10 17:18 ` Bruno Prémont
2009-08-10 18:13 ` Greg KH
2009-08-10 18:35 ` Bruno Prémont
2009-08-10 18:51 ` Bruno Prémont
2009-08-10 19:29 ` Greg KH
2009-08-18 17:00 ` Bruno Prémont
2009-08-18 22:36 ` Greg KH
2009-08-18 23:16 ` Greg KH
2009-08-19 17:22 ` Bruno Prémont
2009-08-19 18:20 ` Alan Stern
2009-08-19 20:15 ` Bruno Prémont
2009-08-19 21:01 ` Alan Stern
2009-08-19 21:50 ` Alan Cox
2009-08-19 22:44 ` Alan Stern
2009-08-20 19:25 ` Bruno Prémont
2009-08-20 21:20 ` Alan Stern
2009-08-21 9:25 ` Bruno Prémont
2009-08-21 15:43 ` Alan Stern
2009-08-21 15:48 ` Alan Cox
2009-08-21 17:39 ` Alan Stern
2009-08-21 18:42 ` Alan Cox [this message]
2009-08-21 20:52 ` Alan Stern
2009-08-21 23:16 ` Alan Cox
2009-08-22 2:30 ` Alan Stern
2009-08-23 2:51 ` Alan Stern
2009-08-23 16:15 ` Alan Stern
2009-08-23 16:30 ` Bruno Prémont
2009-08-24 1:24 ` Alan Stern
2009-08-24 20:15 ` Bruno Prémont
2009-08-25 1:42 ` Alan Stern
2009-08-25 20:19 ` Bruno Prémont
2009-08-25 23:42 ` Alan Stern
2009-08-26 20:32 ` Bruno Prémont
2009-08-27 2:19 ` Alan Stern
2009-08-21 16:50 ` Bruno Prémont
2009-08-20 21:58 ` Alan Cox
2009-08-21 14:02 ` 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=20090821194252.582ef5cd@lxorguk.ukuu.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=bonbons@linux-vserver.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=stern@rowland.harvard.edu \
/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
all inboxes | Powered by JetHome®