• Home
  • Raw
  • Download

Lines Matching full:xhci

3  * xHCI host controller driver
17 #include "xhci.h"
18 #include "xhci-trace.h"
19 #include "xhci-debugfs.h"
28 static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, in xhci_segment_alloc() argument
36 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_segment_alloc()
42 seg->trbs = dma_pool_zalloc(xhci->segment_pool, flags, &dma); in xhci_segment_alloc()
52 dma_pool_free(xhci->segment_pool, seg->trbs, dma); in xhci_segment_alloc()
68 static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg) in xhci_segment_free() argument
71 dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma); in xhci_segment_free()
78 static void xhci_free_segments_for_ring(struct xhci_hcd *xhci, in xhci_free_segments_for_ring() argument
86 xhci_segment_free(xhci, seg); in xhci_free_segments_for_ring()
89 xhci_segment_free(xhci, first); in xhci_free_segments_for_ring()
126 static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, in xhci_link_rings() argument
137 chain_links = !!(xhci_link_trb_quirk(xhci) || in xhci_link_rings()
139 (xhci->quirks & XHCI_AMD_0x96_HOST))); in xhci_link_rings()
280 void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) in xhci_ring_free() argument
290 xhci_free_segments_for_ring(xhci, ring->first_seg); in xhci_ring_free()
321 static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, in xhci_alloc_segments_for_ring() argument
330 chain_links = !!(xhci_link_trb_quirk(xhci) || in xhci_alloc_segments_for_ring()
332 (xhci->quirks & XHCI_AMD_0x96_HOST))); in xhci_alloc_segments_for_ring()
334 prev = xhci_segment_alloc(xhci, cycle_state, max_packet, flags); in xhci_alloc_segments_for_ring()
343 next = xhci_segment_alloc(xhci, cycle_state, max_packet, flags); in xhci_alloc_segments_for_ring()
348 xhci_segment_free(xhci, prev); in xhci_alloc_segments_for_ring()
371 struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, in xhci_ring_alloc() argument
377 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_ring_alloc()
390 ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg, in xhci_ring_alloc()
411 void xhci_free_endpoint_ring(struct xhci_hcd *xhci, in xhci_free_endpoint_ring() argument
415 xhci_ring_free(xhci, virt_dev->eps[ep_index].ring); in xhci_free_endpoint_ring()
423 int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, in xhci_ring_expansion() argument
439 ret = xhci_alloc_segments_for_ring(xhci, &first, &last, in xhci_ring_expansion()
452 xhci_segment_free(xhci, first); in xhci_ring_expansion()
460 xhci_link_rings(xhci, ring, first, last, num_segs); in xhci_ring_expansion()
462 xhci_dbg_trace(xhci, trace_xhci_dbg_ring_expansion, in xhci_ring_expansion()
469 struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, in xhci_alloc_container_ctx() argument
473 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_alloc_container_ctx()
483 ctx->size = HCC_64BYTE_CONTEXT(xhci->hcc_params) ? 2048 : 1024; in xhci_alloc_container_ctx()
485 ctx->size += CTX_SIZE(xhci->hcc_params); in xhci_alloc_container_ctx()
487 ctx->bytes = dma_pool_zalloc(xhci->device_pool, flags, &ctx->dma); in xhci_alloc_container_ctx()
495 void xhci_free_container_ctx(struct xhci_hcd *xhci, in xhci_free_container_ctx() argument
500 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); in xhci_free_container_ctx()
513 struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, in xhci_get_slot_ctx() argument
520 (ctx->bytes + CTX_SIZE(xhci->hcc_params)); in xhci_get_slot_ctx()
523 struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, in xhci_get_ep_ctx() argument
533 (ctx->bytes + (ep_index * CTX_SIZE(xhci->hcc_params))); in xhci_get_ep_ctx()
539 static void xhci_free_stream_ctx(struct xhci_hcd *xhci, in xhci_free_stream_ctx() argument
543 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_free_stream_ctx()
550 return dma_pool_free(xhci->small_streams_pool, in xhci_free_stream_ctx()
553 return dma_pool_free(xhci->medium_streams_pool, in xhci_free_stream_ctx()
567 static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, in xhci_alloc_stream_ctx() argument
571 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_alloc_stream_ctx()
578 return dma_pool_alloc(xhci->small_streams_pool, in xhci_alloc_stream_ctx()
581 return dma_pool_alloc(xhci->medium_streams_pool, in xhci_alloc_stream_ctx()
621 struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, in xhci_alloc_stream_info() argument
631 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_alloc_stream_info()
633 xhci_dbg(xhci, "Allocating %u streams and %u " in xhci_alloc_stream_info()
636 if (xhci->cmd_ring_reserved_trbs == MAX_RSVD_CMD_TRBS) { in xhci_alloc_stream_info()
637 xhci_dbg(xhci, "Command ring has no reserved TRBs available\n"); in xhci_alloc_stream_info()
640 xhci->cmd_ring_reserved_trbs++; in xhci_alloc_stream_info()
658 stream_info->stream_ctx_array = xhci_alloc_stream_ctx(xhci, in xhci_alloc_stream_info()
668 xhci_alloc_command_with_ctx(xhci, true, mem_flags); in xhci_alloc_stream_info()
681 xhci_ring_alloc(xhci, 2, 1, TYPE_STREAM, max_packet, in xhci_alloc_stream_info()
694 xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", in xhci_alloc_stream_info()
699 xhci_ring_free(xhci, cur_ring); in xhci_alloc_stream_info()
717 xhci_ring_free(xhci, cur_ring); in xhci_alloc_stream_info()
721 xhci_free_command(xhci, stream_info->free_streams_command); in xhci_alloc_stream_info()
723 xhci_free_stream_ctx(xhci, in xhci_alloc_stream_info()
732 xhci->cmd_ring_reserved_trbs--; in xhci_alloc_stream_info()
739 void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci, in xhci_setup_streams_ep_input_ctx() argument
749 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_setup_streams_ep_input_ctx()
776 void xhci_free_stream_info(struct xhci_hcd *xhci, in xhci_free_stream_info() argument
789 xhci_ring_free(xhci, cur_ring); in xhci_free_stream_info()
793 xhci_free_command(xhci, stream_info->free_streams_command); in xhci_free_stream_info()
794 xhci->cmd_ring_reserved_trbs--; in xhci_free_stream_info()
796 xhci_free_stream_ctx(xhci, in xhci_free_stream_info()
808 static void xhci_init_endpoint_timer(struct xhci_hcd *xhci, in xhci_init_endpoint_timer() argument
813 ep->xhci = xhci; in xhci_init_endpoint_timer()
816 static void xhci_free_tt_info(struct xhci_hcd *xhci, in xhci_free_tt_info() argument
828 virt_dev->real_port > HCS_MAX_PORTS(xhci->hcs_params1)) { in xhci_free_tt_info()
829 xhci_dbg(xhci, "Bad real port.\n"); in xhci_free_tt_info()
833 tt_list_head = &(xhci->rh_bw[virt_dev->real_port - 1].tts); in xhci_free_tt_info()
846 int xhci_alloc_tt_info(struct xhci_hcd *xhci, in xhci_alloc_tt_info() argument
854 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_alloc_tt_info()
870 &xhci->rh_bw[virt_dev->real_port - 1].tts); in xhci_alloc_tt_info()
881 xhci_free_tt_info(xhci, virt_dev, virt_dev->udev->slot_id); in xhci_alloc_tt_info()
887 * Should be called with xhci->lock held if there is any chance the TT lists
891 void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) in xhci_free_virt_device() argument
898 if (slot_id == 0 || !xhci->devs[slot_id]) in xhci_free_virt_device()
901 dev = xhci->devs[slot_id]; in xhci_free_virt_device()
903 xhci->dcbaa->dev_context_ptrs[slot_id] = 0; in xhci_free_virt_device()
914 xhci_ring_free(xhci, dev->eps[i].ring); in xhci_free_virt_device()
916 xhci_free_stream_info(xhci, in xhci_free_virt_device()
928 xhci_dbg(xhci, "Slot %u endpoint %u not removed from BW list!\n", in xhci_free_virt_device()
933 xhci_free_tt_info(xhci, dev, slot_id); in xhci_free_virt_device()
935 xhci_update_tt_active_eps(xhci, dev, old_active_eps); in xhci_free_virt_device()
938 xhci_free_container_ctx(xhci, dev->in_ctx); in xhci_free_virt_device()
940 xhci_free_container_ctx(xhci, dev->out_ctx); in xhci_free_virt_device()
944 kfree(xhci->devs[slot_id]); in xhci_free_virt_device()
945 xhci->devs[slot_id] = NULL; in xhci_free_virt_device()
954 static void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id) in xhci_free_virt_devices_depth_first() argument
961 vdev = xhci->devs[slot_id]; in xhci_free_virt_devices_depth_first()
966 vdev->real_port > HCS_MAX_PORTS(xhci->hcs_params1)) { in xhci_free_virt_devices_depth_first()
967 xhci_dbg(xhci, "Bad vdev->real_port.\n"); in xhci_free_virt_devices_depth_first()
971 tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts); in xhci_free_virt_devices_depth_first()
976 for (i = 1; i < HCS_MAX_SLOTS(xhci->hcs_params1); i++) { in xhci_free_virt_devices_depth_first()
977 vdev = xhci->devs[i]; in xhci_free_virt_devices_depth_first()
980 xhci, i); in xhci_free_virt_devices_depth_first()
986 xhci_debugfs_remove_slot(xhci, slot_id); in xhci_free_virt_devices_depth_first()
987 xhci_free_virt_device(xhci, slot_id); in xhci_free_virt_devices_depth_first()
990 int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, in xhci_alloc_virt_device() argument
997 if (slot_id == 0 || xhci->devs[slot_id]) { in xhci_alloc_virt_device()
998 xhci_warn(xhci, "Bad Slot ID %d\n", slot_id); in xhci_alloc_virt_device()
1009 dev->out_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_DEVICE, flags); in xhci_alloc_virt_device()
1013 xhci_dbg(xhci, "Slot %d output ctx = 0x%llx (dma)\n", slot_id, in xhci_alloc_virt_device()
1017 dev->in_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, flags); in xhci_alloc_virt_device()
1021 xhci_dbg(xhci, "Slot %d input ctx = 0x%llx (dma)\n", slot_id, in xhci_alloc_virt_device()
1028 xhci_init_endpoint_timer(xhci, &dev->eps[i]); in xhci_alloc_virt_device()
1034 dev->eps[0].ring = xhci_ring_alloc(xhci, 2, 1, TYPE_CTRL, 0, flags); in xhci_alloc_virt_device()
1041 xhci->dcbaa->dev_context_ptrs[slot_id] = cpu_to_le64(dev->out_ctx->dma); in xhci_alloc_virt_device()
1042 xhci_dbg(xhci, "Set slot id %d dcbaa entry %p to 0x%llx\n", in xhci_alloc_virt_device()
1044 &xhci->dcbaa->dev_context_ptrs[slot_id], in xhci_alloc_virt_device()
1045 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id])); in xhci_alloc_virt_device()
1049 xhci->devs[slot_id] = dev; in xhci_alloc_virt_device()
1055 xhci_free_container_ctx(xhci, dev->in_ctx); in xhci_alloc_virt_device()
1057 xhci_free_container_ctx(xhci, dev->out_ctx); in xhci_alloc_virt_device()
1063 void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci, in xhci_copy_ep0_dequeue_into_input_ctx() argument
1070 virt_dev = xhci->devs[udev->slot_id]; in xhci_copy_ep0_dequeue_into_input_ctx()
1071 ep0_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, 0); in xhci_copy_ep0_dequeue_into_input_ctx()
1086 * The xHCI roothub may have ports of differing speeds in any order in the port
1089 * The xHCI hardware wants to know the roothub port number that the USB device
1095 static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, in xhci_find_real_port_number() argument
1102 hcd = xhci->shared_hcd; in xhci_find_real_port_number()
1104 hcd = xhci->main_hcd; in xhci_find_real_port_number()
1113 /* Setup an xHCI virtual device for a Set Address command */
1114 int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev) in xhci_setup_addressable_virt_dev() argument
1123 dev = xhci->devs[udev->slot_id]; in xhci_setup_addressable_virt_dev()
1126 xhci_warn(xhci, "Slot ID %d is not assigned to this device\n", in xhci_setup_addressable_virt_dev()
1130 ep0_ctx = xhci_get_ep_ctx(xhci, dev->in_ctx, 0); in xhci_setup_addressable_virt_dev()
1131 slot_ctx = xhci_get_slot_ctx(xhci, dev->in_ctx); in xhci_setup_addressable_virt_dev()
1158 xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); in xhci_setup_addressable_virt_dev()
1166 port_num = xhci_find_real_port_number(xhci, udev); in xhci_setup_addressable_virt_dev()
1176 xhci_dbg(xhci, "Set root hub portnum to %d\n", port_num); in xhci_setup_addressable_virt_dev()
1177 xhci_dbg(xhci, "Set fake root hub portnum to %d\n", dev->fake_port); in xhci_setup_addressable_virt_dev()
1186 dev->bw_table = &xhci->rh_bw[port_num - 1].bw_table; in xhci_setup_addressable_virt_dev()
1191 rh_bw = &xhci->rh_bw[port_num - 1]; in xhci_setup_addressable_virt_dev()
1206 xhci_warn(xhci, "WARN: Didn't find a matching TT\n"); in xhci_setup_addressable_virt_dev()
1216 xhci_dbg(xhci, "udev->tt = %p\n", udev->tt); in xhci_setup_addressable_virt_dev()
1217 xhci_dbg(xhci, "udev->ttport = 0x%x\n", udev->ttport); in xhci_setup_addressable_virt_dev()
1308 * The polling interval is expressed in "microframes". If xHCI's Interval field
1443 int xhci_endpoint_init(struct xhci_hcd *xhci, in xhci_endpoint_init() argument
1463 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); in xhci_endpoint_init()
1475 * set it to max available. See xHCI 1.1 spec 4.14.1.1 for details. in xhci_endpoint_init()
1483 if ((xhci->quirks & XHCI_LIMIT_ENDPOINT_INTERVAL_7) && in xhci_endpoint_init()
1509 /* xHCI 1.0 and 1.1 indicates that ctrl ep avg TRB Length should be 8 */ in xhci_endpoint_init()
1510 if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version >= 0x100) in xhci_endpoint_init()
1512 /* xhci 1.1 with LEC support doesn't use mult field, use RsvdZ */ in xhci_endpoint_init()
1513 if ((xhci->hci_version > 0x100) && HCC2_LEC(xhci->hcc_params2)) in xhci_endpoint_init()
1518 xhci_ring_alloc(xhci, 2, 1, ring_type, max_packet, mem_flags); in xhci_endpoint_init()
1542 void xhci_endpoint_zero(struct xhci_hcd *xhci, in xhci_endpoint_zero() argument
1550 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); in xhci_endpoint_zero()
1571 void xhci_update_bw_info(struct xhci_hcd *xhci, in xhci_update_bw_info() argument
1596 ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, i); in xhci_update_bw_info()
1629 void xhci_endpoint_copy(struct xhci_hcd *xhci, in xhci_endpoint_copy() argument
1637 out_ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); in xhci_endpoint_copy()
1638 in_ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index); in xhci_endpoint_copy()
1644 if (xhci->quirks & XHCI_MTK_HOST) { in xhci_endpoint_copy()
1655 void xhci_slot_copy(struct xhci_hcd *xhci, in xhci_slot_copy() argument
1662 in_slot_ctx = xhci_get_slot_ctx(xhci, in_ctx); in xhci_slot_copy()
1663 out_slot_ctx = xhci_get_slot_ctx(xhci, out_ctx); in xhci_slot_copy()
1672 static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) in scratchpad_alloc() argument
1675 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in scratchpad_alloc()
1676 int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); in scratchpad_alloc()
1678 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in scratchpad_alloc()
1684 xhci->scratchpad = kzalloc_node(sizeof(*xhci->scratchpad), flags, in scratchpad_alloc()
1686 if (!xhci->scratchpad) in scratchpad_alloc()
1689 xhci->scratchpad->sp_array = dma_alloc_coherent(dev, in scratchpad_alloc()
1691 &xhci->scratchpad->sp_dma, flags); in scratchpad_alloc()
1692 if (!xhci->scratchpad->sp_array) in scratchpad_alloc()
1695 xhci->scratchpad->sp_buffers = kcalloc_node(num_sp, sizeof(void *), in scratchpad_alloc()
1697 if (!xhci->scratchpad->sp_buffers) in scratchpad_alloc()
1700 xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma); in scratchpad_alloc()
1703 void *buf = dma_alloc_coherent(dev, xhci->page_size, &dma, in scratchpad_alloc()
1708 xhci->scratchpad->sp_array[i] = dma; in scratchpad_alloc()
1709 xhci->scratchpad->sp_buffers[i] = buf; in scratchpad_alloc()
1716 dma_free_coherent(dev, xhci->page_size, in scratchpad_alloc()
1717 xhci->scratchpad->sp_buffers[i], in scratchpad_alloc()
1718 xhci->scratchpad->sp_array[i]); in scratchpad_alloc()
1721 kfree(xhci->scratchpad->sp_buffers); in scratchpad_alloc()
1725 xhci->scratchpad->sp_array, in scratchpad_alloc()
1726 xhci->scratchpad->sp_dma); in scratchpad_alloc()
1729 kfree(xhci->scratchpad); in scratchpad_alloc()
1730 xhci->scratchpad = NULL; in scratchpad_alloc()
1736 static void scratchpad_free(struct xhci_hcd *xhci) in scratchpad_free() argument
1740 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in scratchpad_free()
1742 if (!xhci->scratchpad) in scratchpad_free()
1745 num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); in scratchpad_free()
1748 dma_free_coherent(dev, xhci->page_size, in scratchpad_free()
1749 xhci->scratchpad->sp_buffers[i], in scratchpad_free()
1750 xhci->scratchpad->sp_array[i]); in scratchpad_free()
1752 kfree(xhci->scratchpad->sp_buffers); in scratchpad_free()
1754 xhci->scratchpad->sp_array, in scratchpad_free()
1755 xhci->scratchpad->sp_dma); in scratchpad_free()
1756 kfree(xhci->scratchpad); in scratchpad_free()
1757 xhci->scratchpad = NULL; in scratchpad_free()
1760 struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, in xhci_alloc_command() argument
1764 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_alloc_command()
1786 struct xhci_command *xhci_alloc_command_with_ctx(struct xhci_hcd *xhci, in xhci_alloc_command_with_ctx() argument
1791 command = xhci_alloc_command(xhci, allocate_completion, mem_flags); in xhci_alloc_command_with_ctx()
1795 command->in_ctx = xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, in xhci_alloc_command_with_ctx()
1810 void xhci_free_command(struct xhci_hcd *xhci, in xhci_free_command() argument
1813 xhci_free_container_ctx(xhci, in xhci_free_command()
1819 int xhci_alloc_erst(struct xhci_hcd *xhci, in xhci_alloc_erst() argument
1830 erst->entries = dma_alloc_coherent(xhci_to_hcd(xhci)->self.sysdev, in xhci_alloc_erst()
1849 void xhci_free_erst(struct xhci_hcd *xhci, struct xhci_erst *erst) in xhci_free_erst() argument
1852 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_free_erst()
1862 void xhci_mem_cleanup(struct xhci_hcd *xhci) in xhci_mem_cleanup() argument
1864 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_mem_cleanup()
1867 cancel_delayed_work_sync(&xhci->cmd_timer); in xhci_mem_cleanup()
1869 xhci_free_erst(xhci, &xhci->erst); in xhci_mem_cleanup()
1871 if (xhci->event_ring) in xhci_mem_cleanup()
1872 xhci_ring_free(xhci, xhci->event_ring); in xhci_mem_cleanup()
1873 xhci->event_ring = NULL; in xhci_mem_cleanup()
1874 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed event ring"); in xhci_mem_cleanup()
1876 if (xhci->lpm_command) in xhci_mem_cleanup()
1877 xhci_free_command(xhci, xhci->lpm_command); in xhci_mem_cleanup()
1878 xhci->lpm_command = NULL; in xhci_mem_cleanup()
1879 if (xhci->cmd_ring) in xhci_mem_cleanup()
1880 xhci_ring_free(xhci, xhci->cmd_ring); in xhci_mem_cleanup()
1881 xhci->cmd_ring = NULL; in xhci_mem_cleanup()
1882 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed command ring"); in xhci_mem_cleanup()
1883 xhci_cleanup_command_queue(xhci); in xhci_mem_cleanup()
1885 num_ports = HCS_MAX_PORTS(xhci->hcs_params1); in xhci_mem_cleanup()
1886 for (i = 0; i < num_ports && xhci->rh_bw; i++) { in xhci_mem_cleanup()
1887 struct xhci_interval_bw_table *bwt = &xhci->rh_bw[i].bw_table; in xhci_mem_cleanup()
1895 for (i = HCS_MAX_SLOTS(xhci->hcs_params1); i > 0; i--) in xhci_mem_cleanup()
1896 xhci_free_virt_devices_depth_first(xhci, i); in xhci_mem_cleanup()
1898 dma_pool_destroy(xhci->segment_pool); in xhci_mem_cleanup()
1899 xhci->segment_pool = NULL; in xhci_mem_cleanup()
1900 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed segment pool"); in xhci_mem_cleanup()
1902 dma_pool_destroy(xhci->device_pool); in xhci_mem_cleanup()
1903 xhci->device_pool = NULL; in xhci_mem_cleanup()
1904 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed device context pool"); in xhci_mem_cleanup()
1906 dma_pool_destroy(xhci->small_streams_pool); in xhci_mem_cleanup()
1907 xhci->small_streams_pool = NULL; in xhci_mem_cleanup()
1908 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_cleanup()
1911 dma_pool_destroy(xhci->medium_streams_pool); in xhci_mem_cleanup()
1912 xhci->medium_streams_pool = NULL; in xhci_mem_cleanup()
1913 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_cleanup()
1916 if (xhci->dcbaa) in xhci_mem_cleanup()
1917 dma_free_coherent(dev, sizeof(*xhci->dcbaa), in xhci_mem_cleanup()
1918 xhci->dcbaa, xhci->dcbaa->dma); in xhci_mem_cleanup()
1919 xhci->dcbaa = NULL; in xhci_mem_cleanup()
1921 scratchpad_free(xhci); in xhci_mem_cleanup()
1923 if (!xhci->rh_bw) in xhci_mem_cleanup()
1928 list_for_each_entry_safe(tt, n, &xhci->rh_bw[i].tts, tt_list) { in xhci_mem_cleanup()
1935 xhci->cmd_ring_reserved_trbs = 0; in xhci_mem_cleanup()
1936 xhci->usb2_rhub.num_ports = 0; in xhci_mem_cleanup()
1937 xhci->usb3_rhub.num_ports = 0; in xhci_mem_cleanup()
1938 xhci->num_active_eps = 0; in xhci_mem_cleanup()
1939 kfree(xhci->usb2_rhub.ports); in xhci_mem_cleanup()
1940 kfree(xhci->usb3_rhub.ports); in xhci_mem_cleanup()
1941 kfree(xhci->hw_ports); in xhci_mem_cleanup()
1942 kfree(xhci->rh_bw); in xhci_mem_cleanup()
1943 kfree(xhci->ext_caps); in xhci_mem_cleanup()
1944 for (i = 0; i < xhci->num_port_caps; i++) in xhci_mem_cleanup()
1945 kfree(xhci->port_caps[i].psi); in xhci_mem_cleanup()
1946 kfree(xhci->port_caps); in xhci_mem_cleanup()
1947 xhci->num_port_caps = 0; in xhci_mem_cleanup()
1949 xhci->usb2_rhub.ports = NULL; in xhci_mem_cleanup()
1950 xhci->usb3_rhub.ports = NULL; in xhci_mem_cleanup()
1951 xhci->hw_ports = NULL; in xhci_mem_cleanup()
1952 xhci->rh_bw = NULL; in xhci_mem_cleanup()
1953 xhci->ext_caps = NULL; in xhci_mem_cleanup()
1954 xhci->port_caps = NULL; in xhci_mem_cleanup()
1956 xhci->page_size = 0; in xhci_mem_cleanup()
1957 xhci->page_shift = 0; in xhci_mem_cleanup()
1958 xhci->usb2_rhub.bus_state.bus_suspended = 0; in xhci_mem_cleanup()
1959 xhci->usb3_rhub.bus_state.bus_suspended = 0; in xhci_mem_cleanup()
1962 static int xhci_test_trb_in_td(struct xhci_hcd *xhci, in xhci_test_trb_in_td() argument
1977 seg = trb_in_td(xhci, input_seg, start_trb, end_trb, input_dma, false); in xhci_test_trb_in_td()
1979 xhci_warn(xhci, "WARN: %s TRB math test %d failed!\n", in xhci_test_trb_in_td()
1981 xhci_warn(xhci, "Tested TRB math w/ seg %p and " in xhci_test_trb_in_td()
1985 xhci_warn(xhci, "starting TRB %p (0x%llx DMA), " in xhci_test_trb_in_td()
1989 xhci_warn(xhci, "Expected seg %p, got seg %p\n", in xhci_test_trb_in_td()
1991 trb_in_td(xhci, input_seg, start_trb, end_trb, input_dma, in xhci_test_trb_in_td()
1999 static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci) in xhci_check_trb_in_td_math() argument
2008 { xhci->event_ring->first_seg->dma - 16, NULL }, in xhci_check_trb_in_td_math()
2010 { xhci->event_ring->first_seg->dma - 1, NULL }, in xhci_check_trb_in_td_math()
2012 { xhci->event_ring->first_seg->dma, xhci->event_ring->first_seg }, in xhci_check_trb_in_td_math()
2014 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16, in xhci_check_trb_in_td_math()
2015 xhci->event_ring->first_seg }, in xhci_check_trb_in_td_math()
2017 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 1)*16 + 1, NULL }, in xhci_check_trb_in_td_math()
2019 { xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT)*16, NULL }, in xhci_check_trb_in_td_math()
2031 { .input_seg = xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2032 .start_trb = xhci->event_ring->first_seg->trbs, in xhci_check_trb_in_td_math()
2033 .end_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1], in xhci_check_trb_in_td_math()
2034 .input_dma = xhci->cmd_ring->first_seg->dma, in xhci_check_trb_in_td_math()
2038 { .input_seg = xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2039 .start_trb = xhci->event_ring->first_seg->trbs, in xhci_check_trb_in_td_math()
2040 .end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1], in xhci_check_trb_in_td_math()
2041 .input_dma = xhci->cmd_ring->first_seg->dma, in xhci_check_trb_in_td_math()
2045 { .input_seg = xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2046 .start_trb = xhci->cmd_ring->first_seg->trbs, in xhci_check_trb_in_td_math()
2047 .end_trb = &xhci->cmd_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1], in xhci_check_trb_in_td_math()
2048 .input_dma = xhci->cmd_ring->first_seg->dma, in xhci_check_trb_in_td_math()
2052 { .input_seg = xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2053 .start_trb = &xhci->event_ring->first_seg->trbs[0], in xhci_check_trb_in_td_math()
2054 .end_trb = &xhci->event_ring->first_seg->trbs[3], in xhci_check_trb_in_td_math()
2055 .input_dma = xhci->event_ring->first_seg->dma + 4*16, in xhci_check_trb_in_td_math()
2059 { .input_seg = xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2060 .start_trb = &xhci->event_ring->first_seg->trbs[3], in xhci_check_trb_in_td_math()
2061 .end_trb = &xhci->event_ring->first_seg->trbs[6], in xhci_check_trb_in_td_math()
2062 .input_dma = xhci->event_ring->first_seg->dma + 2*16, in xhci_check_trb_in_td_math()
2066 { .input_seg = xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2067 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3], in xhci_check_trb_in_td_math()
2068 .end_trb = &xhci->event_ring->first_seg->trbs[1], in xhci_check_trb_in_td_math()
2069 .input_dma = xhci->event_ring->first_seg->dma + 2*16, in xhci_check_trb_in_td_math()
2073 { .input_seg = xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2074 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3], in xhci_check_trb_in_td_math()
2075 .end_trb = &xhci->event_ring->first_seg->trbs[1], in xhci_check_trb_in_td_math()
2076 .input_dma = xhci->event_ring->first_seg->dma + (TRBS_PER_SEGMENT - 4)*16, in xhci_check_trb_in_td_math()
2080 { .input_seg = xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2081 .start_trb = &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 3], in xhci_check_trb_in_td_math()
2082 .end_trb = &xhci->event_ring->first_seg->trbs[1], in xhci_check_trb_in_td_math()
2083 .input_dma = xhci->cmd_ring->first_seg->dma + 2*16, in xhci_check_trb_in_td_math()
2093 ret = xhci_test_trb_in_td(xhci, in xhci_check_trb_in_td_math()
2094 xhci->event_ring->first_seg, in xhci_check_trb_in_td_math()
2095 xhci->event_ring->first_seg->trbs, in xhci_check_trb_in_td_math()
2096 &xhci->event_ring->first_seg->trbs[TRBS_PER_SEGMENT - 1], in xhci_check_trb_in_td_math()
2106 ret = xhci_test_trb_in_td(xhci, in xhci_check_trb_in_td_math()
2116 xhci_dbg(xhci, "TRB math tests passed.\n"); in xhci_check_trb_in_td_math()
2120 static void xhci_set_hc_event_deq(struct xhci_hcd *xhci) in xhci_set_hc_event_deq() argument
2125 deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, in xhci_set_hc_event_deq()
2126 xhci->event_ring->dequeue); in xhci_set_hc_event_deq()
2128 xhci_warn(xhci, "WARN something wrong with SW event ring " in xhci_set_hc_event_deq()
2131 temp = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); in xhci_set_hc_event_deq()
2137 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_set_hc_event_deq()
2140 xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp, in xhci_set_hc_event_deq()
2141 &xhci->ir_set->erst_dequeue); in xhci_set_hc_event_deq()
2144 static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, in xhci_add_in_port() argument
2151 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_add_in_port()
2159 rhub = &xhci->usb3_rhub; in xhci_add_in_port()
2170 * Some zhaoxin's xHCI controller that follow usb3.1 spec in xhci_add_in_port()
2173 if (xhci->quirks & XHCI_ZHAOXIN_HOST) { in xhci_add_in_port()
2179 rhub = &xhci->usb2_rhub; in xhci_add_in_port()
2181 xhci_warn(xhci, "Ignoring unknown port speed, " in xhci_add_in_port()
2192 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_add_in_port()
2201 port_cap = &xhci->port_caps[xhci->num_port_caps++]; in xhci_add_in_port()
2202 if (xhci->num_port_caps > max_caps) in xhci_add_in_port()
2225 if (xhci->quirks & XHCI_ZHAOXIN_HOST && in xhci_add_in_port()
2230 xhci_dbg(xhci, "PSIV:%d PSIE:%d PLT:%d PFD:%d LP:%d PSIM:%d\n", in xhci_add_in_port()
2249 if (major_revision < 0x03 && xhci->num_ext_caps < max_caps) in xhci_add_in_port()
2250 xhci->ext_caps[xhci->num_ext_caps++] = temp; in xhci_add_in_port()
2252 if ((xhci->hci_version >= 0x100) && (major_revision != 0x03) && in xhci_add_in_port()
2254 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_add_in_port()
2255 "xHCI 1.0: support USB2 hardware lpm"); in xhci_add_in_port()
2256 xhci->hw_lpm_support = 1; in xhci_add_in_port()
2261 struct xhci_port *hw_port = &xhci->hw_ports[i]; in xhci_add_in_port()
2264 xhci_warn(xhci, "Duplicate port entry, Ext Cap %p," in xhci_add_in_port()
2266 xhci_warn(xhci, "Port was marked as USB %u, " in xhci_add_in_port()
2286 static void xhci_create_rhub_port_array(struct xhci_hcd *xhci, in xhci_create_rhub_port_array() argument
2291 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_create_rhub_port_array()
2300 for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { in xhci_create_rhub_port_array()
2301 if (xhci->hw_ports[i].rhub != rhub || in xhci_create_rhub_port_array()
2302 xhci->hw_ports[i].hcd_portnum == DUPLICATE_ENTRY) in xhci_create_rhub_port_array()
2304 xhci->hw_ports[i].hcd_portnum = port_index; in xhci_create_rhub_port_array()
2305 rhub->ports[port_index] = &xhci->hw_ports[i]; in xhci_create_rhub_port_array()
2319 static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) in xhci_setup_port_arrays() argument
2327 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_setup_port_arrays()
2329 num_ports = HCS_MAX_PORTS(xhci->hcs_params1); in xhci_setup_port_arrays()
2330 xhci->hw_ports = kcalloc_node(num_ports, sizeof(*xhci->hw_ports), in xhci_setup_port_arrays()
2332 if (!xhci->hw_ports) in xhci_setup_port_arrays()
2336 xhci->hw_ports[i].addr = &xhci->op_regs->port_status_base + in xhci_setup_port_arrays()
2338 xhci->hw_ports[i].hw_portnum = i; in xhci_setup_port_arrays()
2340 init_completion(&xhci->hw_ports[i].rexit_done); in xhci_setup_port_arrays()
2341 init_completion(&xhci->hw_ports[i].u3exit_done); in xhci_setup_port_arrays()
2344 xhci->rh_bw = kcalloc_node(num_ports, sizeof(*xhci->rh_bw), flags, in xhci_setup_port_arrays()
2346 if (!xhci->rh_bw) in xhci_setup_port_arrays()
2351 INIT_LIST_HEAD(&xhci->rh_bw[i].tts); in xhci_setup_port_arrays()
2352 bw_table = &xhci->rh_bw[i].bw_table; in xhci_setup_port_arrays()
2356 base = &xhci->cap_regs->hc_capbase; in xhci_setup_port_arrays()
2360 xhci_err(xhci, "No Extended Capability registers, unable to set up roothub\n"); in xhci_setup_port_arrays()
2372 xhci->ext_caps = kcalloc_node(cap_count, sizeof(*xhci->ext_caps), in xhci_setup_port_arrays()
2374 if (!xhci->ext_caps) in xhci_setup_port_arrays()
2377 xhci->port_caps = kcalloc_node(cap_count, sizeof(*xhci->port_caps), in xhci_setup_port_arrays()
2379 if (!xhci->port_caps) in xhci_setup_port_arrays()
2385 xhci_add_in_port(xhci, num_ports, base + offset, cap_count); in xhci_setup_port_arrays()
2386 if (xhci->usb2_rhub.num_ports + xhci->usb3_rhub.num_ports == in xhci_setup_port_arrays()
2392 if (xhci->usb2_rhub.num_ports == 0 && xhci->usb3_rhub.num_ports == 0) { in xhci_setup_port_arrays()
2393 xhci_warn(xhci, "No ports on the roothubs?\n"); in xhci_setup_port_arrays()
2396 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_port_arrays()
2398 xhci->usb2_rhub.num_ports, xhci->usb3_rhub.num_ports); in xhci_setup_port_arrays()
2403 if (xhci->usb3_rhub.num_ports > USB_SS_MAXPORTS) { in xhci_setup_port_arrays()
2404 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_port_arrays()
2407 xhci->usb3_rhub.num_ports = USB_SS_MAXPORTS; in xhci_setup_port_arrays()
2409 if (xhci->usb2_rhub.num_ports > USB_MAXCHILDREN) { in xhci_setup_port_arrays()
2410 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_port_arrays()
2413 xhci->usb2_rhub.num_ports = USB_MAXCHILDREN; in xhci_setup_port_arrays()
2421 xhci_create_rhub_port_array(xhci, &xhci->usb2_rhub, flags); in xhci_setup_port_arrays()
2422 xhci_create_rhub_port_array(xhci, &xhci->usb3_rhub, flags); in xhci_setup_port_arrays()
2427 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) in xhci_mem_init() argument
2430 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_mem_init()
2436 INIT_LIST_HEAD(&xhci->cmd_list); in xhci_mem_init()
2439 INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout); in xhci_mem_init()
2440 init_completion(&xhci->cmd_ring_stop_completion); in xhci_mem_init()
2442 page_size = readl(&xhci->op_regs->page_size); in xhci_mem_init()
2443 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2451 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2454 xhci_warn(xhci, "WARN: no supported page size\n"); in xhci_mem_init()
2456 xhci->page_shift = 12; in xhci_mem_init()
2457 xhci->page_size = 1 << xhci->page_shift; in xhci_mem_init()
2458 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2459 "HCD page size set to %iK", xhci->page_size / 1024); in xhci_mem_init()
2465 val = HCS_MAX_SLOTS(readl(&xhci->cap_regs->hcs_params1)); in xhci_mem_init()
2466 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2468 val2 = readl(&xhci->op_regs->config_reg); in xhci_mem_init()
2470 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2472 writel(val, &xhci->op_regs->config_reg); in xhci_mem_init()
2475 * xHCI section 5.4.6 - doorbell array must be in xhci_mem_init()
2478 xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma, in xhci_mem_init()
2480 if (!xhci->dcbaa) in xhci_mem_init()
2482 xhci->dcbaa->dma = dma; in xhci_mem_init()
2483 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2485 (unsigned long long)xhci->dcbaa->dma, xhci->dcbaa); in xhci_mem_init()
2486 xhci_write_64(xhci, dma, &xhci->op_regs->dcbaa_ptr); in xhci_mem_init()
2495 if (xhci->quirks & XHCI_ZHAOXIN_TRB_FETCH) in xhci_mem_init()
2496 xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, in xhci_mem_init()
2497 TRB_SEGMENT_SIZE * 2, TRB_SEGMENT_SIZE * 2, xhci->page_size * 2); in xhci_mem_init()
2499 xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, in xhci_mem_init()
2500 TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size); in xhci_mem_init()
2503 xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev, in xhci_mem_init()
2504 2112, 64, xhci->page_size); in xhci_mem_init()
2505 if (!xhci->segment_pool || !xhci->device_pool) in xhci_mem_init()
2511 xhci->small_streams_pool = in xhci_mem_init()
2512 dma_pool_create("xHCI 256 byte stream ctx arrays", in xhci_mem_init()
2514 xhci->medium_streams_pool = in xhci_mem_init()
2515 dma_pool_create("xHCI 1KB stream ctx arrays", in xhci_mem_init()
2521 if (!xhci->small_streams_pool || !xhci->medium_streams_pool) in xhci_mem_init()
2525 xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, 0, flags); in xhci_mem_init()
2526 if (!xhci->cmd_ring) in xhci_mem_init()
2528 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2529 "Allocated command ring at %p", xhci->cmd_ring); in xhci_mem_init()
2530 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "First segment DMA is 0x%llx", in xhci_mem_init()
2531 (unsigned long long)xhci->cmd_ring->first_seg->dma); in xhci_mem_init()
2534 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); in xhci_mem_init()
2536 (xhci->cmd_ring->first_seg->dma & (u64) ~CMD_RING_RSVD_BITS) | in xhci_mem_init()
2537 xhci->cmd_ring->cycle_state; in xhci_mem_init()
2538 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2540 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring); in xhci_mem_init()
2542 xhci->lpm_command = xhci_alloc_command_with_ctx(xhci, true, flags); in xhci_mem_init()
2543 if (!xhci->lpm_command) in xhci_mem_init()
2550 xhci->cmd_ring_reserved_trbs++; in xhci_mem_init()
2552 val = readl(&xhci->cap_regs->db_off); in xhci_mem_init()
2554 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2557 xhci->dba = (void __iomem *) xhci->cap_regs + val; in xhci_mem_init()
2559 xhci->ir_set = &xhci->run_regs->ir_set[0]; in xhci_mem_init()
2565 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Allocating event ring"); in xhci_mem_init()
2566 xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT, in xhci_mem_init()
2568 if (!xhci->event_ring) in xhci_mem_init()
2570 if (xhci_check_trb_in_td_math(xhci) < 0) in xhci_mem_init()
2573 ret = xhci_alloc_erst(xhci, xhci->event_ring, &xhci->erst, flags); in xhci_mem_init()
2578 val = readl(&xhci->ir_set->erst_size); in xhci_mem_init()
2581 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2584 writel(val, &xhci->ir_set->erst_size); in xhci_mem_init()
2586 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2589 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2591 (unsigned long long)xhci->erst.erst_dma_addr); in xhci_mem_init()
2592 val_64 = xhci_read_64(xhci, &xhci->ir_set->erst_base); in xhci_mem_init()
2594 val_64 |= (xhci->erst.erst_dma_addr & (u64) ~ERST_PTR_MASK); in xhci_mem_init()
2595 xhci_write_64(xhci, val_64, &xhci->ir_set->erst_base); in xhci_mem_init()
2598 xhci_set_hc_event_deq(xhci); in xhci_mem_init()
2599 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_mem_init()
2608 xhci->devs[i] = NULL; in xhci_mem_init()
2610 if (scratchpad_alloc(xhci, flags)) in xhci_mem_init()
2612 if (xhci_setup_port_arrays(xhci, flags)) in xhci_mem_init()
2619 temp = readl(&xhci->op_regs->dev_notification); in xhci_mem_init()
2622 writel(temp, &xhci->op_regs->dev_notification); in xhci_mem_init()
2627 xhci_halt(xhci); in xhci_mem_init()
2628 xhci_reset(xhci, XHCI_RESET_SHORT_USEC); in xhci_mem_init()
2629 xhci_mem_cleanup(xhci); in xhci_mem_init()