aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-hcd.c2
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/xhci-hub.c8
-rw-r--r--drivers/usb/host/xhci-mem.c3
-rw-r--r--drivers/usb/host/xhci-pci.c9
-rw-r--r--drivers/usb/host/xhci-ring.c104
-rw-r--r--drivers/usb/host/xhci.c15
7 files changed, 71 insertions, 72 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 81cda09b47e3..488a30836c36 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -965,8 +965,6 @@ rescan:
965 } 965 }
966 966
967 qh->exception = 1; 967 qh->exception = 1;
968 if (ehci->rh_state < EHCI_RH_RUNNING)
969 qh->qh_state = QH_STATE_IDLE;
970 switch (qh->qh_state) { 968 switch (qh->qh_state) {
971 case QH_STATE_LINKED: 969 case QH_STATE_LINKED:
972 WARN_ON(!list_empty(&qh->qtd_list)); 970 WARN_ON(!list_empty(&qh->qtd_list));
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index cc305c71ac3d..6130b7574908 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1230,7 +1230,7 @@ int ehci_hub_control(
1230 if (selector == EHSET_TEST_SINGLE_STEP_SET_FEATURE) { 1230 if (selector == EHSET_TEST_SINGLE_STEP_SET_FEATURE) {
1231 spin_unlock_irqrestore(&ehci->lock, flags); 1231 spin_unlock_irqrestore(&ehci->lock, flags);
1232 retval = ehset_single_step_set_feature(hcd, 1232 retval = ehset_single_step_set_feature(hcd,
1233 wIndex); 1233 wIndex + 1);
1234 spin_lock_irqsave(&ehci->lock, flags); 1234 spin_lock_irqsave(&ehci->lock, flags);
1235 break; 1235 break;
1236 } 1236 }
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index aa79e8749040..69aece31143a 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -468,7 +468,8 @@ static void xhci_hub_report_usb2_link_state(u32 *status, u32 status_reg)
468} 468}
469 469
470/* Updates Link Status for super Speed port */ 470/* Updates Link Status for super Speed port */
471static void xhci_hub_report_usb3_link_state(u32 *status, u32 status_reg) 471static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
472 u32 *status, u32 status_reg)
472{ 473{
473 u32 pls = status_reg & PORT_PLS_MASK; 474 u32 pls = status_reg & PORT_PLS_MASK;
474 475
@@ -507,7 +508,8 @@ static void xhci_hub_report_usb3_link_state(u32 *status, u32 status_reg)
507 * in which sometimes the port enters compliance mode 508 * in which sometimes the port enters compliance mode
508 * caused by a delay on the host-device negotiation. 509 * caused by a delay on the host-device negotiation.
509 */ 510 */
510 if (pls == USB_SS_PORT_LS_COMP_MOD) 511 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
512 (pls == USB_SS_PORT_LS_COMP_MOD))
511 pls |= USB_PORT_STAT_CONNECTION; 513 pls |= USB_PORT_STAT_CONNECTION;
512 } 514 }
513 515
@@ -666,7 +668,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
666 } 668 }
667 /* Update Port Link State */ 669 /* Update Port Link State */
668 if (hcd->speed == HCD_USB3) { 670 if (hcd->speed == HCD_USB3) {
669 xhci_hub_report_usb3_link_state(&status, raw_port_status); 671 xhci_hub_report_usb3_link_state(xhci, &status, raw_port_status);
670 /* 672 /*
671 * Verify if all USB3 Ports Have entered U0 already. 673 * Verify if all USB3 Ports Have entered U0 already.
672 * Delete Compliance Mode Timer if so. 674 * Delete Compliance Mode Timer if so.
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 8056d90690ee..8936211b161d 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1812,6 +1812,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1812 1812
1813 if (xhci->lpm_command) 1813 if (xhci->lpm_command)
1814 xhci_free_command(xhci, xhci->lpm_command); 1814 xhci_free_command(xhci, xhci->lpm_command);
1815 xhci->lpm_command = NULL;
1815 if (xhci->cmd_ring) 1816 if (xhci->cmd_ring)
1816 xhci_ring_free(xhci, xhci->cmd_ring); 1817 xhci_ring_free(xhci, xhci->cmd_ring);
1817 xhci->cmd_ring = NULL; 1818 xhci->cmd_ring = NULL;
@@ -1819,7 +1820,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1819 xhci_cleanup_command_queue(xhci); 1820 xhci_cleanup_command_queue(xhci);
1820 1821
1821 num_ports = HCS_MAX_PORTS(xhci->hcs_params1); 1822 num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
1822 for (i = 0; i < num_ports; i++) { 1823 for (i = 0; i < num_ports && xhci->rh_bw; i++) {
1823 struct xhci_interval_bw_table *bwt = &xhci->rh_bw[i].bw_table; 1824 struct xhci_interval_bw_table *bwt = &xhci->rh_bw[i].bw_table;
1824 for (j = 0; j < XHCI_MAX_INTERVAL; j++) { 1825 for (j = 0; j < XHCI_MAX_INTERVAL; j++) {
1825 struct list_head *ep = &bwt->interval_bw[j].endpoints; 1826 struct list_head *ep = &bwt->interval_bw[j].endpoints;
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 687d36608155..c22a3e15a16e 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -101,6 +101,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
101 /* AMD PLL quirk */ 101 /* AMD PLL quirk */
102 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info()) 102 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
103 xhci->quirks |= XHCI_AMD_PLL_FIX; 103 xhci->quirks |= XHCI_AMD_PLL_FIX;
104
105 if (pdev->vendor == PCI_VENDOR_ID_AMD)
106 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
107
104 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { 108 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
105 xhci->quirks |= XHCI_LPM_SUPPORT; 109 xhci->quirks |= XHCI_LPM_SUPPORT;
106 xhci->quirks |= XHCI_INTEL_HOST; 110 xhci->quirks |= XHCI_INTEL_HOST;
@@ -151,6 +155,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
151 if (pdev->vendor == PCI_VENDOR_ID_VIA) 155 if (pdev->vendor == PCI_VENDOR_ID_VIA)
152 xhci->quirks |= XHCI_RESET_ON_RESUME; 156 xhci->quirks |= XHCI_RESET_ON_RESUME;
153 157
158 /* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
159 if (pdev->vendor == PCI_VENDOR_ID_VIA &&
160 pdev->device == 0x3432)
161 xhci->quirks |= XHCI_BROKEN_STREAMS;
162
154 if (xhci->quirks & XHCI_RESET_ON_RESUME) 163 if (xhci->quirks & XHCI_RESET_ON_RESUME)
155 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, 164 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
156 "QUIRK: Resetting on resume"); 165 "QUIRK: Resetting on resume");
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 60fb52ae864b..abed30b82905 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -364,32 +364,6 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
364 } 364 }
365} 365}
366 366
367/*
368 * Find the segment that trb is in. Start searching in start_seg.
369 * If we must move past a segment that has a link TRB with a toggle cycle state
370 * bit set, then we will toggle the value pointed at by cycle_state.
371 */
372static struct xhci_segment *find_trb_seg(
373 struct xhci_segment *start_seg,
374 union xhci_trb *trb, int *cycle_state)
375{
376 struct xhci_segment *cur_seg = start_seg;
377 struct xhci_generic_trb *generic_trb;
378
379 while (cur_seg->trbs > trb ||
380 &cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) {
381 generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT - 1].generic;
382 if (generic_trb->field[3] & cpu_to_le32(LINK_TOGGLE))
383 *cycle_state ^= 0x1;
384 cur_seg = cur_seg->next;
385 if (cur_seg == start_seg)
386 /* Looped over the entire list. Oops! */
387 return NULL;
388 }
389 return cur_seg;
390}
391
392
393static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci, 367static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci,
394 unsigned int slot_id, unsigned int ep_index, 368 unsigned int slot_id, unsigned int ep_index,
395 unsigned int stream_id) 369 unsigned int stream_id)
@@ -459,9 +433,12 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
459 struct xhci_virt_device *dev = xhci->devs[slot_id]; 433 struct xhci_virt_device *dev = xhci->devs[slot_id];
460 struct xhci_virt_ep *ep = &dev->eps[ep_index]; 434 struct xhci_virt_ep *ep = &dev->eps[ep_index];
461 struct xhci_ring *ep_ring; 435 struct xhci_ring *ep_ring;
462 struct xhci_generic_trb *trb; 436 struct xhci_segment *new_seg;
437 union xhci_trb *new_deq;
463 dma_addr_t addr; 438 dma_addr_t addr;
464 u64 hw_dequeue; 439 u64 hw_dequeue;
440 bool cycle_found = false;
441 bool td_last_trb_found = false;
465 442
466 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id, 443 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
467 ep_index, stream_id); 444 ep_index, stream_id);
@@ -486,45 +463,45 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
486 hw_dequeue = le64_to_cpu(ep_ctx->deq); 463 hw_dequeue = le64_to_cpu(ep_ctx->deq);
487 } 464 }
488 465
489 /* Find virtual address and segment of hardware dequeue pointer */ 466 new_seg = ep_ring->deq_seg;
490 state->new_deq_seg = ep_ring->deq_seg; 467 new_deq = ep_ring->dequeue;
491 state->new_deq_ptr = ep_ring->dequeue; 468 state->new_cycle_state = hw_dequeue & 0x1;
492 while (xhci_trb_virt_to_dma(state->new_deq_seg, state->new_deq_ptr) 469
493 != (dma_addr_t)(hw_dequeue & ~0xf)) {
494 next_trb(xhci, ep_ring, &state->new_deq_seg,
495 &state->new_deq_ptr);
496 if (state->new_deq_ptr == ep_ring->dequeue) {
497 WARN_ON(1);
498 return;
499 }
500 }
501 /* 470 /*
502 * Find cycle state for last_trb, starting at old cycle state of 471 * We want to find the pointer, segment and cycle state of the new trb
503 * hw_dequeue. If there is only one segment ring, find_trb_seg() will 472 * (the one after current TD's last_trb). We know the cycle state at
504 * return immediately and cannot toggle the cycle state if this search 473 * hw_dequeue, so walk the ring until both hw_dequeue and last_trb are
505 * wraps around, so add one more toggle manually in that case. 474 * found.
506 */ 475 */
507 state->new_cycle_state = hw_dequeue & 0x1; 476 do {
508 if (ep_ring->first_seg == ep_ring->first_seg->next && 477 if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq)
509 cur_td->last_trb < state->new_deq_ptr) 478 == (dma_addr_t)(hw_dequeue & ~0xf)) {
510 state->new_cycle_state ^= 0x1; 479 cycle_found = true;
480 if (td_last_trb_found)
481 break;
482 }
483 if (new_deq == cur_td->last_trb)
484 td_last_trb_found = true;
511 485
512 state->new_deq_ptr = cur_td->last_trb; 486 if (cycle_found &&
513 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 487 TRB_TYPE_LINK_LE32(new_deq->generic.field[3]) &&
514 "Finding segment containing last TRB in TD."); 488 new_deq->generic.field[3] & cpu_to_le32(LINK_TOGGLE))
515 state->new_deq_seg = find_trb_seg(state->new_deq_seg, 489 state->new_cycle_state ^= 0x1;
516 state->new_deq_ptr, &state->new_cycle_state); 490
517 if (!state->new_deq_seg) { 491 next_trb(xhci, ep_ring, &new_seg, &new_deq);
518 WARN_ON(1); 492
519 return; 493 /* Search wrapped around, bail out */
520 } 494 if (new_deq == ep->ring->dequeue) {
495 xhci_err(xhci, "Error: Failed finding new dequeue state\n");
496 state->new_deq_seg = NULL;
497 state->new_deq_ptr = NULL;
498 return;
499 }
500
501 } while (!cycle_found || !td_last_trb_found);
521 502
522 /* Increment to find next TRB after last_trb. Cycle if appropriate. */ 503 state->new_deq_seg = new_seg;
523 trb = &state->new_deq_ptr->generic; 504 state->new_deq_ptr = new_deq;
524 if (TRB_TYPE_LINK_LE32(trb->field[3]) &&
525 (trb->field[3] & cpu_to_le32(LINK_TOGGLE)))
526 state->new_cycle_state ^= 0x1;
527 next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
528 505
529 /* Don't update the ring cycle state for the producer (us). */ 506 /* Don't update the ring cycle state for the producer (us). */
530 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 507 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
@@ -2487,7 +2464,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2487 * last TRB of the previous TD. The command completion handle 2464 * last TRB of the previous TD. The command completion handle
2488 * will take care the rest. 2465 * will take care the rest.
2489 */ 2466 */
2490 if (!event_seg && trb_comp_code == COMP_STOP_INVAL) { 2467 if (!event_seg && (trb_comp_code == COMP_STOP ||
2468 trb_comp_code == COMP_STOP_INVAL)) {
2491 ret = 0; 2469 ret = 0;
2492 goto cleanup; 2470 goto cleanup;
2493 } 2471 }
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index b6f21175b872..c4a8fca8ae93 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2880,6 +2880,9 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
2880 ep_index, ep->stopped_stream, ep->stopped_td, 2880 ep_index, ep->stopped_stream, ep->stopped_td,
2881 &deq_state); 2881 &deq_state);
2882 2882
2883 if (!deq_state.new_deq_ptr || !deq_state.new_deq_seg)
2884 return;
2885
2883 /* HW with the reset endpoint quirk will use the saved dequeue state to 2886 /* HW with the reset endpoint quirk will use the saved dequeue state to
2884 * issue a configure endpoint command later. 2887 * issue a configure endpoint command later.
2885 */ 2888 */
@@ -3968,13 +3971,21 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
3968 int ret; 3971 int ret;
3969 3972
3970 spin_lock_irqsave(&xhci->lock, flags); 3973 spin_lock_irqsave(&xhci->lock, flags);
3971 if (max_exit_latency == xhci->devs[udev->slot_id]->current_mel) { 3974
3975 virt_dev = xhci->devs[udev->slot_id];
3976
3977 /*
3978 * virt_dev might not exists yet if xHC resumed from hibernate (S4) and
3979 * xHC was re-initialized. Exit latency will be set later after
3980 * hub_port_finish_reset() is done and xhci->devs[] are re-allocated
3981 */
3982
3983 if (!virt_dev || max_exit_latency == virt_dev->current_mel) {
3972 spin_unlock_irqrestore(&xhci->lock, flags); 3984 spin_unlock_irqrestore(&xhci->lock, flags);
3973 return 0; 3985 return 0;
3974 } 3986 }
3975 3987
3976 /* Attempt to issue an Evaluate Context command to change the MEL. */ 3988 /* Attempt to issue an Evaluate Context command to change the MEL. */
3977 virt_dev = xhci->devs[udev->slot_id];
3978 command = xhci->lpm_command; 3989 command = xhci->lpm_command;
3979 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 3990 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx);
3980 if (!ctrl_ctx) { 3991 if (!ctrl_ctx) {