xhci: Fix cycle bit calculation during stall handling.
commit24dfb5f904c1478c1ce62f91d654ccc3bfd420dd
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Thu, 24 Feb 2011 02:12:29 +0000 (23 18:12 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 23 Mar 2011 20:03:52 +0000 (23 13:03 -0700)
treea0e877c94d7d020248dff703ad882b29f929e32a
parent5fb7c16628c599f9598ebda9403af1c122f1911e
xhci: Fix cycle bit calculation during stall handling.

commit 01a1fdb9a7afa5e3c14c9316d6f380732750b4e4 upstream.

When an endpoint stalls, we need to update the xHCI host's internal
dequeue pointer to move it past the stalled transfer.  This includes
updating the cycle bit (TRB ownership bit) if we have moved the dequeue
pointer past a link TRB with the toggle cycle bit set.

When we're trying to find the new dequeue segment, find_trb_seg() is
supposed to keep track of whether we've passed any link TRBs with the
toggle cycle bit set.  However, this while loop's body

while (cur_seg->trbs > trb ||
&cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) {

Will never get executed if the ring only contains one segment.
find_trb_seg() will return immediately, without updating the new cycle
bit.  Since find_trb_seg() has no idea where in the segment the TD that
stalled was, make the caller, xhci_find_new_dequeue_state(), check for
this special case and update the cycle bit accordingly.

This patch should be queued to kernels all the way back to 2.6.31.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Tested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/host/xhci-ring.c