aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2011-04-19 20:43:33 -0400
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2011-05-02 19:42:56 -0400
commitb61d378f2da41c748aba6ca19d77e1e1c02bcea5 (patch)
treeefb1541eefb32e57bf619a8bd85748a31b283031
parent5cd43e33b9519143f06f507dd7cbee6b7a621885 (diff)
xhci 1.0: Set transfer burst last packet count field.
The xHCI 1.0 specification defines a new isochronous TRB field, called transfer burst last packet count (TBLPC). This field defines the number of packets in the last "burst" of packets in a TD. Only SuperSpeed endpoints can handle more than one burst, so this is set to the number for packets in a TD for all non-SuperSpeed devices (minus one, since the field is zero based). This patch should have no effect on host controllers that don't advertise the xHCI 1.0 (0x100) version number in their hci_version field. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
-rw-r--r--drivers/usb/host/xhci-ring.c41
-rw-r--r--drivers/usb/host/xhci.h1
2 files changed, 41 insertions, 1 deletions
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index cc5963263a65..396f8d2a2e8d 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3144,6 +3144,42 @@ static unsigned int xhci_get_burst_count(struct xhci_hcd *xhci,
3144 return roundup(total_packet_count, max_burst + 1) - 1; 3144 return roundup(total_packet_count, max_burst + 1) - 1;
3145} 3145}
3146 3146
3147/*
3148 * Returns the number of packets in the last "burst" of packets. This field is
3149 * valid for all speeds of devices. USB 2.0 devices can only do one "burst", so
3150 * the last burst packet count is equal to the total number of packets in the
3151 * TD. SuperSpeed endpoints can have up to 3 bursts. All but the last burst
3152 * must contain (bMaxBurst + 1) number of packets, but the last burst can
3153 * contain 1 to (bMaxBurst + 1) packets.
3154 */
3155static unsigned int xhci_get_last_burst_packet_count(struct xhci_hcd *xhci,
3156 struct usb_device *udev,
3157 struct urb *urb, unsigned int total_packet_count)
3158{
3159 unsigned int max_burst;
3160 unsigned int residue;
3161
3162 if (xhci->hci_version < 0x100)
3163 return 0;
3164
3165 switch (udev->speed) {
3166 case USB_SPEED_SUPER:
3167 /* bMaxBurst is zero based: 0 means 1 packet per burst */
3168 max_burst = urb->ep->ss_ep_comp.bMaxBurst;
3169 residue = total_packet_count % (max_burst + 1);
3170 /* If residue is zero, the last burst contains (max_burst + 1)
3171 * number of packets, but the TLBPC field is zero-based.
3172 */
3173 if (residue == 0)
3174 return max_burst;
3175 return residue - 1;
3176 default:
3177 if (total_packet_count == 0)
3178 return 0;
3179 return total_packet_count - 1;
3180 }
3181}
3182
3147/* This is for isoc transfer */ 3183/* This is for isoc transfer */
3148static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, 3184static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3149 struct urb *urb, int slot_id, unsigned int ep_index) 3185 struct urb *urb, int slot_id, unsigned int ep_index)
@@ -3186,6 +3222,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3186 for (i = 0; i < num_tds; i++) { 3222 for (i = 0; i < num_tds; i++) {
3187 unsigned int total_packet_count; 3223 unsigned int total_packet_count;
3188 unsigned int burst_count; 3224 unsigned int burst_count;
3225 unsigned int residue;
3189 3226
3190 first_trb = true; 3227 first_trb = true;
3191 running_total = 0; 3228 running_total = 0;
@@ -3197,6 +3234,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3197 le16_to_cpu(urb->ep->desc.wMaxPacketSize)); 3234 le16_to_cpu(urb->ep->desc.wMaxPacketSize));
3198 burst_count = xhci_get_burst_count(xhci, urb->dev, urb, 3235 burst_count = xhci_get_burst_count(xhci, urb->dev, urb,
3199 total_packet_count); 3236 total_packet_count);
3237 residue = xhci_get_last_burst_packet_count(xhci,
3238 urb->dev, urb, total_packet_count);
3200 3239
3201 trbs_per_td = count_isoc_trbs_needed(xhci, urb, i); 3240 trbs_per_td = count_isoc_trbs_needed(xhci, urb, i);
3202 3241
@@ -3210,7 +3249,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3210 3249
3211 for (j = 0; j < trbs_per_td; j++) { 3250 for (j = 0; j < trbs_per_td; j++) {
3212 u32 remainder = 0; 3251 u32 remainder = 0;
3213 field = TRB_TBC(burst_count); 3252 field = TRB_TBC(burst_count) | TRB_TLBPC(residue);
3214 3253
3215 if (first_trb) { 3254 if (first_trb) {
3216 /* Queue the isoc TRB */ 3255 /* Queue the isoc TRB */
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 87ec3b079728..db661543a805 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -944,6 +944,7 @@ struct xhci_event_cmd {
944#define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22) 944#define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22)
945#define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff) 945#define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff)
946#define TRB_TBC(p) (((p) & 0x3) << 7) 946#define TRB_TBC(p) (((p) & 0x3) << 7)
947#define TRB_TLBPC(p) (((p) & 0xf) << 16)
947 948
948/* Cycle bit - indicates TRB ownership by HC or HCD */ 949/* Cycle bit - indicates TRB ownership by HC or HCD */
949#define TRB_CYCLE (1<<0) 950#define TRB_CYCLE (1<<0)