USB: OHCI: don't lose track of EDs when a controller dies
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 17 Jul 2014 20:34:29 +0000 (16:34 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 13 Sep 2014 22:41:38 +0000 (23:41 +0100)
commitbb013738fb8a73670c11ccc31ce0180d99b6c335
tree0cc2d62163e859e58735aa713e294c3db441d17f
parent85cf47369ef88ad59ba03a41c5519342a7a079fe
USB: OHCI: don't lose track of EDs when a controller dies

commit 977dcfdc60311e7aa571cabf6f39c36dde13339e upstream.

This patch fixes a bug in ohci-hcd.  When an URB is unlinked, the
corresponding Endpoint Descriptor is added to the ed_rm_list and taken
off the hardware schedule.  Once the ED is no longer visible to the
hardware, finish_unlinks() handles the URBs that were unlinked or have
completed.  If any URBs remain attached to the ED, the ED is added
back to the hardware schedule -- but only if the controller is
running.

This fails when a controller dies.  A non-empty ED does not get added
back to the hardware schedule and does not remain on the ed_rm_list;
ohci-hcd loses track of it.  The remaining URBs cannot be unlinked,
which causes the USB stack to hang.

The patch changes finish_unlinks() so that non-empty EDs remain on
the ed_rm_list if the controller isn't running.  This requires moving
some of the existing code around, to avoid modifying the ED's hardware
fields more than once.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: keep using HC_IS_RUNNING()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/host/ohci-q.c