All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org
Subject: Re: [RFC]extension of the anchor API
Date: Thu, 08 Apr 2021 11:23:05 +0200	[thread overview]
Message-ID: <cc44e358406f48175fad9e956369d0f5a07efbe9.camel@suse.com> (raw)
In-Reply-To: <20210325183856.GA799855@rowland.harvard.edu>

Am Donnerstag, den 25.03.2021, 14:38 -0400 schrieb Alan Stern:
> On Thu, Mar 25, 2021 at 05:04:25PM +0100, Oliver Neukum wrote:
> > Am Donnerstag, den 25.03.2021, 11:06 -0400 schrieb Alan Stern:
> > > > +:c:func:`usb_submit_anchored_urbs`
> > > > +---------------------------------
> > > > +
> > > > +The URBs contained in anchor are chronologically submitted until
> > > 
> > > "chronologically" is the wrong word.  They are submitted in the order
> > > of the anchor's list, which is the same as the order that an iterator
> > > would use.
> > 
> > OK. "In the same sequence as they were anchored" ?
> 
> Hmmm.  What happens if you submit an anchor's worth of URBs, but then 
> you kill them in the reverse order (which is how you would normally want 
> to cancel a bunch of URBs)?  Since each URB gets moved to the end of the 
> anchor's list when it completes, after they are all killed the list will 
> be reversed.  So the next time you submit the anchor, the order of URBs 
> will be backward.  If some of the URBs completed before they were 
> killed, the order will be mixed up.

Yes. If the URBs themselves, as opposed to their payloads, are
different, this will happen. Yet I am afraid we are looking at a
necessary race condition here. If you cancel a non-atomic operation,
you will need to deal with all possible intermediate stages of
completion.

> Of course, if you never use the URBs on an anchor after killing it, this 
> doesn't matter.

Yes, to partially solve this issue I wrote
usb_transfer_anchors()
which allows you to separate those URBs you kill (or submit)
by shifting them to another anchor. This is incomplete,
as obviously something you kill may do a transfer.

	Regards
		Oliver



  reply	other threads:[~2021-04-08  9:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 11:03 [RFC]extension of the anchor API Oliver Neukum
2021-03-25 13:48 ` kernel test robot
2021-03-25 15:06 ` Alan Stern
2021-03-25 16:04   ` Oliver Neukum
2021-03-25 18:38     ` Alan Stern
2021-04-08  9:23       ` Oliver Neukum [this message]
2021-04-08 15:07         ` Alan Stern
2021-04-12  9:58           ` Oliver Neukum
2021-04-12 15:06             ` Alan Stern
2021-04-14  8:12               ` Oliver Neukum
2021-04-14 14:56                 ` Alan Stern
2021-04-15 11:23                   ` Oliver Neukum
2021-04-15 15:18                     ` 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=cc44e358406f48175fad9e956369d0f5a07efbe9.camel@suse.com \
    --to=oneukum@suse.com \
    --cc=linux-usb@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.