aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2011-02-23 21:12:29 -0500
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2011-03-13 21:23:54 -0400
commit01a1fdb9a7afa5e3c14c9316d6f380732750b4e4 (patch)
treea8a27f453ca6ce5e5919f77a51368020887f5674 /drivers/usb
parentbf161e85fb153c0dd5a95faca73fd6a9d237c389 (diff)
xhci: Fix cycle bit calculation during stall handling.
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> Cc: stable@kernel.org
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/xhci-ring.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 3577cd663ebc..cf86eb70a62e 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -495,6 +495,20 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
495 state->new_cycle_state = ~(state->new_cycle_state) & 0x1; 495 state->new_cycle_state = ~(state->new_cycle_state) & 0x1;
496 next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr); 496 next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
497 497
498 /*
499 * If there is only one segment in a ring, find_trb_seg()'s while loop
500 * will not run, and it will return before it has a chance to see if it
501 * needs to toggle the cycle bit. It can't tell if the stalled transfer
502 * ended just before the link TRB on a one-segment ring, or if the TD
503 * wrapped around the top of the ring, because it doesn't have the TD in
504 * question. Look for the one-segment case where stalled TRB's address
505 * is greater than the new dequeue pointer address.
506 */
507 if (ep_ring->first_seg == ep_ring->first_seg->next &&
508 state->new_deq_ptr < dev->eps[ep_index].stopped_trb)
509 state->new_cycle_state ^= 0x1;
510 xhci_dbg(xhci, "Cycle state = 0x%x\n", state->new_cycle_state);
511
498 /* Don't update the ring cycle state for the producer (us). */ 512 /* Don't update the ring cycle state for the producer (us). */
499 xhci_dbg(xhci, "New dequeue segment = %p (virtual)\n", 513 xhci_dbg(xhci, "New dequeue segment = %p (virtual)\n",
500 state->new_deq_seg); 514 state->new_deq_seg);