Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion drivers/usb/host/xhci-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
unsigned int mult;
unsigned int avg_trb_len;
unsigned int err_count = 0;
unsigned int nsegs = 2;

ep_index = xhci_get_endpoint_index(&ep->desc);
ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
Expand All @@ -1455,6 +1456,10 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,

ring_type = usb_endpoint_type(&ep->desc);

if (xhci->quirks & XHCI_VLI_TRB_CACHE_BUG &&
udev->speed != USB_SPEED_SUPER) {
nsegs = 1;
}
/*
* Get values to fill the endpoint context, mostly from ep descriptor.
* The average TRB buffer lengt for bulk endpoints is unclear as we
Expand Down Expand Up @@ -1502,7 +1507,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,

/* Set up the endpoint ring */
virt_dev->eps[ep_index].new_ring =
xhci_ring_alloc(xhci, 2, 1, ring_type, max_packet, mem_flags);
xhci_ring_alloc(xhci, nsegs, 1, ring_type, max_packet, mem_flags);
if (!virt_dev->eps[ep_index].new_ring)
return -ENOMEM;

Expand Down
1 change: 1 addition & 0 deletions drivers/usb/host/xhci-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
xhci->quirks |= XHCI_LPM_SUPPORT;
xhci->quirks |= XHCI_EP_CTX_BROKEN_DCS;
xhci->quirks |= XHCI_AVOID_DQ_ON_LINK;
xhci->quirks |= XHCI_VLI_TRB_CACHE_BUG;
}

if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
Expand Down
6 changes: 6 additions & 0 deletions drivers/usb/host/xhci-ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ static inline int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring,
return 0;

if (ring->type != TYPE_COMMAND && ring->type != TYPE_EVENT) {
/*
* If the ring has a single segment the dequeue segment
* never changes, so don't use it as measure of free space.
*/
if (ring->num_segs == 1)
return ring->num_trbs_free >= num_trbs;
num_trbs_in_deq_seg = ring->dequeue - ring->deq_seg->trbs;
if (ring->num_trbs_free < num_trbs + num_trbs_in_deq_seg)
return 0;
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/host/xhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,7 @@ struct xhci_hcd {
#define XHCI_NO_SOFT_RETRY BIT_ULL(40)
#define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(41)
#define XHCI_AVOID_DQ_ON_LINK BIT_ULL(42)
#define XHCI_VLI_TRB_CACHE_BUG BIT_ULL(43)

unsigned int num_active_eps;
unsigned int limit_active_eps;
Expand Down