USB: EHCI: fix two new bugs related to Clear-TT-Buffer
commita33dc3b8f8d2065a3aa3e874100b7f00713d3825
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 31 Jul 2009 14:40:22 +0000 (31 10:40 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 9 Sep 2009 03:34:02 +0000 (8 20:34 -0700)
treecc7f2a322b05dff24c8ed9ec1d249a7997a376c8
parent6e7b7f694c29fe24c7e51296599027e9bdbce557
USB: EHCI: fix two new bugs related to Clear-TT-Buffer

commit 7a0f0d951273eee889c2441846842348ebc00a2a upstream.

This patch (as1273) fixes two(!) bugs introduced by the new
Clear-TT-Buffer implementation in ehci-hcd.

It is now possible for an idle QH to have some URBs on its
queue -- this will happen if a Clear-TT-Buffer is pending for
the QH's endpoint.  Consequently we should not issue a warning
when someone tries to unlink an URB from an idle QH; instead
we should process the request immediately.

The refcounts for QHs could get messed up, because
submit_async() would increment the refcount when calling
qh_link_async() and qh_link_async() would then refuse to link
the QH into the schedule if a Clear-TT-Buffer was pending.
Instead we should increment the refcount only when the QH
actually is added to the schedule.  The current code tries to
be clever by leaving the refcount alone if an unlink is
immediately followed by a relink; the patch changes this to an
unconditional decrement and increment (although they occur in
the opposite order).

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: David Brownell <david-b@pacbell.net>
Tested-by: Manuel Lauss <manuel.lauss@gmail.com>
Tested-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-q.c