aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci-ring.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/xhci-ring.c')
-rw-r--r--drivers/usb/host/xhci-ring.c68
1 files changed, 10 insertions, 58 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index a0b248c34526..0ed64eb68e48 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -307,13 +307,14 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
307 return 0; 307 return 0;
308 } 308 }
309 309
310 temp_64 = readq(&xhci->op_regs->cmd_ring); 310 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
311 if (!(temp_64 & CMD_RING_RUNNING)) { 311 if (!(temp_64 & CMD_RING_RUNNING)) {
312 xhci_dbg(xhci, "Command ring had been stopped\n"); 312 xhci_dbg(xhci, "Command ring had been stopped\n");
313 return 0; 313 return 0;
314 } 314 }
315 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED; 315 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
316 writeq(temp_64 | CMD_RING_ABORT, &xhci->op_regs->cmd_ring); 316 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
317 &xhci->op_regs->cmd_ring);
317 318
318 /* Section 4.6.1.2 of xHCI 1.0 spec says software should 319 /* Section 4.6.1.2 of xHCI 1.0 spec says software should
319 * time the completion od all xHCI commands, including 320 * time the completion od all xHCI commands, including
@@ -2864,8 +2865,9 @@ hw_died:
2864 /* Clear the event handler busy flag (RW1C); 2865 /* Clear the event handler busy flag (RW1C);
2865 * the event ring should be empty. 2866 * the event ring should be empty.
2866 */ 2867 */
2867 temp_64 = readq(&xhci->ir_set->erst_dequeue); 2868 temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
2868 writeq(temp_64 | ERST_EHB, &xhci->ir_set->erst_dequeue); 2869 xhci_write_64(xhci, temp_64 | ERST_EHB,
2870 &xhci->ir_set->erst_dequeue);
2869 spin_unlock(&xhci->lock); 2871 spin_unlock(&xhci->lock);
2870 2872
2871 return IRQ_HANDLED; 2873 return IRQ_HANDLED;
@@ -2877,7 +2879,7 @@ hw_died:
2877 */ 2879 */
2878 while (xhci_handle_event(xhci) > 0) {} 2880 while (xhci_handle_event(xhci) > 0) {}
2879 2881
2880 temp_64 = readq(&xhci->ir_set->erst_dequeue); 2882 temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
2881 /* If necessary, update the HW's version of the event ring deq ptr. */ 2883 /* If necessary, update the HW's version of the event ring deq ptr. */
2882 if (event_ring_deq != xhci->event_ring->dequeue) { 2884 if (event_ring_deq != xhci->event_ring->dequeue) {
2883 deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, 2885 deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg,
@@ -2892,7 +2894,7 @@ hw_died:
2892 2894
2893 /* Clear the event handler busy flag (RW1C); event ring is empty. */ 2895 /* Clear the event handler busy flag (RW1C); event ring is empty. */
2894 temp_64 |= ERST_EHB; 2896 temp_64 |= ERST_EHB;
2895 writeq(temp_64, &xhci->ir_set->erst_dequeue); 2897 xhci_write_64(xhci, temp_64, &xhci->ir_set->erst_dequeue);
2896 2898
2897 spin_unlock(&xhci->lock); 2899 spin_unlock(&xhci->lock);
2898 2900
@@ -2965,58 +2967,8 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
2965 } 2967 }
2966 2968
2967 while (1) { 2969 while (1) {
2968 if (room_on_ring(xhci, ep_ring, num_trbs)) { 2970 if (room_on_ring(xhci, ep_ring, num_trbs))
2969 union xhci_trb *trb = ep_ring->enqueue; 2971 break;
2970 unsigned int usable = ep_ring->enq_seg->trbs +
2971 TRBS_PER_SEGMENT - 1 - trb;
2972 u32 nop_cmd;
2973
2974 /*
2975 * Section 4.11.7.1 TD Fragments states that a link
2976 * TRB must only occur at the boundary between
2977 * data bursts (eg 512 bytes for 480M).
2978 * While it is possible to split a large fragment
2979 * we don't know the size yet.
2980 * Simplest solution is to fill the trb before the
2981 * LINK with nop commands.
2982 */
2983 if (num_trbs == 1 || num_trbs <= usable || usable == 0)
2984 break;
2985
2986 if (ep_ring->type != TYPE_BULK)
2987 /*
2988 * While isoc transfers might have a buffer that
2989 * crosses a 64k boundary it is unlikely.
2990 * Since we can't add NOPs without generating
2991 * gaps in the traffic just hope it never
2992 * happens at the end of the ring.
2993 * This could be fixed by writing a LINK TRB
2994 * instead of the first NOP - however the
2995 * TRB_TYPE_LINK_LE32() calls would all need
2996 * changing to check the ring length.
2997 */
2998 break;
2999
3000 if (num_trbs >= TRBS_PER_SEGMENT) {
3001 xhci_err(xhci, "Too many fragments %d, max %d\n",
3002 num_trbs, TRBS_PER_SEGMENT - 1);
3003 return -EINVAL;
3004 }
3005
3006 nop_cmd = cpu_to_le32(TRB_TYPE(TRB_TR_NOOP) |
3007 ep_ring->cycle_state);
3008 ep_ring->num_trbs_free -= usable;
3009 do {
3010 trb->generic.field[0] = 0;
3011 trb->generic.field[1] = 0;
3012 trb->generic.field[2] = 0;
3013 trb->generic.field[3] = nop_cmd;
3014 trb++;
3015 } while (--usable);
3016 ep_ring->enqueue = trb;
3017 if (room_on_ring(xhci, ep_ring, num_trbs))
3018 break;
3019 }
3020 2972
3021 if (ep_ring == xhci->cmd_ring) { 2973 if (ep_ring == xhci->cmd_ring) {
3022 xhci_err(xhci, "Do not support expand command ring\n"); 2974 xhci_err(xhci, "Do not support expand command ring\n");