aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci-mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/xhci-mem.c')
-rw-r--r--drivers/usb/host/xhci-mem.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index bffcef7a5545..49f7d72f8b1b 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -198,6 +198,31 @@ fail:
198 return 0; 198 return 0;
199} 199}
200 200
201void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci,
202 struct xhci_virt_device *virt_dev,
203 unsigned int ep_index)
204{
205 int rings_cached;
206
207 rings_cached = virt_dev->num_rings_cached;
208 if (rings_cached < XHCI_MAX_RINGS_CACHED) {
209 virt_dev->num_rings_cached++;
210 rings_cached = virt_dev->num_rings_cached;
211 virt_dev->ring_cache[rings_cached] =
212 virt_dev->eps[ep_index].ring;
213 xhci_dbg(xhci, "Cached old ring, "
214 "%d ring%s cached\n",
215 rings_cached,
216 (rings_cached > 1) ? "s" : "");
217 } else {
218 xhci_ring_free(xhci, virt_dev->eps[ep_index].ring);
219 xhci_dbg(xhci, "Ring cache full (%d rings), "
220 "freeing ring\n",
221 virt_dev->num_rings_cached);
222 }
223 virt_dev->eps[ep_index].ring = NULL;
224}
225
201/* Zero an endpoint ring (except for link TRBs) and move the enqueue and dequeue 226/* Zero an endpoint ring (except for link TRBs) and move the enqueue and dequeue
202 * pointers to the beginning of the ring. 227 * pointers to the beginning of the ring.
203 */ 228 */
@@ -242,6 +267,8 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci,
242void xhci_free_container_ctx(struct xhci_hcd *xhci, 267void xhci_free_container_ctx(struct xhci_hcd *xhci,
243 struct xhci_container_ctx *ctx) 268 struct xhci_container_ctx *ctx)
244{ 269{
270 if (!ctx)
271 return;
245 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); 272 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma);
246 kfree(ctx); 273 kfree(ctx);
247} 274}
@@ -427,7 +454,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
427 case USB_SPEED_LOW: 454 case USB_SPEED_LOW:
428 slot_ctx->dev_info |= (u32) SLOT_SPEED_LS; 455 slot_ctx->dev_info |= (u32) SLOT_SPEED_LS;
429 break; 456 break;
430 case USB_SPEED_VARIABLE: 457 case USB_SPEED_WIRELESS:
431 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); 458 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n");
432 return -EINVAL; 459 return -EINVAL;
433 break; 460 break;
@@ -471,7 +498,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
471 case USB_SPEED_LOW: 498 case USB_SPEED_LOW:
472 ep0_ctx->ep_info2 |= MAX_PACKET(8); 499 ep0_ctx->ep_info2 |= MAX_PACKET(8);
473 break; 500 break;
474 case USB_SPEED_VARIABLE: 501 case USB_SPEED_WIRELESS:
475 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); 502 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n");
476 return -EINVAL; 503 return -EINVAL;
477 break; 504 break;
@@ -819,7 +846,8 @@ static void scratchpad_free(struct xhci_hcd *xhci)
819} 846}
820 847
821struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 848struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
822 bool allocate_completion, gfp_t mem_flags) 849 bool allocate_in_ctx, bool allocate_completion,
850 gfp_t mem_flags)
823{ 851{
824 struct xhci_command *command; 852 struct xhci_command *command;
825 853
@@ -827,11 +855,14 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
827 if (!command) 855 if (!command)
828 return NULL; 856 return NULL;
829 857
830 command->in_ctx = 858 if (allocate_in_ctx) {
831 xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, mem_flags); 859 command->in_ctx =
832 if (!command->in_ctx) { 860 xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT,
833 kfree(command); 861 mem_flags);
834 return NULL; 862 if (!command->in_ctx) {
863 kfree(command);
864 return NULL;
865 }
835 } 866 }
836 867
837 if (allocate_completion) { 868 if (allocate_completion) {