linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ming.lei@canonical.com (Ming Lei)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v1 5/6] USB: EHCI: improve interrupt qh unlink
Date: Wed, 19 Jun 2013 11:36:31 +0800	[thread overview]
Message-ID: <CACVXFVOMDbWRWErkF5iDqtsJVBwD4B4fn22ZR1vupb78bKoDiQ@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1306181246140.1157-100000@iolanthe.rowland.org>

On Wed, Jun 19, 2013 at 12:51 AM, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Tue, 18 Jun 2013, Ming Lei wrote:
>
>> Given interrupt URB will be resubmitted from tasklet context which
>> is scheduled by ehci hardware interrupt handler, and commonly only
>> one interrupt URB is scheduled on qh, so the qh may be unlinked
>> immediately once qh_completions() returns from ehci_irq(), then
>> the intr URB to be resubmitted in complete() can only be scheduled
>> and linked to hardware until the qh unlink is completed.
>>
>> This patch applied the QH_STATE_UNLINK_WAIT(not used by interrupt qh)
>> state to improve this above situation, and the qh will wait for 5
>> milliseconds before being unlinked from hardware, if one URB is submitted
>> during the period, the qh is move out of unlink wait state and the
>> interrupt transfer can be scheduled immediately, not like before: the
>> transfer is only linked to hardware until previous unlink is completed.
>>
>> Only enable the improvement in case that HCD supports to run
>> giveback of URB in tasklet context.
>
> The approach used in this patch is wrong.  You shouldn't start the
> unlink, then wait, then finish the unlink.  Consider what would happen

What you mentioned above is just what the patch is doing, :-)

start_unlink_intr() only sets the qh as QH_STATE_UNLINK_WAIT, puts
the qh into one wait list and starts a timer, if it is expired the qh will be
started to unlink, otherwise the qh can be recovered to QH_STATE_LINKED
immediately if there is one URB submitted.

So unlinking intr qh becomes a 3-stage process:

       - wait(qh return to linked state if URB is submitted during the period,
                  otherwise go to start unlink)
       - start unlink(do unlink, and wait for end of unlink)
       - end unlink

> if an URB were submitted during the delay: It would have to wait until

If an URB were submitted during the delay, the previous wait is canceled
immediately, and the qh state is recovered to linked state, please see
cancel_unlink_wait_intr() called in intr_submit().

> the QH was completely unlinked.  Instead, you should wait first, then
> do the entire unlink.

Yes, it is just what the patch is doing, :-)

>
> For example, scan_async() in ehci-q.c doesn't immediately begin to
> unlink empty async QHs.  It merely marks them as being empty and starts
> a timer to check them later.  It they are still empty at that point,
> then they are unlinked.

Yes, the patch starts to use QH_STATE_UNLINK_WAIT state for intr qh,
and previously the state is only used by async qh.

>
> Also, it's silly to check whether or not giveback uses a tasklet.  We
> know that following the 6/6 patch it will.  Even if it doesn't, there's
> no harm in waiting a little while before unlinking an empty interrupt
> QH.

It is still for the test reason, since the patch may cause recursion if
HCD_BH isn't set.

Thanks,
--
Ming Lei

  reply	other threads:[~2013-06-19  3:36 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 15:03 [RFC PATCH v1 0/6] USB: HCD/EHCI: giveback of URB in tasklet context Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 1/6] USB: HCD: support " Ming Lei
2013-06-18 16:05   ` Alan Stern
2013-06-19  2:59     ` Ming Lei
2013-06-19 11:50       ` Ming Lei
2013-06-19 15:37       ` Alan Stern
2013-06-20  1:50         ` Ming Lei
2013-06-20 14:59           ` Alan Stern
2013-06-20 15:13             ` Ming Lei
2013-06-20 16:52               ` Alan Stern
2013-06-21  1:12                 ` Ming Lei
2013-06-21  4:46                   ` Ming Lei
2013-06-21  5:13                     ` Ming Lei
2013-06-21  8:33                   ` Oliver Neukum
2013-06-21  9:13                     ` Ming Lei
2013-06-21  9:20                       ` Oliver Neukum
2013-06-21  9:43                         ` Ming Lei
2013-06-21 10:09                           ` Ming Lei
2013-06-21 14:48                           ` Alan Stern
2013-06-21 16:12                             ` Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 2/6] USB: disable IRQs deliberately when calling complete() Ming Lei
2013-06-18 15:13   ` Sergei Shtylyov
2013-06-18 16:36   ` Alan Stern
2013-06-19  3:02     ` Ming Lei
2013-06-19 15:30       ` Alan Stern
2013-06-18 15:03 ` [RFC PATCH v1 3/6] USB: URB documentation: claim complete() may be run with IRQs enabled Ming Lei
2013-06-18 16:42   ` Alan Stern
2013-06-19  3:06     ` Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 4/6] USB: EHCI: don't release ehci->lock if URB giveback in tasklet context Ming Lei
2013-06-18 16:43   ` Alan Stern
2013-06-19  3:13     ` Ming Lei
2013-06-19 15:47       ` Alan Stern
2013-06-20  1:53         ` Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 5/6] USB: EHCI: improve interrupt qh unlink Ming Lei
2013-06-18 16:51   ` Alan Stern
2013-06-19  3:36     ` Ming Lei [this message]
2013-06-19 15:44       ` Alan Stern
2013-06-20  6:05         ` Ming Lei
2013-06-21 20:16           ` Alan Stern
2013-06-24  4:55             ` Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 6/6] USB: EHCI: support running URB giveback in tasklet context Ming Lei
2013-06-18 16:55   ` Alan Stern
2013-06-19  3:39     ` Ming Lei

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=CACVXFVOMDbWRWErkF5iDqtsJVBwD4B4fn22ZR1vupb78bKoDiQ@mail.gmail.com \
    --to=ming.lei@canonical.com \
    --cc=linux-arm-kernel@lists.infradead.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).