Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 190457
b: refs/heads/master
c: 9238f25
h: refs/heads/master
i:
  190455: 4585a6d
v: v3
  • Loading branch information
Sarah Sharp authored and Greg Kroah-Hartman committed Apr 30, 2010
1 parent a4a33ae commit 7cce438
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1cf62246c0e394021e494e0a8f1013e80db1a1a9
refs/heads/master: 9238f25d5d32a435277eb234ec82bacdd5daed41
51 changes: 51 additions & 0 deletions trunk/drivers/usb/host/xhci-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,36 @@ static inline u32 xhci_get_endpoint_type(struct usb_device *udev,
return type;
}

/* Return the maximum endpoint service interval time (ESIT) payload.
* Basically, this is the maxpacket size, multiplied by the burst size
* and mult size.
*/
static inline u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
struct usb_device *udev,
struct usb_host_endpoint *ep)
{
int max_burst;
int max_packet;

/* Only applies for interrupt or isochronous endpoints */
if (usb_endpoint_xfer_control(&ep->desc) ||
usb_endpoint_xfer_bulk(&ep->desc))
return 0;

if (udev->speed == USB_SPEED_SUPER) {
if (ep->ss_ep_comp)
return ep->ss_ep_comp->desc.wBytesPerInterval;
xhci_warn(xhci, "WARN no SS endpoint companion descriptor.\n");
/* Assume no bursts, no multiple opportunities to send. */
return ep->desc.wMaxPacketSize;
}

max_packet = ep->desc.wMaxPacketSize & 0x3ff;
max_burst = (ep->desc.wMaxPacketSize & 0x1800) >> 11;
/* A 0 in max burst means 1 transfer per ESIT */
return max_packet * (max_burst + 1);
}

int xhci_endpoint_init(struct xhci_hcd *xhci,
struct xhci_virt_device *virt_dev,
struct usb_device *udev,
Expand All @@ -636,6 +666,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
struct xhci_ring *ep_ring;
unsigned int max_packet;
unsigned int max_burst;
u32 max_esit_payload;

ep_index = xhci_get_endpoint_index(&ep->desc);
ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
Expand Down Expand Up @@ -703,6 +734,26 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
default:
BUG();
}
max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep);
ep_ctx->tx_info = MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload);

/*
* XXX no idea how to calculate the average TRB buffer length for bulk
* endpoints, as the driver gives us no clue how big each scatter gather
* list entry (or buffer) is going to be.
*
* For isochronous and interrupt endpoints, we set it to the max
* available, until we have new API in the USB core to allow drivers to
* declare how much bandwidth they actually need.
*
* Normally, it would be calculated by taking the total of the buffer
* lengths in the TD and then dividing by the number of TRBs in a TD,
* including link TRBs, No-op TRBs, and Event data TRBs. Since we don't
* use Event Data TRBs, and we don't chain in a link TRB on short
* transfers, we're basically dividing by 1.
*/
ep_ctx->tx_info |= AVG_TRB_LENGTH_FOR_EP(max_esit_payload);

/* FIXME Debug endpoint context */
return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/usb/host/xhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,10 @@ struct xhci_ep_ctx {
#define MAX_PACKET_MASK (0xffff << 16)
#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff)

/* tx_info bitmasks */
#define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff)
#define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16)


/**
* struct xhci_input_control_context
Expand Down

0 comments on commit 7cce438

Please sign in to comment.