diff options
author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2010-07-09 11:08:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-07-26 15:00:58 -0400 |
commit | d1dc908a251c8cd87c1a1ad4f2c4a40cdbd8286c (patch) | |
tree | 3f2b42d53b514823649d1343e8d77fdc8dda60bc /drivers/usb | |
parent | 7595931c986f50b1e197ce7b881563e36a7d041e (diff) |
USB: xHCI: Fix another bug in link TRB activation change.
Commit 6c12db90f19727c76990e7f4801c67a148b30111 also seems to have
introduced a bug that is triggered when the command ring is about to wrap.
The inc_enq() function will not have moved the enqueue pointer past the
link TRB. It is supposed to be moved past the link TRB in prepare_ring(),
which should be called before a TD is enqueued. However, the
queue_command() function never calls the prepare_ring() function because
prepare_ring() is only supposed to be used for endpoint rings. That means
the enqueue pointer will not be moved past the link TRB, and will get
overwritten.
The fix is to make queue_command() call prepare_ring() with a fake
endpoint status (set to running). Then the enqueue pointer will get moved
past the link TRB.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 94e6934edb09..bfc99a939455 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -2380,16 +2380,19 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2, | |||
2380 | u32 field3, u32 field4, bool command_must_succeed) | 2380 | u32 field3, u32 field4, bool command_must_succeed) |
2381 | { | 2381 | { |
2382 | int reserved_trbs = xhci->cmd_ring_reserved_trbs; | 2382 | int reserved_trbs = xhci->cmd_ring_reserved_trbs; |
2383 | int ret; | ||
2384 | |||
2383 | if (!command_must_succeed) | 2385 | if (!command_must_succeed) |
2384 | reserved_trbs++; | 2386 | reserved_trbs++; |
2385 | 2387 | ||
2386 | if (!room_on_ring(xhci, xhci->cmd_ring, reserved_trbs)) { | 2388 | ret = prepare_ring(xhci, xhci->cmd_ring, EP_STATE_RUNNING, |
2387 | if (!in_interrupt()) | 2389 | reserved_trbs, GFP_ATOMIC); |
2388 | xhci_err(xhci, "ERR: No room for command on command ring\n"); | 2390 | if (ret < 0) { |
2391 | xhci_err(xhci, "ERR: No room for command on command ring\n"); | ||
2389 | if (command_must_succeed) | 2392 | if (command_must_succeed) |
2390 | xhci_err(xhci, "ERR: Reserved TRB counting for " | 2393 | xhci_err(xhci, "ERR: Reserved TRB counting for " |
2391 | "unfailable commands failed.\n"); | 2394 | "unfailable commands failed.\n"); |
2392 | return -ENOMEM; | 2395 | return ret; |
2393 | } | 2396 | } |
2394 | queue_trb(xhci, xhci->cmd_ring, false, false, field1, field2, field3, | 2397 | queue_trb(xhci, xhci->cmd_ring, false, false, field1, field2, field3, |
2395 | field4 | xhci->cmd_ring->cycle_state); | 2398 | field4 | xhci->cmd_ring->cycle_state); |