public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Harald Welte <laforge@gnumonks.org>
Cc: linux-usb-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [linux-usb-devel] Re: [BUG] oops while completing async USB via usbdevio
Date: Tue, 31 May 2005 11:53:24 -0700	[thread overview]
Message-ID: <200505311153.24747.david-b@pacbell.net> (raw)
In-Reply-To: <20050531084852.GJ25536@sunbeam.de.gnumonks.org>

On Tuesday 31 May 2005 1:48 am, Harald Welte wrote:
> On Mon, May 30, 2005 at 03:55:39PM -0700, David Brownell wrote:
> 
> > The logic closing an open usbfs file -- which is done before any task
> > exits with such an open file -- is supposed to block till all its URBs
> > complete.  So the pointer to the task "should" be valid for as long as
> > any URB it's submitted is active.
> 
> unfortunately it doesn't seem to cover the fork() case, see below.

OK, so it seems this is a moderately deep broken assumption in usbfs.


> > Not that it helps at all, but I've never really trusted the usbfs async
> > I/O code.  "Real AIO" could be a lot more obviously correct.  And smaller.
> 
> mh, but nobody has written AIO-enabled usbfs2  yet ;)

I'm still hoping that one of the folk who want make an interesting and
useful contribution to Linux will take the hint.  It goes slowly. :)


Right now I think a "usbfs 1.5" would be the simplest way to deliver
it ... an ioctl that returns a new per-endpoint file descriptor.  It'd
need to support the AIO calls and a bit more ... and that could be the
guts of a "usbfs2".  The "gadgetfs" code shows how small that part
could be ... and later, some libfs based code could do all the fun
stuff, creating a real "usbfs2" that exports normal per-endpoint files
and so on.  Then we could deprecate the current AIO stuff...


> meanwhile, the current usbfs aio handling is the only way how to deal
> with delivery of interrupt pipe URB's to userspace drivers.

Other than tying up the file descriptor with a blocking read, that is.


> However, __exit_files() only calls close_files() if files->count goes
> down to zero. What if the process fork()ed before, and the other half of
> the fork still has a refcount?  -> boom.
> 
> It seems to me that the whole usbdevio async handling doesn't really
> cope with a lot of the unix semantics, such as fork() or file descriptor
> passing.

*cough* usbfs2 aio *cough*


> Wouldn't it help to associate the URB with the file (instaed of the
> task), and then send the signal to any task that still has opened the
> file?  I'm willing to hack up a patch, if this is considered a sane fix.

Sounds reasonable, except that not all such tasks will want the signal.
Though I guess the infrastructure to filter the signal out already exists,
so the main missing piece is that urb-to-file binding.

- Dave


  parent reply	other threads:[~2005-05-31 19:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-30 19:44 [BUG] oops while completing async USB via usbdevio Harald Welte
2005-05-30 21:26 ` Harald Welte
2005-05-30 22:55   ` [linux-usb-devel] " David Brownell
2005-05-30 23:09     ` Oliver Neukum
2005-05-30 23:12       ` David Brownell
2005-05-31  8:04       ` Harald Welte
2005-05-31  8:48     ` Harald Welte
2005-05-31 11:45       ` Oliver Neukum
2005-05-31 18:53       ` David Brownell [this message]
2005-05-31 22:12         ` Harald Welte
2005-06-06 16:05           ` Harald Welte
2005-06-06 16:24             ` Alan Stern
2005-06-06 16:50               ` Harald Welte
2005-05-30 23:07   ` Oliver Neukum
2005-05-31  8:06     ` Harald Welte

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=200505311153.24747.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=laforge@gnumonks.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    /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