Lines Matching +full:generic +full:- +full:uhci
1 // SPDX-License-Identifier: GPL-2.0
22 #include <linux/dma-mapping.h>
23 #include <linux/usb/xhci-sideband.h>
26 #include "xhci-trace.h"
27 #include "xhci-debugfs.h"
28 #include "xhci-dbgcap.h"
48 if (!td || !td->start_seg) in td_on_ring()
51 xhci_for_each_ring_seg(ring->first_seg, seg) { in td_on_ring()
52 if (seg == td->start_seg) in td_on_ring()
60 * xhci_handshake - spin reading hc until handshake completes or fails
70 * hardware flakeout), or the register reads as all-ones (hardware removed).
82 return -ENODEV; in xhci_handshake()
88 * xhci_handshake_check_state - same as xhci_handshake but takes an additional
101 xhci->xhc_state & exit_state, in xhci_handshake_check_state()
104 if (result == U32_MAX || xhci->xhc_state & exit_state) in xhci_handshake_check_state()
105 return -ENODEV; in xhci_handshake_check_state()
120 halted = readl(&xhci->op_regs->status) & STS_HALT; in xhci_quiesce()
124 cmd = readl(&xhci->op_regs->command); in xhci_quiesce()
126 writel(cmd, &xhci->op_regs->command); in xhci_quiesce()
144 ret = xhci_handshake(&xhci->op_regs->status, in xhci_halt()
151 xhci->xhc_state |= XHCI_STATE_HALTED; in xhci_halt()
152 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; in xhci_halt()
165 temp = readl(&xhci->op_regs->command); in xhci_start()
169 writel(temp, &xhci->op_regs->command); in xhci_start()
175 ret = xhci_handshake(&xhci->op_regs->status, in xhci_start()
177 if (ret == -ETIMEDOUT) in xhci_start()
183 xhci->xhc_state = 0; in xhci_start()
184 xhci->run_graceperiod = jiffies + msecs_to_jiffies(500); in xhci_start()
203 state = readl(&xhci->op_regs->status); in xhci_reset()
207 return -ENODEV; in xhci_reset()
216 command = readl(&xhci->op_regs->command); in xhci_reset()
218 writel(command, &xhci->op_regs->command); in xhci_reset()
227 if (xhci->quirks & XHCI_INTEL_HOST) in xhci_reset()
230 ret = xhci_handshake_check_state(xhci, &xhci->op_regs->command, in xhci_reset()
235 if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL) in xhci_reset()
236 usb_asmedia_modifyflowcontrol(to_pci_dev(xhci_to_hcd(xhci)->self.controller)); in xhci_reset()
244 ret = xhci_handshake(&xhci->op_regs->status, STS_CNR, 0, timeout_us); in xhci_reset()
246 xhci->usb2_rhub.bus_state.port_c_suspend = 0; in xhci_reset()
247 xhci->usb2_rhub.bus_state.suspended_ports = 0; in xhci_reset()
248 xhci->usb2_rhub.bus_state.resuming_ports = 0; in xhci_reset()
249 xhci->usb3_rhub.bus_state.port_c_suspend = 0; in xhci_reset()
250 xhci->usb3_rhub.bus_state.suspended_ports = 0; in xhci_reset()
251 xhci->usb3_rhub.bus_state.resuming_ports = 0; in xhci_reset()
258 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_zero_64b_regs()
279 if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !domain || in xhci_zero_64b_regs()
280 domain->type == IOMMU_DOMAIN_IDENTITY) in xhci_zero_64b_regs()
286 val = readl(&xhci->op_regs->command); in xhci_zero_64b_regs()
288 writel(val, &xhci->op_regs->command); in xhci_zero_64b_regs()
291 val = readl(&xhci->op_regs->status); in xhci_zero_64b_regs()
293 writel(val, &xhci->op_regs->status); in xhci_zero_64b_regs()
296 val = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); in xhci_zero_64b_regs()
298 xhci_write_64(xhci, 0, &xhci->op_regs->dcbaa_ptr); in xhci_zero_64b_regs()
299 val = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); in xhci_zero_64b_regs()
301 xhci_write_64(xhci, 0, &xhci->op_regs->cmd_ring); in xhci_zero_64b_regs()
303 intrs = min_t(u32, HCS_MAX_INTRS(xhci->hcs_params1), in xhci_zero_64b_regs()
304 ARRAY_SIZE(xhci->run_regs->ir_set)); in xhci_zero_64b_regs()
309 ir = &xhci->run_regs->ir_set[i]; in xhci_zero_64b_regs()
310 val = xhci_read_64(xhci, &ir->erst_base); in xhci_zero_64b_regs()
312 xhci_write_64(xhci, 0, &ir->erst_base); in xhci_zero_64b_regs()
313 val= xhci_read_64(xhci, &ir->erst_dequeue); in xhci_zero_64b_regs()
315 xhci_write_64(xhci, 0, &ir->erst_dequeue); in xhci_zero_64b_regs()
319 err = xhci_handshake(&xhci->op_regs->status, in xhci_zero_64b_regs()
330 if (!ir || !ir->ir_set) in xhci_enable_interrupter()
331 return -EINVAL; in xhci_enable_interrupter()
333 iman = readl(&ir->ir_set->iman); in xhci_enable_interrupter()
335 writel(iman, &ir->ir_set->iman); in xhci_enable_interrupter()
338 readl(&ir->ir_set->iman); in xhci_enable_interrupter()
346 if (!ir || !ir->ir_set) in xhci_disable_interrupter()
347 return -EINVAL; in xhci_disable_interrupter()
349 iman = readl(&ir->ir_set->iman); in xhci_disable_interrupter()
351 writel(iman, &ir->ir_set->iman); in xhci_disable_interrupter()
353 iman = readl(&ir->ir_set->iman); in xhci_disable_interrupter()
366 if (!ir || !ir->ir_set) in xhci_set_interrupter_moderation()
367 return -EINVAL; in xhci_set_interrupter_moderation()
372 imod = readl(&ir->ir_set->imod); in xhci_set_interrupter_moderation()
375 writel(imod, &ir->ir_set->imod); in xhci_set_interrupter_moderation()
389 rhub = &xhci->usb3_rhub; in compliance_mode_recovery()
390 hcd = rhub->hcd; in compliance_mode_recovery()
395 for (i = 0; i < rhub->num_ports; i++) { in compliance_mode_recovery()
396 temp = readl(rhub->ports[i]->addr); in compliance_mode_recovery()
403 "Compliance mode detected->port %d", in compliance_mode_recovery()
408 if (hcd->state == HC_STATE_SUSPENDED) in compliance_mode_recovery()
415 if (xhci->port_status_u0 != ((1 << rhub->num_ports) - 1)) in compliance_mode_recovery()
416 mod_timer(&xhci->comp_mode_recovery_timer, in compliance_mode_recovery()
421 * Quirk to work around issue generated by the SN65LVPE502CP USB3.0 re-driver
432 xhci->port_status_u0 = 0; in compliance_mode_recovery_timer_init()
433 timer_setup(&xhci->comp_mode_recovery_timer, compliance_mode_recovery, in compliance_mode_recovery_timer_init()
435 xhci->comp_mode_recovery_timer.expires = jiffies + in compliance_mode_recovery_timer_init()
438 add_timer(&xhci->comp_mode_recovery_timer); in compliance_mode_recovery_timer_init()
445 * USB3.0 re-driver and that need the Compliance Mode Quirk.
447 * Vendor: Hewlett-Packard -> System Models: Z420, Z620 and Z820
458 if (!(strstr(dmi_sys_vendor, "Hewlett-Packard"))) in xhci_compliance_mode_recovery_timer_quirk_check()
472 return (xhci->port_status_u0 == ((1 << xhci->usb3_rhub.num_ports) - 1)); in xhci_all_ports_seen_u0()
479 page_size = readl(&xhci->op_regs->page_size) & XHCI_PAGE_SIZE_MASK; in xhci_hcd_page_size()
486 xhci->page_size = page_size << 12; in xhci_hcd_page_size()
488 xhci->page_size >> 10); in xhci_hcd_page_size()
496 max_slots = HCS_MAX_SLOTS(xhci->hcs_params1); in xhci_enable_max_dev_slots()
500 config_reg = readl(&xhci->op_regs->config_reg); in xhci_enable_max_dev_slots()
506 writel(config_reg, &xhci->op_regs->config_reg); in xhci_enable_max_dev_slots()
514 deq_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg, xhci->cmd_ring->dequeue); in xhci_set_cmd_ring_deq()
517 crcr = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); in xhci_set_cmd_ring_deq()
522 crcr |= xhci->cmd_ring->cycle_state; in xhci_set_cmd_ring_deq()
525 xhci_write_64(xhci, crcr, &xhci->op_regs->cmd_ring); in xhci_set_cmd_ring_deq()
532 offset = readl(&xhci->cap_regs->db_off) & DBOFF_MASK; in xhci_set_doorbell_ptr()
533 xhci->dba = (void __iomem *)xhci->cap_regs + offset; in xhci_set_doorbell_ptr()
546 dev_notf = readl(&xhci->op_regs->dev_notification); in xhci_set_dev_notifications()
549 writel(dev_notf, &xhci->op_regs->dev_notification); in xhci_set_dev_notifications()
553 * Initialize memory for HCD and xHC (one-time init).
565 spin_lock_init(&xhci->lock); in xhci_init()
567 INIT_LIST_HEAD(&xhci->cmd_list); in xhci_init()
568 INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout); in xhci_init()
569 init_completion(&xhci->cmd_ring_stop_completion); in xhci_init()
571 memset(xhci->devs, 0, MAX_HC_SLOTS * sizeof(*xhci->devs)); in xhci_init()
584 xhci_write_64(xhci, xhci->dcbaa->dma, &xhci->op_regs->dcbaa_ptr); in xhci_init()
594 xhci->interrupters[0]->isoc_bei_interval = AVOID_BEI_INTERVAL_MAX; in xhci_init()
598 xhci->quirks |= XHCI_COMP_MODE_QUIRK; in xhci_init()
606 /*-------------------------------------------------------------------------*/
610 struct xhci_interrupter *ir = xhci->interrupters[0]; in xhci_run_finished()
618 spin_lock_irqsave(&xhci->lock, flags); in xhci_run_finished()
621 temp = readl(&xhci->op_regs->command); in xhci_run_finished()
623 writel(temp, &xhci->op_regs->command); in xhci_run_finished()
630 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_run_finished()
631 return -ENODEV; in xhci_run_finished()
634 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; in xhci_run_finished()
636 if (xhci->quirks & XHCI_NEC_HOST) in xhci_run_finished()
639 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_run_finished()
654 * Setup MSI-X vectors and enable interrupts.
661 struct xhci_interrupter *ir = xhci->interrupters[0]; in xhci_run()
666 hcd->uses_new_polling = 1; in xhci_run()
667 if (hcd->msi_enabled) in xhci_run()
668 ir->ip_autoclear = true; in xhci_run()
675 temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); in xhci_run()
680 xhci_set_interrupter_moderation(ir, xhci->imod_interval); in xhci_run()
682 if (xhci->quirks & XHCI_NEC_HOST) { in xhci_run()
687 return -ENOMEM; in xhci_run()
704 set_bit(HCD_FLAG_DEFER_RH_REGISTER, &hcd->flags); in xhci_run()
723 struct xhci_interrupter *ir = xhci->interrupters[0]; in xhci_stop()
725 mutex_lock(&xhci->mutex); in xhci_stop()
729 mutex_unlock(&xhci->mutex); in xhci_stop()
735 spin_lock_irq(&xhci->lock); in xhci_stop()
736 xhci->xhc_state |= XHCI_STATE_HALTED; in xhci_stop()
737 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; in xhci_stop()
740 spin_unlock_irq(&xhci->lock); in xhci_stop()
743 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_stop()
745 timer_delete_sync(&xhci->comp_mode_recovery_timer); in xhci_stop()
751 if (xhci->quirks & XHCI_AMD_PLL_FIX) in xhci_stop()
756 temp = readl(&xhci->op_regs->status); in xhci_stop()
757 writel((temp & ~0x1fff) | STS_EINT, &xhci->op_regs->status); in xhci_stop()
764 "xhci_stop completed - status = %x", in xhci_stop()
765 readl(&xhci->op_regs->status)); in xhci_stop()
766 mutex_unlock(&xhci->mutex); in xhci_stop()
771 * Shutdown HC (not bus-specific)
783 if (xhci->quirks & XHCI_SPURIOUS_REBOOT) in xhci_shutdown()
784 usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev)); in xhci_shutdown()
788 __func__, hcd->self.busnum); in xhci_shutdown()
789 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in xhci_shutdown()
790 timer_delete_sync(&hcd->rh_timer); in xhci_shutdown()
792 if (xhci->shared_hcd) { in xhci_shutdown()
793 clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); in xhci_shutdown()
794 timer_delete_sync(&xhci->shared_hcd->rh_timer); in xhci_shutdown()
797 spin_lock_irq(&xhci->lock); in xhci_shutdown()
802 * firmware delay in ADL-P PCH if port are left in U3 at shutdown in xhci_shutdown()
804 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP || in xhci_shutdown()
805 xhci->quirks & XHCI_RESET_TO_DEFAULT) in xhci_shutdown()
808 spin_unlock_irq(&xhci->lock); in xhci_shutdown()
811 "xhci_shutdown completed - status = %x", in xhci_shutdown()
812 readl(&xhci->op_regs->status)); in xhci_shutdown()
822 xhci->s3.command = readl(&xhci->op_regs->command); in xhci_save_registers()
823 xhci->s3.dev_nt = readl(&xhci->op_regs->dev_notification); in xhci_save_registers()
824 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); in xhci_save_registers()
825 xhci->s3.config_reg = readl(&xhci->op_regs->config_reg); in xhci_save_registers()
829 for (i = 0; i < xhci->max_interrupters; i++) { in xhci_save_registers()
830 ir = xhci->interrupters[i]; in xhci_save_registers()
834 ir->s3_erst_size = readl(&ir->ir_set->erst_size); in xhci_save_registers()
835 ir->s3_erst_base = xhci_read_64(xhci, &ir->ir_set->erst_base); in xhci_save_registers()
836 ir->s3_erst_dequeue = xhci_read_64(xhci, &ir->ir_set->erst_dequeue); in xhci_save_registers()
837 ir->s3_iman = readl(&ir->ir_set->iman); in xhci_save_registers()
838 ir->s3_imod = readl(&ir->ir_set->imod); in xhci_save_registers()
847 writel(xhci->s3.command, &xhci->op_regs->command); in xhci_restore_registers()
848 writel(xhci->s3.dev_nt, &xhci->op_regs->dev_notification); in xhci_restore_registers()
849 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr); in xhci_restore_registers()
850 writel(xhci->s3.config_reg, &xhci->op_regs->config_reg); in xhci_restore_registers()
853 for (i = 0; i < xhci->max_interrupters; i++) { in xhci_restore_registers()
854 ir = xhci->interrupters[i]; in xhci_restore_registers()
858 writel(ir->s3_erst_size, &ir->ir_set->erst_size); in xhci_restore_registers()
859 xhci_write_64(xhci, ir->s3_erst_base, &ir->ir_set->erst_base); in xhci_restore_registers()
860 xhci_write_64(xhci, ir->s3_erst_dequeue, &ir->ir_set->erst_dequeue); in xhci_restore_registers()
861 writel(ir->s3_iman, &ir->ir_set->iman); in xhci_restore_registers()
862 writel(ir->s3_imod, &ir->ir_set->imod); in xhci_restore_registers()
870 * need to re-program it on resume. Unfortunately, the pointer must be 64-byte
873 * middle of the ring (TRBs are 16-byte aligned).
880 ring = xhci->cmd_ring; in xhci_clear_command_ring()
881 xhci_for_each_ring_seg(ring->first_seg, seg) { in xhci_clear_command_ring()
883 memset(seg->trbs, 0, sizeof(union xhci_trb) * (TRBS_PER_SEGMENT - 1)); in xhci_clear_command_ring()
885 seg->trbs[TRBS_PER_SEGMENT - 1].link.control &= cpu_to_le32(~TRB_CYCLE); in xhci_clear_command_ring()
891 * Yes, this will need to be re-written after resume, but we're paranoid in xhci_clear_command_ring()
916 spin_lock_irqsave(&xhci->lock, flags); in xhci_disable_hub_port_wake()
918 for (i = 0; i < rhub->num_ports; i++) { in xhci_disable_hub_port_wake()
919 portsc = readl(rhub->ports[i]->addr); in xhci_disable_hub_port_wake()
932 writel(t2, rhub->ports[i]->addr); in xhci_disable_hub_port_wake()
933 xhci_dbg(xhci, "config port %d-%d wake bits, portsc: 0x%x, write: 0x%x\n", in xhci_disable_hub_port_wake()
934 rhub->hcd->self.busnum, i + 1, portsc, t2); in xhci_disable_hub_port_wake()
937 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_disable_hub_port_wake()
947 status = readl(&xhci->op_regs->status); in xhci_pending_portevent()
956 port_index = xhci->usb2_rhub.num_ports; in xhci_pending_portevent()
957 ports = xhci->usb2_rhub.ports; in xhci_pending_portevent()
958 while (port_index--) { in xhci_pending_portevent()
959 portsc = readl(ports[port_index]->addr); in xhci_pending_portevent()
964 port_index = xhci->usb3_rhub.num_ports; in xhci_pending_portevent()
965 ports = xhci->usb3_rhub.ports; in xhci_pending_portevent()
966 while (port_index--) { in xhci_pending_portevent()
967 portsc = readl(ports[port_index]->addr); in xhci_pending_portevent()
976 * Stop HC (not bus-specific)
989 if (!hcd->state) in xhci_suspend()
992 if (hcd->state != HC_STATE_SUSPENDED || in xhci_suspend()
993 (xhci->shared_hcd && xhci->shared_hcd->state != HC_STATE_SUSPENDED)) in xhci_suspend()
994 return -EINVAL; in xhci_suspend()
997 xhci_disable_hub_port_wake(xhci, &xhci->usb3_rhub, do_wakeup); in xhci_suspend()
998 xhci_disable_hub_port_wake(xhci, &xhci->usb2_rhub, do_wakeup); in xhci_suspend()
1007 __func__, hcd->self.busnum); in xhci_suspend()
1008 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in xhci_suspend()
1009 timer_delete_sync(&hcd->rh_timer); in xhci_suspend()
1010 if (xhci->shared_hcd) { in xhci_suspend()
1011 clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); in xhci_suspend()
1012 timer_delete_sync(&xhci->shared_hcd->rh_timer); in xhci_suspend()
1015 if (xhci->quirks & XHCI_SUSPEND_DELAY) in xhci_suspend()
1018 spin_lock_irq(&xhci->lock); in xhci_suspend()
1019 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); in xhci_suspend()
1020 if (xhci->shared_hcd) in xhci_suspend()
1021 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); in xhci_suspend()
1026 command = readl(&xhci->op_regs->command); in xhci_suspend()
1028 writel(command, &xhci->op_regs->command); in xhci_suspend()
1031 delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1; in xhci_suspend()
1033 if (xhci_handshake(&xhci->op_regs->status, in xhci_suspend()
1036 spin_unlock_irq(&xhci->lock); in xhci_suspend()
1037 return -ETIMEDOUT; in xhci_suspend()
1045 command = readl(&xhci->op_regs->command); in xhci_suspend()
1047 writel(command, &xhci->op_regs->command); in xhci_suspend()
1048 xhci->broken_suspend = 0; in xhci_suspend()
1049 if (xhci_handshake(&xhci->op_regs->status, in xhci_suspend()
1060 res = readl(&xhci->op_regs->status); in xhci_suspend()
1061 if ((xhci->quirks & XHCI_SNPS_BROKEN_SUSPEND) && in xhci_suspend()
1064 xhci->broken_suspend = 1; in xhci_suspend()
1067 spin_unlock_irq(&xhci->lock); in xhci_suspend()
1068 return -ETIMEDOUT; in xhci_suspend()
1071 spin_unlock_irq(&xhci->lock); in xhci_suspend()
1077 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_suspend()
1079 timer_delete_sync(&xhci->comp_mode_recovery_timer); in xhci_suspend()
1090 * start xHC (not bus-specific)
1104 if (!hcd->state) in xhci_resume()
1111 if (time_before(jiffies, xhci->usb2_rhub.bus_state.next_statechange) || in xhci_resume()
1112 time_before(jiffies, xhci->usb3_rhub.bus_state.next_statechange)) in xhci_resume()
1115 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); in xhci_resume()
1116 if (xhci->shared_hcd) in xhci_resume()
1117 set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); in xhci_resume()
1119 spin_lock_irq(&xhci->lock); in xhci_resume()
1121 if (xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_suspend) in xhci_resume()
1129 retval = xhci_handshake(&xhci->op_regs->status, in xhci_resume()
1134 spin_unlock_irq(&xhci->lock); in xhci_resume()
1143 command = readl(&xhci->op_regs->command); in xhci_resume()
1145 writel(command, &xhci->op_regs->command); in xhci_resume()
1151 if (xhci_handshake(&xhci->op_regs->status, in xhci_resume()
1154 spin_unlock_irq(&xhci->lock); in xhci_resume()
1155 return -ETIMEDOUT; in xhci_resume()
1159 temp = readl(&xhci->op_regs->status); in xhci_resume()
1161 /* re-initialize the HC on Restore Error, or Host Controller Error */ in xhci_resume()
1163 !(xhci->xhc_state & XHCI_STATE_REMOVING)) { in xhci_resume()
1170 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_resume()
1172 timer_delete_sync(&xhci->comp_mode_recovery_timer); in xhci_resume()
1178 usb_root_hub_lost_power(xhci->main_hcd->self.root_hub); in xhci_resume()
1179 if (xhci->shared_hcd) in xhci_resume()
1180 usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub); in xhci_resume()
1186 spin_unlock_irq(&xhci->lock); in xhci_resume()
1191 temp = readl(&xhci->op_regs->status); in xhci_resume()
1192 writel((temp & ~0x1fff) | STS_EINT, &xhci->op_regs->status); in xhci_resume()
1193 xhci_disable_interrupter(xhci, xhci->interrupters[0]); in xhci_resume()
1198 xhci_dbg(xhci, "xhci_stop completed - status = %x\n", in xhci_resume()
1199 readl(&xhci->op_regs->status)); in xhci_resume()
1213 if (!retval && xhci->shared_hcd) { in xhci_resume()
1215 retval = xhci_run(xhci->shared_hcd); in xhci_resume()
1223 hcd->state = HC_STATE_SUSPENDED; in xhci_resume()
1225 if (xhci->shared_hcd) { in xhci_resume()
1226 xhci->shared_hcd->state = HC_STATE_SUSPENDED; in xhci_resume()
1227 usb_hcd_resume_root_hub(xhci->shared_hcd); in xhci_resume()
1235 command = readl(&xhci->op_regs->command); in xhci_resume()
1237 writel(command, &xhci->op_regs->command); in xhci_resume()
1238 xhci_handshake(&xhci->op_regs->status, STS_HALT, in xhci_resume()
1250 spin_unlock_irq(&xhci->lock); in xhci_resume()
1261 if (xhci->usb3_rhub.bus_state.suspended_ports || in xhci_resume()
1262 xhci->usb3_rhub.bus_state.bus_suspended) in xhci_resume()
1273 if (xhci->shared_hcd) in xhci_resume()
1274 usb_hcd_resume_root_hub(xhci->shared_hcd); in xhci_resume()
1281 * be re-initialized Always after a system resume. Ports are subject in xhci_resume()
1285 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !comp_timer_running) in xhci_resume()
1288 if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL) in xhci_resume()
1289 usb_asmedia_modifyflowcontrol(to_pci_dev(hcd->self.controller)); in xhci_resume()
1291 /* Re-enable port polling. */ in xhci_resume()
1293 __func__, hcd->self.busnum); in xhci_resume()
1294 if (xhci->shared_hcd) { in xhci_resume()
1295 set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); in xhci_resume()
1296 usb_hcd_poll_rh_status(xhci->shared_hcd); in xhci_resume()
1298 set_bit(HCD_FLAG_POLL_RH, &hcd->flags); in xhci_resume()
1306 /*-------------------------------------------------------------------------*/
1316 buf_len = urb->transfer_buffer_length; in xhci_map_temp_buffer()
1319 dev_to_node(hcd->self.sysdev)); in xhci_map_temp_buffer()
1321 return -ENOMEM; in xhci_map_temp_buffer()
1324 sg_pcopy_to_buffer(urb->sg, urb->num_sgs, in xhci_map_temp_buffer()
1327 urb->transfer_buffer = temp; in xhci_map_temp_buffer()
1328 urb->transfer_dma = dma_map_single(hcd->self.sysdev, in xhci_map_temp_buffer()
1329 urb->transfer_buffer, in xhci_map_temp_buffer()
1330 urb->transfer_buffer_length, in xhci_map_temp_buffer()
1333 if (dma_mapping_error(hcd->self.sysdev, in xhci_map_temp_buffer()
1334 urb->transfer_dma)) { in xhci_map_temp_buffer()
1335 ret = -EAGAIN; in xhci_map_temp_buffer()
1338 urb->transfer_flags |= URB_DMA_MAP_SINGLE; in xhci_map_temp_buffer()
1355 tail_sg = urb->sg; in xhci_urb_temp_buffer_required()
1356 max_pkt = usb_endpoint_maxp(&urb->ep->desc); in xhci_urb_temp_buffer_required()
1358 if (!urb->num_sgs) in xhci_urb_temp_buffer_required()
1361 if (urb->dev->speed >= USB_SPEED_SUPER) in xhci_urb_temp_buffer_required()
1366 if (urb->transfer_buffer_length != 0 && in xhci_urb_temp_buffer_required()
1367 !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) { in xhci_urb_temp_buffer_required()
1368 for_each_sg(urb->sg, sg, urb->num_sgs, i) { in xhci_urb_temp_buffer_required()
1369 len = len + sg->length; in xhci_urb_temp_buffer_required()
1370 if (i > trb_size - 2) { in xhci_urb_temp_buffer_required()
1371 len = len - tail_sg->length; in xhci_urb_temp_buffer_required()
1392 buf_len = urb->transfer_buffer_length; in xhci_unmap_temp_buf()
1395 (urb->transfer_flags & URB_DMA_MAP_SINGLE)) in xhci_unmap_temp_buf()
1396 dma_unmap_single(hcd->self.sysdev, in xhci_unmap_temp_buf()
1397 urb->transfer_dma, in xhci_unmap_temp_buf()
1398 urb->transfer_buffer_length, in xhci_unmap_temp_buf()
1402 len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs, in xhci_unmap_temp_buf()
1403 urb->transfer_buffer, in xhci_unmap_temp_buf()
1409 urb->actual_length = len; in xhci_unmap_temp_buf()
1412 urb->transfer_flags &= ~URB_DMA_MAP_SINGLE; in xhci_unmap_temp_buf()
1413 kfree(urb->transfer_buffer); in xhci_unmap_temp_buf()
1414 urb->transfer_buffer = NULL; in xhci_unmap_temp_buf()
1433 if (xhci->quirks & XHCI_SG_TRB_CACHE_SIZE_QUIRK) { in xhci_map_urb_for_dma()
1447 if (urb->num_sgs && (urb->transfer_flags & URB_DMA_MAP_SINGLE)) in xhci_unmap_urb_for_dma()
1450 if ((xhci->quirks & XHCI_SG_TRB_CACHE_SIZE_QUIRK) && unmap_temp_buf) in xhci_unmap_urb_for_dma()
1457 * xhci_get_endpoint_index - Used for passing endpoint bitmasks between the core and
1462 * Index = (epnum * 2) + direction - 1,
1465 * index = (epnum * 2) + direction - 1 = (epnum * 2) + 1 - 1 = (epnum * 2)
1474 (usb_endpoint_dir_in(desc) ? 1 : 0) - 1; in xhci_get_endpoint_index()
1506 return fls(added_ctxs) - 1; in xhci_last_valid_endpoint()
1510 * returns 0 this is a root hub; returns -EINVAL for NULL pointers.
1520 return -EINVAL; in xhci_check_args()
1522 if (!udev->parent) { in xhci_check_args()
1529 if (!udev->slot_id || !xhci->devs[udev->slot_id]) { in xhci_check_args()
1532 return -EINVAL; in xhci_check_args()
1535 virt_dev = xhci->devs[udev->slot_id]; in xhci_check_args()
1536 if (virt_dev->udev != udev) { in xhci_check_args()
1539 return -EINVAL; in xhci_check_args()
1543 if (xhci->xhc_state & XHCI_STATE_HALTED) in xhci_check_args()
1544 return -ENODEV; in xhci_check_args()
1568 ep_ctx = xhci_get_ep_ctx(xhci, vdev->out_ctx, 0); in xhci_check_ep0_maxpacket()
1569 hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2)); in xhci_check_ep0_maxpacket()
1570 max_packet_size = usb_endpoint_maxp(&vdev->udev->ep0.desc); in xhci_check_ep0_maxpacket()
1590 return -ENOMEM; in xhci_check_ep0_maxpacket()
1592 command->in_ctx = vdev->in_ctx; in xhci_check_ep0_maxpacket()
1593 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx); in xhci_check_ep0_maxpacket()
1597 ret = -ENOMEM; in xhci_check_ep0_maxpacket()
1601 xhci_endpoint_copy(xhci, vdev->in_ctx, vdev->out_ctx, 0); in xhci_check_ep0_maxpacket()
1603 ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, 0); in xhci_check_ep0_maxpacket()
1604 ep_ctx->ep_info &= cpu_to_le32(~EP_STATE_MASK);/* must clear */ in xhci_check_ep0_maxpacket()
1605 ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK); in xhci_check_ep0_maxpacket()
1606 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size)); in xhci_check_ep0_maxpacket()
1608 ctrl_ctx->add_flags = cpu_to_le32(EP0_FLAG); in xhci_check_ep0_maxpacket()
1609 ctrl_ctx->drop_flags = 0; in xhci_check_ep0_maxpacket()
1611 ret = xhci_configure_endpoint(xhci, vdev->udev, command, in xhci_check_ep0_maxpacket()
1614 ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG); in xhci_check_ep0_maxpacket()
1617 dev_dbg(&vdev->udev->dev, "incorrect max packet size %d for ep0\n", in xhci_check_ep0_maxpacket()
1619 return -EINVAL; in xhci_check_ep0_maxpacket()
1622 kfree(command->completion); in xhci_check_ep0_maxpacket()
1629 * non-error returns are a promise to giveback() the urb later
1642 ep_index = xhci_get_endpoint_index(&urb->ep->desc); in xhci_urb_enqueue()
1644 if (usb_endpoint_xfer_isoc(&urb->ep->desc)) in xhci_urb_enqueue()
1645 num_tds = urb->number_of_packets; in xhci_urb_enqueue()
1646 else if (usb_endpoint_is_bulk_out(&urb->ep->desc) && in xhci_urb_enqueue()
1647 urb->transfer_buffer_length > 0 && in xhci_urb_enqueue()
1648 urb->transfer_flags & URB_ZERO_PACKET && in xhci_urb_enqueue()
1649 !(urb->transfer_buffer_length % usb_endpoint_maxp(&urb->ep->desc))) in xhci_urb_enqueue()
1656 return -ENOMEM; in xhci_urb_enqueue()
1658 urb_priv->num_tds = num_tds; in xhci_urb_enqueue()
1659 urb_priv->num_tds_done = 0; in xhci_urb_enqueue()
1660 urb->hcpriv = urb_priv; in xhci_urb_enqueue()
1664 spin_lock_irqsave(&xhci->lock, flags); in xhci_urb_enqueue()
1666 ret = xhci_check_args(hcd, urb->dev, urb->ep, in xhci_urb_enqueue()
1669 ret = ret ? ret : -EINVAL; in xhci_urb_enqueue()
1673 slot_id = urb->dev->slot_id; in xhci_urb_enqueue()
1676 ret = -ESHUTDOWN; in xhci_urb_enqueue()
1680 if (xhci->devs[slot_id]->flags & VDEV_PORT_ERROR) { in xhci_urb_enqueue()
1682 ret = -ENODEV; in xhci_urb_enqueue()
1686 if (xhci->xhc_state & XHCI_STATE_DYING) { in xhci_urb_enqueue()
1687 xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for non-responsive xHCI host.\n", in xhci_urb_enqueue()
1688 urb->ep->desc.bEndpointAddress, urb); in xhci_urb_enqueue()
1689 ret = -ESHUTDOWN; in xhci_urb_enqueue()
1693 ep_state = &xhci->devs[slot_id]->eps[ep_index].ep_state; in xhci_urb_enqueue()
1698 ret = -EINVAL; in xhci_urb_enqueue()
1703 ret = -EINVAL; in xhci_urb_enqueue()
1707 switch (usb_endpoint_type(&urb->ep->desc)) { in xhci_urb_enqueue()
1729 urb->hcpriv = NULL; in xhci_urb_enqueue()
1731 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_urb_enqueue()
1751 * series of 1-TRB transfer no-op TDs. (No-ops shouldn't be chained.) The
1781 spin_lock_irqsave(&xhci->lock, flags); in xhci_urb_dequeue()
1791 vdev = xhci->devs[urb->dev->slot_id]; in xhci_urb_dequeue()
1792 urb_priv = urb->hcpriv; in xhci_urb_dequeue()
1796 ep_index = xhci_get_endpoint_index(&urb->ep->desc); in xhci_urb_dequeue()
1797 ep = &vdev->eps[ep_index]; in xhci_urb_dequeue()
1803 temp = readl(&xhci->op_regs->status); in xhci_urb_dequeue()
1804 if (temp == ~(u32)0 || xhci->xhc_state & XHCI_STATE_DYING) { in xhci_urb_dequeue()
1810 * check ring is not re-allocated since URB was enqueued. If it is, then in xhci_urb_dequeue()
1814 if (!td_on_ring(&urb_priv->td[0], ep_ring)) { in xhci_urb_dequeue()
1816 for (i = urb_priv->num_tds_done; i < urb_priv->num_tds; i++) { in xhci_urb_dequeue()
1817 td = &urb_priv->td[i]; in xhci_urb_dequeue()
1818 if (!list_empty(&td->cancelled_td_list)) in xhci_urb_dequeue()
1819 list_del_init(&td->cancelled_td_list); in xhci_urb_dequeue()
1824 if (xhci->xhc_state & XHCI_STATE_HALTED) { in xhci_urb_dequeue()
1827 for (i = urb_priv->num_tds_done; in xhci_urb_dequeue()
1828 i < urb_priv->num_tds; in xhci_urb_dequeue()
1830 td = &urb_priv->td[i]; in xhci_urb_dequeue()
1831 if (!list_empty(&td->td_list)) in xhci_urb_dequeue()
1832 list_del_init(&td->td_list); in xhci_urb_dequeue()
1833 if (!list_empty(&td->cancelled_td_list)) in xhci_urb_dequeue()
1834 list_del_init(&td->cancelled_td_list); in xhci_urb_dequeue()
1839 i = urb_priv->num_tds_done; in xhci_urb_dequeue()
1840 if (i < urb_priv->num_tds) in xhci_urb_dequeue()
1844 urb, urb->dev->devpath, in xhci_urb_dequeue()
1845 urb->ep->desc.bEndpointAddress, in xhci_urb_dequeue()
1847 urb_priv->td[i].start_seg, in xhci_urb_dequeue()
1848 urb_priv->td[i].start_trb)); in xhci_urb_dequeue()
1850 for (; i < urb_priv->num_tds; i++) { in xhci_urb_dequeue()
1851 td = &urb_priv->td[i]; in xhci_urb_dequeue()
1853 if (list_empty(&td->cancelled_td_list)) { in xhci_urb_dequeue()
1854 td->cancel_status = TD_DIRTY; in xhci_urb_dequeue()
1855 list_add_tail(&td->cancelled_td_list, in xhci_urb_dequeue()
1856 &ep->cancelled_td_list); in xhci_urb_dequeue()
1861 if (ep->ep_state & (EP_STOP_CMD_PENDING | EP_HALTED | SET_DEQ_PENDING)) { in xhci_urb_dequeue()
1863 urb->dev->slot_id, ep_index, ep->ep_state); in xhci_urb_dequeue()
1868 if (ep->ep_state & EP_CLEARING_TT) { in xhci_urb_dequeue()
1871 urb->dev->slot_id, ep_index, ep->ep_state); in xhci_urb_dequeue()
1877 ret = -ENOMEM; in xhci_urb_dequeue()
1880 ep->stop_time = jiffies; in xhci_urb_dequeue()
1881 ep->ep_state |= EP_STOP_CMD_PENDING; in xhci_urb_dequeue()
1882 xhci_queue_stop_endpoint(xhci, command, urb->dev->slot_id, in xhci_urb_dequeue()
1887 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_urb_dequeue()
1894 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_urb_dequeue()
1895 usb_hcd_giveback_urb(hcd, urb, -ESHUTDOWN); in xhci_urb_dequeue()
1910 * the xhci->devs[slot_id] structure.
1928 if (xhci->xhc_state & XHCI_STATE_DYING) in xhci_drop_endpoint()
1929 return -ENODEV; in xhci_drop_endpoint()
1932 drop_flag = xhci_get_endpoint_flag(&ep->desc); in xhci_drop_endpoint()
1934 xhci_dbg(xhci, "xHCI %s - can't drop slot or ep 0 %#x\n", in xhci_drop_endpoint()
1939 in_ctx = xhci->devs[udev->slot_id]->in_ctx; in xhci_drop_endpoint()
1940 out_ctx = xhci->devs[udev->slot_id]->out_ctx; in xhci_drop_endpoint()
1948 ep_index = xhci_get_endpoint_index(&ep->desc); in xhci_drop_endpoint()
1954 le32_to_cpu(ctrl_ctx->drop_flags) & in xhci_drop_endpoint()
1955 xhci_get_endpoint_flag(&ep->desc)) { in xhci_drop_endpoint()
1957 if (xhci->devs[udev->slot_id]->eps[ep_index].ring != NULL) in xhci_drop_endpoint()
1963 ctrl_ctx->drop_flags |= cpu_to_le32(drop_flag); in xhci_drop_endpoint()
1964 new_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags); in xhci_drop_endpoint()
1966 ctrl_ctx->add_flags &= cpu_to_le32(~drop_flag); in xhci_drop_endpoint()
1967 new_add_flags = le32_to_cpu(ctrl_ctx->add_flags); in xhci_drop_endpoint()
1969 xhci_debugfs_remove_endpoint(xhci, xhci->devs[udev->slot_id], ep_index); in xhci_drop_endpoint()
1971 xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep); in xhci_drop_endpoint()
1974 (unsigned int) ep->desc.bEndpointAddress, in xhci_drop_endpoint()
1975 udev->slot_id, in xhci_drop_endpoint()
1993 * for mutual exclusion to protect the xhci->devs[slot_id] structure.
2011 ep->hcpriv = NULL; in xhci_add_endpoint()
2015 if (xhci->xhc_state & XHCI_STATE_DYING) in xhci_add_endpoint()
2016 return -ENODEV; in xhci_add_endpoint()
2018 added_ctxs = xhci_get_endpoint_flag(&ep->desc); in xhci_add_endpoint()
2024 xhci_dbg(xhci, "xHCI %s - can't add slot or ep 0 %#x\n", in xhci_add_endpoint()
2029 virt_dev = xhci->devs[udev->slot_id]; in xhci_add_endpoint()
2030 in_ctx = virt_dev->in_ctx; in xhci_add_endpoint()
2038 ep_index = xhci_get_endpoint_index(&ep->desc); in xhci_add_endpoint()
2042 if (virt_dev->eps[ep_index].ring && in xhci_add_endpoint()
2043 !(le32_to_cpu(ctrl_ctx->drop_flags) & added_ctxs)) { in xhci_add_endpoint()
2046 (unsigned int) ep->desc.bEndpointAddress); in xhci_add_endpoint()
2047 return -EINVAL; in xhci_add_endpoint()
2053 if (le32_to_cpu(ctrl_ctx->add_flags) & added_ctxs) { in xhci_add_endpoint()
2065 dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n", in xhci_add_endpoint()
2066 __func__, ep->desc.bEndpointAddress); in xhci_add_endpoint()
2067 return -ENOMEM; in xhci_add_endpoint()
2070 ctrl_ctx->add_flags |= cpu_to_le32(added_ctxs); in xhci_add_endpoint()
2071 new_add_flags = le32_to_cpu(ctrl_ctx->add_flags); in xhci_add_endpoint()
2075 * this re-adds a new state for the endpoint from the new endpoint in xhci_add_endpoint()
2076 * descriptors. We must drop and re-add this endpoint, so we leave the in xhci_add_endpoint()
2079 new_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags); in xhci_add_endpoint()
2082 ep->hcpriv = udev; in xhci_add_endpoint()
2084 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); in xhci_add_endpoint()
2088 (unsigned int) ep->desc.bEndpointAddress, in xhci_add_endpoint()
2089 udev->slot_id, in xhci_add_endpoint()
2103 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx); in xhci_zero_in_ctx()
2115 ctrl_ctx->drop_flags = 0; in xhci_zero_in_ctx()
2116 ctrl_ctx->add_flags = 0; in xhci_zero_in_ctx()
2117 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); in xhci_zero_in_ctx()
2118 slot_ctx->dev_info &= cpu_to_le32(~LAST_CTX_MASK); in xhci_zero_in_ctx()
2120 slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1)); in xhci_zero_in_ctx()
2122 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, i); in xhci_zero_in_ctx()
2123 ep_ctx->ep_info = 0; in xhci_zero_in_ctx()
2124 ep_ctx->ep_info2 = 0; in xhci_zero_in_ctx()
2125 ep_ctx->deq = 0; in xhci_zero_in_ctx()
2126 ep_ctx->tx_info = 0; in xhci_zero_in_ctx()
2139 ret = -ETIME; in xhci_configure_endpoint_result()
2142 dev_warn(&udev->dev, in xhci_configure_endpoint_result()
2144 ret = -ENOMEM; in xhci_configure_endpoint_result()
2149 dev_warn(&udev->dev, in xhci_configure_endpoint_result()
2151 ret = -ENOSPC; in xhci_configure_endpoint_result()
2156 dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, " in xhci_configure_endpoint_result()
2159 ret = -EINVAL; in xhci_configure_endpoint_result()
2162 dev_warn(&udev->dev, in xhci_configure_endpoint_result()
2164 ret = -ENODEV; in xhci_configure_endpoint_result()
2174 ret = -EINVAL; in xhci_configure_endpoint_result()
2189 ret = -ETIME; in xhci_evaluate_context_result()
2192 dev_warn(&udev->dev, in xhci_evaluate_context_result()
2194 ret = -EINVAL; in xhci_evaluate_context_result()
2197 dev_warn(&udev->dev, in xhci_evaluate_context_result()
2199 ret = -EINVAL; in xhci_evaluate_context_result()
2202 dev_warn(&udev->dev, in xhci_evaluate_context_result()
2204 ret = -EINVAL; in xhci_evaluate_context_result()
2207 dev_warn(&udev->dev, in xhci_evaluate_context_result()
2209 ret = -ENODEV; in xhci_evaluate_context_result()
2213 dev_warn(&udev->dev, "WARN: Max Exit Latency too large\n"); in xhci_evaluate_context_result()
2214 ret = -EINVAL; in xhci_evaluate_context_result()
2224 ret = -EINVAL; in xhci_evaluate_context_result()
2240 valid_add_flags = le32_to_cpu(ctrl_ctx->add_flags) >> 2; in xhci_count_num_new_endpoints()
2241 valid_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags) >> 2; in xhci_count_num_new_endpoints()
2247 return hweight32(valid_add_flags) - in xhci_count_num_new_endpoints()
2257 valid_add_flags = le32_to_cpu(ctrl_ctx->add_flags) >> 2; in xhci_count_num_dropped_endpoints()
2258 valid_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags) >> 2; in xhci_count_num_dropped_endpoints()
2260 return hweight32(valid_drop_flags) - in xhci_count_num_dropped_endpoints()
2270 * - the first configure endpoint command drops more endpoints than it adds
2271 * - a second configure endpoint command that adds more endpoints is queued
2272 * - the first configure endpoint command fails, so the config is unchanged
2273 * - the second command may succeed, even though there isn't enough resources
2275 * Must be called with xhci->lock held.
2283 if (xhci->num_active_eps + added_eps > xhci->limit_active_eps) { in xhci_reserve_host_resources()
2287 xhci->num_active_eps, added_eps, in xhci_reserve_host_resources()
2288 xhci->limit_active_eps); in xhci_reserve_host_resources()
2289 return -ENOMEM; in xhci_reserve_host_resources()
2291 xhci->num_active_eps += added_eps; in xhci_reserve_host_resources()
2294 xhci->num_active_eps); in xhci_reserve_host_resources()
2302 * Must be called with xhci->lock held.
2310 xhci->num_active_eps -= num_failed_eps; in xhci_free_host_resources()
2314 xhci->num_active_eps); in xhci_free_host_resources()
2321 * Must be called with xhci->lock held.
2329 xhci->num_active_eps -= num_dropped_eps; in xhci_finish_resource_reservation()
2334 xhci->num_active_eps); in xhci_finish_resource_reservation()
2339 switch (udev->speed) { in xhci_get_block_size()
2358 if (interval_bw->overhead[LS_OVERHEAD_TYPE]) in xhci_get_largest_overhead()
2360 if (interval_bw->overhead[FS_OVERHEAD_TYPE]) in xhci_get_largest_overhead()
2377 bw_table = &xhci->rh_bw[virt_dev->rhub_port->hw_portnum].bw_table; in xhci_check_tt_bw_table()
2378 tt_info = virt_dev->tt_info; in xhci_check_tt_bw_table()
2385 if (old_active_eps == 0 && tt_info->active_eps != 0) { in xhci_check_tt_bw_table()
2386 if (bw_table->bw_used + TT_HS_OVERHEAD > HS_BW_LIMIT) in xhci_check_tt_bw_table()
2387 return -ENOMEM; in xhci_check_tt_bw_table()
2405 if (virt_dev->bw_table->ss_bw_in > (SS_BW_LIMIT_IN - bw_reserved)) in xhci_check_ss_bw()
2406 return -ENOMEM; in xhci_check_ss_bw()
2409 if (virt_dev->bw_table->ss_bw_out > (SS_BW_LIMIT_OUT - bw_reserved)) in xhci_check_ss_bw()
2410 return -ENOMEM; in xhci_check_ss_bw()
2416 * This algorithm is a very conservative estimate of the worst-case scheduling
2424 * over-estimate.
2471 if (virt_dev->udev->speed >= USB_SPEED_SUPER) in xhci_check_bw_table()
2474 if (virt_dev->udev->speed == USB_SPEED_HIGH) { in xhci_check_bw_table()
2483 bw_table = virt_dev->bw_table; in xhci_check_bw_table()
2487 block_size = xhci_get_block_size(virt_dev->udev); in xhci_check_bw_table()
2492 if (virt_dev->tt_info) { in xhci_check_bw_table()
2495 virt_dev->rhub_port->hw_portnum + 1); in xhci_check_bw_table()
2499 return -ENOMEM; in xhci_check_bw_table()
2503 virt_dev->tt_info->slot_id, in xhci_check_bw_table()
2504 virt_dev->tt_info->ttport); in xhci_check_bw_table()
2508 virt_dev->rhub_port->hw_portnum + 1); in xhci_check_bw_table()
2514 bw_used = DIV_ROUND_UP(bw_table->interval0_esit_payload, block_size) + in xhci_check_bw_table()
2515 bw_table->interval_bw[0].num_packets * in xhci_check_bw_table()
2516 xhci_get_largest_overhead(&bw_table->interval_bw[0]); in xhci_check_bw_table()
2529 bw_table->interval_bw[i].num_packets; in xhci_check_bw_table()
2534 if (list_empty(&bw_table->interval_bw[i].endpoints)) in xhci_check_bw_table()
2540 ep_entry = bw_table->interval_bw[i].endpoints.next; in xhci_check_bw_table()
2545 virt_ep->bw_info.max_packet_size, in xhci_check_bw_table()
2553 &bw_table->interval_bw[i]); in xhci_check_bw_table()
2592 return -ENOMEM; in xhci_check_bw_table()
2596 * Ok, we know we have some packets left over after even-handedly in xhci_check_bw_table()
2598 * fit into, so we over-schedule and say they will be scheduled every in xhci_check_bw_table()
2604 if (!virt_dev->tt_info && virt_dev->udev->speed == USB_SPEED_HIGH) { in xhci_check_bw_table()
2610 xhci->rh_bw[virt_dev->rhub_port->hw_portnum].num_active_tts; in xhci_check_bw_table()
2617 (max_bandwidth - bw_used - bw_reserved) * 100 / in xhci_check_bw_table()
2624 return -ENOMEM; in xhci_check_bw_table()
2627 bw_table->bw_used = bw_used; in xhci_check_bw_table()
2645 unsigned int mps = DIV_ROUND_UP(ep_bw->max_packet_size, SS_BLOCK); in xhci_get_ss_bw_consumed()
2647 if (ep_bw->ep_interval == 0) in xhci_get_ss_bw_consumed()
2649 (ep_bw->mult * ep_bw->num_packets * in xhci_get_ss_bw_consumed()
2651 return DIV_ROUND_UP(ep_bw->mult * ep_bw->num_packets * in xhci_get_ss_bw_consumed()
2653 1 << ep_bw->ep_interval); in xhci_get_ss_bw_consumed()
2667 if (xhci_is_async_ep(ep_bw->type)) in xhci_drop_ep_from_interval_table()
2670 if (udev->speed >= USB_SPEED_SUPER) { in xhci_drop_ep_from_interval_table()
2671 if (xhci_is_sync_in_ep(ep_bw->type)) in xhci_drop_ep_from_interval_table()
2672 xhci->devs[udev->slot_id]->bw_table->ss_bw_in -= in xhci_drop_ep_from_interval_table()
2675 xhci->devs[udev->slot_id]->bw_table->ss_bw_out -= in xhci_drop_ep_from_interval_table()
2683 if (list_empty(&virt_ep->bw_endpoint_list)) in xhci_drop_ep_from_interval_table()
2688 if (udev->speed == USB_SPEED_HIGH) in xhci_drop_ep_from_interval_table()
2689 normalized_interval = ep_bw->ep_interval; in xhci_drop_ep_from_interval_table()
2691 normalized_interval = ep_bw->ep_interval - 3; in xhci_drop_ep_from_interval_table()
2694 bw_table->interval0_esit_payload -= ep_bw->max_esit_payload; in xhci_drop_ep_from_interval_table()
2695 interval_bw = &bw_table->interval_bw[normalized_interval]; in xhci_drop_ep_from_interval_table()
2696 interval_bw->num_packets -= ep_bw->num_packets; in xhci_drop_ep_from_interval_table()
2697 switch (udev->speed) { in xhci_drop_ep_from_interval_table()
2699 interval_bw->overhead[LS_OVERHEAD_TYPE] -= 1; in xhci_drop_ep_from_interval_table()
2702 interval_bw->overhead[FS_OVERHEAD_TYPE] -= 1; in xhci_drop_ep_from_interval_table()
2705 interval_bw->overhead[HS_OVERHEAD_TYPE] -= 1; in xhci_drop_ep_from_interval_table()
2714 tt_info->active_eps -= 1; in xhci_drop_ep_from_interval_table()
2715 list_del_init(&virt_ep->bw_endpoint_list); in xhci_drop_ep_from_interval_table()
2729 if (xhci_is_async_ep(ep_bw->type)) in xhci_add_ep_to_interval_table()
2732 if (udev->speed == USB_SPEED_SUPER) { in xhci_add_ep_to_interval_table()
2733 if (xhci_is_sync_in_ep(ep_bw->type)) in xhci_add_ep_to_interval_table()
2734 xhci->devs[udev->slot_id]->bw_table->ss_bw_in += in xhci_add_ep_to_interval_table()
2737 xhci->devs[udev->slot_id]->bw_table->ss_bw_out += in xhci_add_ep_to_interval_table()
2745 if (udev->speed == USB_SPEED_HIGH) in xhci_add_ep_to_interval_table()
2746 normalized_interval = ep_bw->ep_interval; in xhci_add_ep_to_interval_table()
2748 normalized_interval = ep_bw->ep_interval - 3; in xhci_add_ep_to_interval_table()
2751 bw_table->interval0_esit_payload += ep_bw->max_esit_payload; in xhci_add_ep_to_interval_table()
2752 interval_bw = &bw_table->interval_bw[normalized_interval]; in xhci_add_ep_to_interval_table()
2753 interval_bw->num_packets += ep_bw->num_packets; in xhci_add_ep_to_interval_table()
2754 switch (udev->speed) { in xhci_add_ep_to_interval_table()
2756 interval_bw->overhead[LS_OVERHEAD_TYPE] += 1; in xhci_add_ep_to_interval_table()
2759 interval_bw->overhead[FS_OVERHEAD_TYPE] += 1; in xhci_add_ep_to_interval_table()
2762 interval_bw->overhead[HS_OVERHEAD_TYPE] += 1; in xhci_add_ep_to_interval_table()
2772 tt_info->active_eps += 1; in xhci_add_ep_to_interval_table()
2774 list_for_each_entry(smaller_ep, &interval_bw->endpoints, in xhci_add_ep_to_interval_table()
2776 if (ep_bw->max_packet_size >= in xhci_add_ep_to_interval_table()
2777 smaller_ep->bw_info.max_packet_size) { in xhci_add_ep_to_interval_table()
2779 list_add_tail(&virt_ep->bw_endpoint_list, in xhci_add_ep_to_interval_table()
2780 &smaller_ep->bw_endpoint_list); in xhci_add_ep_to_interval_table()
2785 list_add_tail(&virt_ep->bw_endpoint_list, in xhci_add_ep_to_interval_table()
2786 &interval_bw->endpoints); in xhci_add_ep_to_interval_table()
2794 if (!virt_dev->tt_info) in xhci_update_tt_active_eps()
2797 rh_bw_info = &xhci->rh_bw[virt_dev->rhub_port->hw_portnum]; in xhci_update_tt_active_eps()
2799 virt_dev->tt_info->active_eps != 0) { in xhci_update_tt_active_eps()
2800 rh_bw_info->num_active_tts += 1; in xhci_update_tt_active_eps()
2801 rh_bw_info->bw_table.bw_used += TT_HS_OVERHEAD; in xhci_update_tt_active_eps()
2803 virt_dev->tt_info->active_eps == 0) { in xhci_update_tt_active_eps()
2804 rh_bw_info->num_active_tts -= 1; in xhci_update_tt_active_eps()
2805 rh_bw_info->bw_table.bw_used -= TT_HS_OVERHEAD; in xhci_update_tt_active_eps()
2818 if (virt_dev->tt_info) in xhci_reserve_bandwidth()
2819 old_active_eps = virt_dev->tt_info->active_eps; in xhci_reserve_bandwidth()
2825 return -ENOMEM; in xhci_reserve_bandwidth()
2833 memcpy(&ep_bw_info[i], &virt_dev->eps[i].bw_info, in xhci_reserve_bandwidth()
2840 &virt_dev->eps[i].bw_info, in xhci_reserve_bandwidth()
2841 virt_dev->bw_table, in xhci_reserve_bandwidth()
2842 virt_dev->udev, in xhci_reserve_bandwidth()
2843 &virt_dev->eps[i], in xhci_reserve_bandwidth()
2844 virt_dev->tt_info); in xhci_reserve_bandwidth()
2847 xhci_update_bw_info(xhci, virt_dev->in_ctx, ctrl_ctx, virt_dev); in xhci_reserve_bandwidth()
2852 &virt_dev->eps[i].bw_info, in xhci_reserve_bandwidth()
2853 virt_dev->bw_table, in xhci_reserve_bandwidth()
2854 virt_dev->udev, in xhci_reserve_bandwidth()
2855 &virt_dev->eps[i], in xhci_reserve_bandwidth()
2856 virt_dev->tt_info); in xhci_reserve_bandwidth()
2877 &virt_dev->eps[i].bw_info, in xhci_reserve_bandwidth()
2878 virt_dev->bw_table, in xhci_reserve_bandwidth()
2879 virt_dev->udev, in xhci_reserve_bandwidth()
2880 &virt_dev->eps[i], in xhci_reserve_bandwidth()
2881 virt_dev->tt_info); in xhci_reserve_bandwidth()
2884 memcpy(&virt_dev->eps[i].bw_info, &ep_bw_info[i], in xhci_reserve_bandwidth()
2889 &virt_dev->eps[i].bw_info, in xhci_reserve_bandwidth()
2890 virt_dev->bw_table, in xhci_reserve_bandwidth()
2891 virt_dev->udev, in xhci_reserve_bandwidth()
2892 &virt_dev->eps[i], in xhci_reserve_bandwidth()
2893 virt_dev->tt_info); in xhci_reserve_bandwidth()
2895 return -ENOMEM; in xhci_reserve_bandwidth()
2916 return -ENOMEM; in xhci_stop_endpoint_sync()
2918 spin_lock_irqsave(&xhci->lock, flags); in xhci_stop_endpoint_sync()
2919 ret = xhci_queue_stop_endpoint(xhci, command, ep->vdev->slot_id, in xhci_stop_endpoint_sync()
2920 ep->ep_index, suspend); in xhci_stop_endpoint_sync()
2922 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_endpoint_sync()
2927 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_stop_endpoint_sync()
2929 wait_for_completion(command->completion); in xhci_stop_endpoint_sync()
2932 if (command->status == COMP_COMMAND_ABORTED || in xhci_stop_endpoint_sync()
2933 command->status == COMP_COMMAND_RING_STOPPED) { in xhci_stop_endpoint_sync()
2935 ret = -ETIME; in xhci_stop_endpoint_sync()
2959 return -EINVAL; in xhci_configure_endpoint()
2961 spin_lock_irqsave(&xhci->lock, flags); in xhci_configure_endpoint()
2963 if (xhci->xhc_state & XHCI_STATE_DYING) { in xhci_configure_endpoint()
2964 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2965 return -ESHUTDOWN; in xhci_configure_endpoint()
2968 virt_dev = xhci->devs[udev->slot_id]; in xhci_configure_endpoint()
2970 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx); in xhci_configure_endpoint()
2972 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2975 return -ENOMEM; in xhci_configure_endpoint()
2978 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK) && in xhci_configure_endpoint()
2980 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2983 xhci->num_active_eps); in xhci_configure_endpoint()
2984 return -ENOMEM; in xhci_configure_endpoint()
2986 if ((xhci->quirks & XHCI_SW_BW_CHECKING) && !ctx_change && in xhci_configure_endpoint()
2987 xhci_reserve_bandwidth(xhci, virt_dev, command->in_ctx)) { in xhci_configure_endpoint()
2988 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) in xhci_configure_endpoint()
2990 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2992 return -ENOMEM; in xhci_configure_endpoint()
2995 slot_ctx = xhci_get_slot_ctx(xhci, command->in_ctx); in xhci_configure_endpoint()
3002 command->in_ctx->dma, in xhci_configure_endpoint()
3003 udev->slot_id, must_succeed); in xhci_configure_endpoint()
3006 command->in_ctx->dma, in xhci_configure_endpoint()
3007 udev->slot_id, must_succeed); in xhci_configure_endpoint()
3009 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) in xhci_configure_endpoint()
3011 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
3014 return -ENOMEM; in xhci_configure_endpoint()
3017 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
3020 wait_for_completion(command->completion); in xhci_configure_endpoint()
3024 &command->status); in xhci_configure_endpoint()
3027 &command->status); in xhci_configure_endpoint()
3029 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) { in xhci_configure_endpoint()
3030 spin_lock_irqsave(&xhci->lock, flags); in xhci_configure_endpoint()
3038 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
3046 struct xhci_virt_ep *ep = &vdev->eps[i]; in xhci_check_bw_drop_ep_streams()
3048 if (ep->ep_state & EP_HAS_STREAMS) { in xhci_check_bw_drop_ep_streams()
3051 xhci_free_stream_info(xhci, ep->stream_info); in xhci_check_bw_drop_ep_streams()
3052 ep->stream_info = NULL; in xhci_check_bw_drop_ep_streams()
3053 ep->ep_state &= ~EP_HAS_STREAMS; in xhci_check_bw_drop_ep_streams()
3064 * else should be touching the xhci->devs[slot_id] structure, so we
3065 * don't need to take the xhci->lock for manipulating that.
3081 if ((xhci->xhc_state & XHCI_STATE_DYING) || in xhci_check_bandwidth()
3082 (xhci->xhc_state & XHCI_STATE_REMOVING)) in xhci_check_bandwidth()
3083 return -ENODEV; in xhci_check_bandwidth()
3086 virt_dev = xhci->devs[udev->slot_id]; in xhci_check_bandwidth()
3090 return -ENOMEM; in xhci_check_bandwidth()
3092 command->in_ctx = virt_dev->in_ctx; in xhci_check_bandwidth()
3094 /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */ in xhci_check_bandwidth()
3095 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx); in xhci_check_bandwidth()
3099 ret = -ENOMEM; in xhci_check_bandwidth()
3102 ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG); in xhci_check_bandwidth()
3103 ctrl_ctx->add_flags &= cpu_to_le32(~EP0_FLAG); in xhci_check_bandwidth()
3104 ctrl_ctx->drop_flags &= cpu_to_le32(~(SLOT_FLAG | EP0_FLAG)); in xhci_check_bandwidth()
3107 if (ctrl_ctx->add_flags == cpu_to_le32(SLOT_FLAG) && in xhci_check_bandwidth()
3108 ctrl_ctx->drop_flags == 0) { in xhci_check_bandwidth()
3113 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); in xhci_check_bandwidth()
3114 for (i = 31; i >= 1; i--) { in xhci_check_bandwidth()
3117 if ((virt_dev->eps[i-1].ring && !(ctrl_ctx->drop_flags & le32)) in xhci_check_bandwidth()
3118 || (ctrl_ctx->add_flags & le32) || i == 1) { in xhci_check_bandwidth()
3119 slot_ctx->dev_info &= cpu_to_le32(~LAST_CTX_MASK); in xhci_check_bandwidth()
3120 slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(i)); in xhci_check_bandwidth()
3133 if ((le32_to_cpu(ctrl_ctx->drop_flags) & (1 << (i + 1))) && in xhci_check_bandwidth()
3134 !(le32_to_cpu(ctrl_ctx->add_flags) & (1 << (i + 1)))) { in xhci_check_bandwidth()
3145 if (!virt_dev->eps[i].new_ring) in xhci_check_bandwidth()
3150 if (virt_dev->eps[i].ring) { in xhci_check_bandwidth()
3154 virt_dev->eps[i].ring = virt_dev->eps[i].new_ring; in xhci_check_bandwidth()
3155 virt_dev->eps[i].new_ring = NULL; in xhci_check_bandwidth()
3159 kfree(command->completion); in xhci_check_bandwidth()
3178 virt_dev = xhci->devs[udev->slot_id]; in xhci_reset_bandwidth()
3181 if (virt_dev->eps[i].new_ring) { in xhci_reset_bandwidth()
3183 xhci_ring_free(xhci, virt_dev->eps[i].new_ring); in xhci_reset_bandwidth()
3184 virt_dev->eps[i].new_ring = NULL; in xhci_reset_bandwidth()
3200 return -EINVAL; in xhci_get_port_bandwidth()
3204 return -ENOMEM; in xhci_get_port_bandwidth()
3206 cmd->in_ctx = ctx; in xhci_get_port_bandwidth()
3209 spin_lock_irqsave(&xhci->lock, flags); in xhci_get_port_bandwidth()
3211 ret = xhci_queue_get_port_bw(xhci, cmd, ctx->dma, dev_speed, 0); in xhci_get_port_bandwidth()
3213 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_get_port_bandwidth()
3217 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_get_port_bandwidth()
3219 wait_for_completion(cmd->completion); in xhci_get_port_bandwidth()
3221 kfree(cmd->completion); in xhci_get_port_bandwidth()
3233 ctrl_ctx->add_flags = cpu_to_le32(add_flags); in xhci_setup_input_ctx_for_config_ep()
3234 ctrl_ctx->drop_flags = cpu_to_le32(drop_flags); in xhci_setup_input_ctx_for_config_ep()
3236 ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG); in xhci_setup_input_ctx_for_config_ep()
3251 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_disable()
3253 udev = (struct usb_device *)host_ep->hcpriv; in xhci_endpoint_disable()
3254 if (!udev || !udev->slot_id) in xhci_endpoint_disable()
3257 vdev = xhci->devs[udev->slot_id]; in xhci_endpoint_disable()
3261 ep_index = xhci_get_endpoint_index(&host_ep->desc); in xhci_endpoint_disable()
3262 ep = &vdev->eps[ep_index]; in xhci_endpoint_disable()
3265 if (ep->ep_state & EP_CLEARING_TT) { in xhci_endpoint_disable()
3266 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_disable()
3271 if (ep->ep_state) in xhci_endpoint_disable()
3273 ep->ep_state); in xhci_endpoint_disable()
3275 host_ep->hcpriv = NULL; in xhci_endpoint_disable()
3276 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_disable()
3290 * vdev may be lost due to xHC restore error and re-initialization during S3/S4
3309 ep_index = xhci_get_endpoint_index(&host_ep->desc); in xhci_endpoint_reset()
3316 if (usb_endpoint_xfer_control(&host_ep->desc) && ep_index == 0) { in xhci_endpoint_reset()
3319 if (udev->speed != USB_SPEED_FULL || !udev->slot_id) in xhci_endpoint_reset()
3322 vdev = xhci->devs[udev->slot_id]; in xhci_endpoint_reset()
3323 if (!vdev || vdev->udev != udev) in xhci_endpoint_reset()
3332 if (!host_ep->hcpriv) in xhci_endpoint_reset()
3334 udev = (struct usb_device *) host_ep->hcpriv; in xhci_endpoint_reset()
3335 vdev = xhci->devs[udev->slot_id]; in xhci_endpoint_reset()
3337 if (!udev->slot_id || !vdev) in xhci_endpoint_reset()
3340 ep = &vdev->eps[ep_index]; in xhci_endpoint_reset()
3343 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_reset()
3344 if (ep->ep_state & EP_HARD_CLEAR_TOGGLE) { in xhci_endpoint_reset()
3345 ep->ep_state &= ~EP_HARD_CLEAR_TOGGLE; in xhci_endpoint_reset()
3346 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3349 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3350 /* Only interrupt and bulk ep's use data toggle, USB2 spec 5.5.4-> */ in xhci_endpoint_reset()
3351 if (usb_endpoint_xfer_control(&host_ep->desc) || in xhci_endpoint_reset()
3352 usb_endpoint_xfer_isoc(&host_ep->desc)) in xhci_endpoint_reset()
3355 ep_flag = xhci_get_endpoint_flag(&host_ep->desc); in xhci_endpoint_reset()
3368 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_reset()
3371 ep->ep_state |= EP_SOFT_CLEAR_TOGGLE; in xhci_endpoint_reset()
3379 if (!list_empty(&ep->ring->td_list)) { in xhci_endpoint_reset()
3380 dev_err(&udev->dev, "EP not empty, refuse reset\n"); in xhci_endpoint_reset()
3381 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3386 err = xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, in xhci_endpoint_reset()
3389 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3397 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3399 wait_for_completion(stop_cmd->completion); in xhci_endpoint_reset()
3401 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_reset()
3404 ctrl_ctx = xhci_get_input_control_ctx(cfg_cmd->in_ctx); in xhci_endpoint_reset()
3406 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3413 xhci_setup_input_ctx_for_config_ep(xhci, cfg_cmd->in_ctx, vdev->out_ctx, in xhci_endpoint_reset()
3415 xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index); in xhci_endpoint_reset()
3417 err = xhci_queue_configure_endpoint(xhci, cfg_cmd, cfg_cmd->in_ctx->dma, in xhci_endpoint_reset()
3418 udev->slot_id, false); in xhci_endpoint_reset()
3420 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3428 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3430 wait_for_completion(cfg_cmd->completion); in xhci_endpoint_reset()
3435 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_reset()
3436 if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE) in xhci_endpoint_reset()
3437 ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE; in xhci_endpoint_reset()
3438 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3450 return -EINVAL; in xhci_check_streams_endpoint()
3453 return ret ? ret : -EINVAL; in xhci_check_streams_endpoint()
3454 if (usb_ss_max_streams(&ep->ss_ep_comp) == 0) { in xhci_check_streams_endpoint()
3457 ep->desc.bEndpointAddress); in xhci_check_streams_endpoint()
3458 return -EINVAL; in xhci_check_streams_endpoint()
3461 ep_index = xhci_get_endpoint_index(&ep->desc); in xhci_check_streams_endpoint()
3462 ep_state = xhci->devs[slot_id]->eps[ep_index].ep_state; in xhci_check_streams_endpoint()
3467 ep->desc.bEndpointAddress); in xhci_check_streams_endpoint()
3470 return -EINVAL; in xhci_check_streams_endpoint()
3472 if (!list_empty(&xhci->devs[slot_id]->eps[ep_index].ring->td_list)) { in xhci_check_streams_endpoint()
3475 ep->desc.bEndpointAddress); in xhci_check_streams_endpoint()
3476 return -EINVAL; in xhci_check_streams_endpoint()
3494 max_streams = HCC_MAX_PSA(xhci->hcc_params); in xhci_calculate_streams_entries()
3519 eps[i], udev->slot_id); in xhci_calculate_streams_and_bitmask()
3523 max_streams = usb_ss_max_streams(&eps[i]->ss_ep_comp); in xhci_calculate_streams_and_bitmask()
3524 if (max_streams < (*num_streams - 1)) { in xhci_calculate_streams_and_bitmask()
3526 eps[i]->desc.bEndpointAddress, in xhci_calculate_streams_and_bitmask()
3531 endpoint_flag = xhci_get_endpoint_flag(&eps[i]->desc); in xhci_calculate_streams_and_bitmask()
3533 return -EINVAL; in xhci_calculate_streams_and_bitmask()
3549 slot_id = udev->slot_id; in xhci_calculate_no_streams_bitmask()
3550 if (!xhci->devs[slot_id]) in xhci_calculate_no_streams_bitmask()
3554 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_calculate_no_streams_bitmask()
3555 ep_state = xhci->devs[slot_id]->eps[ep_index].ep_state; in xhci_calculate_no_streams_bitmask()
3561 eps[i]->desc.bEndpointAddress); in xhci_calculate_no_streams_bitmask()
3570 eps[i]->desc.bEndpointAddress); in xhci_calculate_no_streams_bitmask()
3572 "with non-streams endpoint\n"); in xhci_calculate_no_streams_bitmask()
3575 changed_ep_bitmask |= xhci_get_endpoint_flag(&eps[i]->desc); in xhci_calculate_no_streams_bitmask()
3612 return -EINVAL; in xhci_alloc_streams()
3623 if ((xhci->quirks & XHCI_BROKEN_STREAMS) || in xhci_alloc_streams()
3624 HCC_MAX_PSA(xhci->hcc_params) < 4) { in xhci_alloc_streams()
3626 return -ENOSYS; in xhci_alloc_streams()
3631 return -ENOMEM; in xhci_alloc_streams()
3633 ctrl_ctx = xhci_get_input_control_ctx(config_cmd->in_ctx); in xhci_alloc_streams()
3638 return -ENOMEM; in xhci_alloc_streams()
3645 spin_lock_irqsave(&xhci->lock, flags); in xhci_alloc_streams()
3650 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_streams()
3657 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_streams()
3658 return -EINVAL; in xhci_alloc_streams()
3660 vdev = xhci->devs[udev->slot_id]; in xhci_alloc_streams()
3665 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_alloc_streams()
3666 vdev->eps[ep_index].ep_state |= EP_GETTING_STREAMS; in xhci_alloc_streams()
3668 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_streams()
3679 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_alloc_streams()
3680 max_packet = usb_endpoint_maxp(&eps[i]->desc); in xhci_alloc_streams()
3681 vdev->eps[ep_index].stream_info = xhci_alloc_stream_info(xhci, in xhci_alloc_streams()
3685 if (!vdev->eps[ep_index].stream_info) in xhci_alloc_streams()
3696 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_alloc_streams()
3697 ep_ctx = xhci_get_ep_ctx(xhci, config_cmd->in_ctx, ep_index); in xhci_alloc_streams()
3699 xhci_endpoint_copy(xhci, config_cmd->in_ctx, in xhci_alloc_streams()
3700 vdev->out_ctx, ep_index); in xhci_alloc_streams()
3702 vdev->eps[ep_index].stream_info); in xhci_alloc_streams()
3707 xhci_setup_input_ctx_for_config_ep(xhci, config_cmd->in_ctx, in xhci_alloc_streams()
3708 vdev->out_ctx, ctrl_ctx, in xhci_alloc_streams()
3722 spin_lock_irqsave(&xhci->lock, flags); in xhci_alloc_streams()
3724 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_alloc_streams()
3725 vdev->eps[ep_index].ep_state &= ~EP_GETTING_STREAMS; in xhci_alloc_streams()
3727 udev->slot_id, ep_index); in xhci_alloc_streams()
3728 vdev->eps[ep_index].ep_state |= EP_HAS_STREAMS; in xhci_alloc_streams()
3731 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_streams()
3734 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_alloc_streams()
3738 return num_streams - 1; in xhci_alloc_streams()
3743 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_alloc_streams()
3744 xhci_free_stream_info(xhci, vdev->eps[ep_index].stream_info); in xhci_alloc_streams()
3745 vdev->eps[ep_index].stream_info = NULL; in xhci_alloc_streams()
3749 vdev->eps[ep_index].ep_state &= ~EP_GETTING_STREAMS; in xhci_alloc_streams()
3750 vdev->eps[ep_index].ep_state &= ~EP_HAS_STREAMS; in xhci_alloc_streams()
3754 return -ENOMEM; in xhci_alloc_streams()
3777 vdev = xhci->devs[udev->slot_id]; in xhci_free_streams()
3780 spin_lock_irqsave(&xhci->lock, flags); in xhci_free_streams()
3784 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_streams()
3785 return -EINVAL; in xhci_free_streams()
3792 ep_index = xhci_get_endpoint_index(&eps[0]->desc); in xhci_free_streams()
3793 command = vdev->eps[ep_index].stream_info->free_streams_command; in xhci_free_streams()
3794 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx); in xhci_free_streams()
3796 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_streams()
3799 return -EINVAL; in xhci_free_streams()
3805 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_free_streams()
3806 ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, ep_index); in xhci_free_streams()
3807 xhci->devs[udev->slot_id]->eps[ep_index].ep_state |= in xhci_free_streams()
3810 xhci_endpoint_copy(xhci, command->in_ctx, in xhci_free_streams()
3811 vdev->out_ctx, ep_index); in xhci_free_streams()
3813 &vdev->eps[ep_index]); in xhci_free_streams()
3815 xhci_setup_input_ctx_for_config_ep(xhci, command->in_ctx, in xhci_free_streams()
3816 vdev->out_ctx, ctrl_ctx, in xhci_free_streams()
3818 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_streams()
3832 spin_lock_irqsave(&xhci->lock, flags); in xhci_free_streams()
3834 ep_index = xhci_get_endpoint_index(&eps[i]->desc); in xhci_free_streams()
3835 xhci_free_stream_info(xhci, vdev->eps[ep_index].stream_info); in xhci_free_streams()
3836 vdev->eps[ep_index].stream_info = NULL; in xhci_free_streams()
3840 vdev->eps[ep_index].ep_state &= ~EP_GETTING_NO_STREAMS; in xhci_free_streams()
3841 vdev->eps[ep_index].ep_state &= ~EP_HAS_STREAMS; in xhci_free_streams()
3843 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_streams()
3853 * Must be called with xhci->lock held.
3863 if (virt_dev->eps[i].ring) { in xhci_free_device_endpoint_resources()
3868 xhci->num_active_eps -= num_dropped_eps; in xhci_free_device_endpoint_resources()
3874 xhci->num_active_eps); in xhci_free_device_endpoint_resources()
3883 * xhci_address_device(), and then re-set up the configuration. If this is
3885 * settings will be re-installed through the normal bandwidth allocation
3894 * re-initialization during S3/S4. In this case, call xhci_alloc_dev() to
3895 * re-allocate the device.
3913 slot_id = udev->slot_id; in xhci_discover_or_reset_device()
3914 virt_dev = xhci->devs[slot_id]; in xhci_discover_or_reset_device()
3917 "not exist. Re-allocate the device\n", slot_id); in xhci_discover_or_reset_device()
3922 return -EINVAL; in xhci_discover_or_reset_device()
3925 if (virt_dev->tt_info) in xhci_discover_or_reset_device()
3926 old_active_eps = virt_dev->tt_info->active_eps; in xhci_discover_or_reset_device()
3928 if (virt_dev->udev != udev) { in xhci_discover_or_reset_device()
3931 * Re-allocate the device. in xhci_discover_or_reset_device()
3934 "not match the udev. Re-allocate the device\n", in xhci_discover_or_reset_device()
3940 return -EINVAL; in xhci_discover_or_reset_device()
3944 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); in xhci_discover_or_reset_device()
3945 if (GET_SLOT_STATE(le32_to_cpu(slot_ctx->dev_state)) == in xhci_discover_or_reset_device()
3949 if (xhci->quirks & XHCI_ETRON_HOST) { in xhci_discover_or_reset_device()
3954 ret = xhci_disable_slot(xhci, udev->slot_id); in xhci_discover_or_reset_device()
3955 xhci_free_virt_device(xhci, udev->slot_id); in xhci_discover_or_reset_device()
3961 ret = -EINVAL; in xhci_discover_or_reset_device()
3978 return -ENOMEM; in xhci_discover_or_reset_device()
3982 spin_lock_irqsave(&xhci->lock, flags); in xhci_discover_or_reset_device()
3987 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_discover_or_reset_device()
3991 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_discover_or_reset_device()
3994 wait_for_completion(reset_device_cmd->completion); in xhci_discover_or_reset_device()
4000 ret = reset_device_cmd->status; in xhci_discover_or_reset_device()
4005 ret = -ETIME; in xhci_discover_or_reset_device()
4011 xhci_get_slot_state(xhci, virt_dev->out_ctx)); in xhci_discover_or_reset_device()
4024 ret = -EINVAL; in xhci_discover_or_reset_device()
4029 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) { in xhci_discover_or_reset_device()
4030 spin_lock_irqsave(&xhci->lock, flags); in xhci_discover_or_reset_device()
4033 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_discover_or_reset_device()
4038 struct xhci_virt_ep *ep = &virt_dev->eps[i]; in xhci_discover_or_reset_device()
4040 if (ep->ep_state & EP_HAS_STREAMS) { in xhci_discover_or_reset_device()
4043 xhci_free_stream_info(xhci, ep->stream_info); in xhci_discover_or_reset_device()
4044 ep->stream_info = NULL; in xhci_discover_or_reset_device()
4045 ep->ep_state &= ~EP_HAS_STREAMS; in xhci_discover_or_reset_device()
4048 if (ep->ring) { in xhci_discover_or_reset_device()
4049 if (ep->sideband) in xhci_discover_or_reset_device()
4050 xhci_sideband_notify_ep_ring_free(ep->sideband, i); in xhci_discover_or_reset_device()
4054 if (!list_empty(&virt_dev->eps[i].bw_endpoint_list)) in xhci_discover_or_reset_device()
4056 &virt_dev->eps[i].bw_info, in xhci_discover_or_reset_device()
4057 virt_dev->bw_table, in xhci_discover_or_reset_device()
4059 &virt_dev->eps[i], in xhci_discover_or_reset_device()
4060 virt_dev->tt_info); in xhci_discover_or_reset_device()
4061 xhci_clear_endpoint_bw_info(&virt_dev->eps[i].bw_info); in xhci_discover_or_reset_device()
4065 virt_dev->flags = 0; in xhci_discover_or_reset_device()
4091 if (xhci->quirks & XHCI_RESET_ON_RESUME) in xhci_free_dev()
4092 pm_runtime_put_noidle(hcd->self.controller); in xhci_free_dev()
4098 if (ret <= 0 && ret != -ENODEV) in xhci_free_dev()
4101 virt_dev = xhci->devs[udev->slot_id]; in xhci_free_dev()
4102 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); in xhci_free_dev()
4107 virt_dev->eps[i].ep_state &= ~EP_STOP_CMD_PENDING; in xhci_free_dev()
4108 virt_dev->udev = NULL; in xhci_free_dev()
4109 xhci_disable_slot(xhci, udev->slot_id); in xhci_free_dev()
4111 spin_lock_irqsave(&xhci->lock, flags); in xhci_free_dev()
4112 xhci_free_virt_device(xhci, udev->slot_id); in xhci_free_dev()
4113 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_dev()
4126 return -ENOMEM; in xhci_disable_slot()
4130 spin_lock_irqsave(&xhci->lock, flags); in xhci_disable_slot()
4132 state = readl(&xhci->op_regs->status); in xhci_disable_slot()
4133 if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) || in xhci_disable_slot()
4134 (xhci->xhc_state & XHCI_STATE_HALTED)) { in xhci_disable_slot()
4135 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_disable_slot()
4137 return -ENODEV; in xhci_disable_slot()
4143 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_disable_slot()
4148 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_disable_slot()
4150 wait_for_completion(command->completion); in xhci_disable_slot()
4152 if (command->status != COMP_SUCCESS) in xhci_disable_slot()
4154 slot_id, command->status); in xhci_disable_slot()
4165 * Must be called with xhci->lock held.
4169 if (xhci->num_active_eps + 1 > xhci->limit_active_eps) { in xhci_reserve_host_control_ep_resources()
4173 xhci->num_active_eps, xhci->limit_active_eps); in xhci_reserve_host_control_ep_resources()
4174 return -ENOMEM; in xhci_reserve_host_control_ep_resources()
4176 xhci->num_active_eps += 1; in xhci_reserve_host_control_ep_resources()
4179 xhci->num_active_eps); in xhci_reserve_host_control_ep_resources()
4201 spin_lock_irqsave(&xhci->lock, flags); in xhci_alloc_dev()
4204 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_dev()
4210 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_dev()
4212 wait_for_completion(command->completion); in xhci_alloc_dev()
4213 slot_id = command->slot_id; in xhci_alloc_dev()
4215 if (!slot_id || command->status != COMP_SUCCESS) { in xhci_alloc_dev()
4217 xhci_trb_comp_code_string(command->status)); in xhci_alloc_dev()
4220 readl(&xhci->cap_regs->hcs_params1))); in xhci_alloc_dev()
4227 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) { in xhci_alloc_dev()
4228 spin_lock_irqsave(&xhci->lock, flags); in xhci_alloc_dev()
4231 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_dev()
4234 xhci->num_active_eps); in xhci_alloc_dev()
4237 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_dev()
4247 vdev = xhci->devs[slot_id]; in xhci_alloc_dev()
4248 slot_ctx = xhci_get_slot_ctx(xhci, vdev->out_ctx); in xhci_alloc_dev()
4251 udev->slot_id = slot_id; in xhci_alloc_dev()
4259 if (xhci->quirks & XHCI_RESET_ON_RESUME) in xhci_alloc_dev()
4260 pm_runtime_get_noresume(hcd->self.controller); in xhci_alloc_dev()
4267 xhci_disable_slot(xhci, udev->slot_id); in xhci_alloc_dev()
4268 xhci_free_virt_device(xhci, udev->slot_id); in xhci_alloc_dev()
4274 * xhci_setup_device - issues an Address Device command to assign a unique
4296 mutex_lock(&xhci->mutex); in xhci_setup_device()
4298 if (xhci->xhc_state) { /* dying, removing or halted */ in xhci_setup_device()
4299 ret = -ESHUTDOWN; in xhci_setup_device()
4303 if (!udev->slot_id) { in xhci_setup_device()
4305 "Bad Slot ID %d", udev->slot_id); in xhci_setup_device()
4306 ret = -EINVAL; in xhci_setup_device()
4310 virt_dev = xhci->devs[udev->slot_id]; in xhci_setup_device()
4315 * a zero-dereference was observed once due to virt_dev = 0. in xhci_setup_device()
4319 udev->slot_id); in xhci_setup_device()
4320 ret = -EINVAL; in xhci_setup_device()
4323 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); in xhci_setup_device()
4327 if (GET_SLOT_STATE(le32_to_cpu(slot_ctx->dev_state)) == in xhci_setup_device()
4336 ret = -ENOMEM; in xhci_setup_device()
4340 command->in_ctx = virt_dev->in_ctx; in xhci_setup_device()
4341 command->timeout_ms = timeout_ms; in xhci_setup_device()
4343 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); in xhci_setup_device()
4344 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx); in xhci_setup_device()
4348 ret = -EINVAL; in xhci_setup_device()
4352 * If this is the first Set Address since device plug-in or in xhci_setup_device()
4356 if (!slot_ctx->dev_info) in xhci_setup_device()
4361 ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG); in xhci_setup_device()
4362 ctrl_ctx->drop_flags = 0; in xhci_setup_device()
4364 trace_xhci_address_ctx(xhci, virt_dev->in_ctx, in xhci_setup_device()
4365 le32_to_cpu(slot_ctx->dev_info) >> 27); in xhci_setup_device()
4368 spin_lock_irqsave(&xhci->lock, flags); in xhci_setup_device()
4370 ret = xhci_queue_address_device(xhci, command, virt_dev->in_ctx->dma, in xhci_setup_device()
4371 udev->slot_id, setup); in xhci_setup_device()
4373 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_setup_device()
4379 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_setup_device()
4382 wait_for_completion(command->completion); in xhci_setup_device()
4388 switch (command->status) { in xhci_setup_device()
4392 ret = -ETIME; in xhci_setup_device()
4397 act, udev->slot_id); in xhci_setup_device()
4398 ret = -EINVAL; in xhci_setup_device()
4401 dev_warn(&udev->dev, "Device not responding to setup %s.\n", act); in xhci_setup_device()
4403 mutex_unlock(&xhci->mutex); in xhci_setup_device()
4404 ret = xhci_disable_slot(xhci, udev->slot_id); in xhci_setup_device()
4405 xhci_free_virt_device(xhci, udev->slot_id); in xhci_setup_device()
4410 kfree(command->completion); in xhci_setup_device()
4412 return -EPROTO; in xhci_setup_device()
4414 dev_warn(&udev->dev, in xhci_setup_device()
4416 ret = -ENODEV; in xhci_setup_device()
4425 act, command->status); in xhci_setup_device()
4426 trace_xhci_address_ctx(xhci, virt_dev->out_ctx, 1); in xhci_setup_device()
4427 ret = -EINVAL; in xhci_setup_device()
4432 temp_64 = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); in xhci_setup_device()
4437 udev->slot_id, in xhci_setup_device()
4438 &xhci->dcbaa->dev_context_ptrs[udev->slot_id], in xhci_setup_device()
4440 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[udev->slot_id])); in xhci_setup_device()
4443 (unsigned long long)virt_dev->out_ctx->dma); in xhci_setup_device()
4444 trace_xhci_address_ctx(xhci, virt_dev->in_ctx, in xhci_setup_device()
4445 le32_to_cpu(slot_ctx->dev_info) >> 27); in xhci_setup_device()
4450 trace_xhci_address_ctx(xhci, virt_dev->out_ctx, in xhci_setup_device()
4451 le32_to_cpu(slot_ctx->dev_info) >> 27); in xhci_setup_device()
4453 ctrl_ctx->add_flags = 0; in xhci_setup_device()
4454 ctrl_ctx->drop_flags = 0; in xhci_setup_device()
4455 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); in xhci_setup_device()
4456 udev->devaddr = (u8)(le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK); in xhci_setup_device()
4460 le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK); in xhci_setup_device()
4462 mutex_unlock(&xhci->mutex); in xhci_setup_device()
4464 kfree(command->completion); in xhci_setup_device()
4493 return rhub->ports[port1 - 1]->hw_portnum + 1; in xhci_find_raw_port_number()
4512 return -ENOMEM; in xhci_change_max_exit_latency()
4514 spin_lock_irqsave(&xhci->lock, flags); in xhci_change_max_exit_latency()
4516 virt_dev = xhci->devs[udev->slot_id]; in xhci_change_max_exit_latency()
4520 * xHC was re-initialized. Exit latency will be set later after in xhci_change_max_exit_latency()
4521 * hub_port_finish_reset() is done and xhci->devs[] are re-allocated in xhci_change_max_exit_latency()
4524 if (!virt_dev || max_exit_latency == virt_dev->current_mel) { in xhci_change_max_exit_latency()
4525 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_change_max_exit_latency()
4531 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx); in xhci_change_max_exit_latency()
4533 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_change_max_exit_latency()
4537 return -ENOMEM; in xhci_change_max_exit_latency()
4540 xhci_slot_copy(xhci, command->in_ctx, virt_dev->out_ctx); in xhci_change_max_exit_latency()
4541 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_change_max_exit_latency()
4543 ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG); in xhci_change_max_exit_latency()
4544 slot_ctx = xhci_get_slot_ctx(xhci, command->in_ctx); in xhci_change_max_exit_latency()
4545 slot_ctx->dev_info2 &= cpu_to_le32(~((u32) MAX_EXIT)); in xhci_change_max_exit_latency()
4546 slot_ctx->dev_info2 |= cpu_to_le32(max_exit_latency); in xhci_change_max_exit_latency()
4547 slot_ctx->dev_state = 0; in xhci_change_max_exit_latency()
4557 spin_lock_irqsave(&xhci->lock, flags); in xhci_change_max_exit_latency()
4558 virt_dev->current_mel = max_exit_latency; in xhci_change_max_exit_latency()
4559 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_change_max_exit_latency()
4581 u2del = HCS_U2_LATENCY(xhci->hcs_params3); in xhci_calculate_hird_besl()
4582 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes); in xhci_calculate_hird_besl()
4598 besl_host = (u2del - 51) / 75 + 1; in xhci_calculate_hird_besl()
4616 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes); in xhci_calculate_usb2_hw_lpm_params()
4619 l1 = udev->l1_params.timeout / 256; in xhci_calculate_usb2_hw_lpm_params()
4642 if (xhci->quirks & XHCI_HW_LPM_DISABLE) in xhci_set_usb2_hardware_lpm()
4643 return -EPERM; in xhci_set_usb2_hardware_lpm()
4645 if (hcd->speed >= HCD_USB3 || !xhci->hw_lpm_support || in xhci_set_usb2_hardware_lpm()
4646 !udev->lpm_capable) in xhci_set_usb2_hardware_lpm()
4647 return -EPERM; in xhci_set_usb2_hardware_lpm()
4649 if (!udev->parent || udev->parent->parent || in xhci_set_usb2_hardware_lpm()
4650 udev->descriptor.bDeviceClass == USB_CLASS_HUB) in xhci_set_usb2_hardware_lpm()
4651 return -EPERM; in xhci_set_usb2_hardware_lpm()
4653 if (udev->usb2_hw_lpm_capable != 1) in xhci_set_usb2_hardware_lpm()
4654 return -EPERM; in xhci_set_usb2_hardware_lpm()
4656 spin_lock_irqsave(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4658 ports = xhci->usb2_rhub.ports; in xhci_set_usb2_hardware_lpm()
4659 port_num = udev->portnum - 1; in xhci_set_usb2_hardware_lpm()
4660 pm_addr = ports[port_num]->addr + PORTPMSC; in xhci_set_usb2_hardware_lpm()
4662 hlpm_addr = ports[port_num]->addr + PORTHLPMC; in xhci_set_usb2_hardware_lpm()
4669 if (udev->usb2_hw_lpm_besl_capable) { in xhci_set_usb2_hardware_lpm()
4674 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes); in xhci_set_usb2_hardware_lpm()
4679 hird = udev->l1_params.besl; in xhci_set_usb2_hardware_lpm()
4682 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4688 spin_lock_irqsave(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4699 pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id); in xhci_set_usb2_hardware_lpm()
4711 if (udev->usb2_hw_lpm_besl_capable) { in xhci_set_usb2_hardware_lpm()
4712 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4714 readl_poll_timeout(ports[port_num]->addr, pm_val, in xhci_set_usb2_hardware_lpm()
4721 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4732 if (hcd->speed >= HCD_USB3 && !udev->parent->parent) { in xhci_update_device()
4733 port = xhci->usb3_rhub.ports[udev->portnum - 1]; in xhci_update_device()
4735 udev->tunnel_mode = xhci_port_is_tunneled(xhci, port); in xhci_update_device()
4736 if (udev->tunnel_mode == USB_LINK_UNKNOWN) in xhci_update_device()
4737 dev_dbg(&udev->dev, "link tunnel state unknown\n"); in xhci_update_device()
4738 else if (udev->tunnel_mode == USB_LINK_TUNNELED) in xhci_update_device()
4739 dev_dbg(&udev->dev, "tunneled over USB4 link\n"); in xhci_update_device()
4740 else if (udev->tunnel_mode == USB_LINK_NATIVE) in xhci_update_device()
4741 dev_dbg(&udev->dev, "native USB 3.x link\n"); in xhci_update_device()
4745 if (hcd->speed >= HCD_USB3 || !udev->lpm_capable || !xhci->hw_lpm_support) in xhci_update_device()
4748 /* we only support lpm for non-hub device connected to root hub yet */ in xhci_update_device()
4749 if (!udev->parent || udev->parent->parent || in xhci_update_device()
4750 udev->descriptor.bDeviceClass == USB_CLASS_HUB) in xhci_update_device()
4753 port = xhci->usb2_rhub.ports[udev->portnum - 1]; in xhci_update_device()
4754 capability = port->port_cap->protocol_caps; in xhci_update_device()
4757 udev->usb2_hw_lpm_capable = 1; in xhci_update_device()
4758 udev->l1_params.timeout = XHCI_L1_TIMEOUT; in xhci_update_device()
4759 udev->l1_params.besl = XHCI_DEFAULT_BESL; in xhci_update_device()
4761 udev->usb2_hw_lpm_besl_capable = 1; in xhci_update_device()
4767 /*---------------------- USB 3.0 Link PM functions ------------------------*/
4769 /* Service interval in nanoseconds = 2^(bInterval - 1) * 125us * 1000ns / 1us */
4773 return (1ULL << (desc->bInterval - 1)) * 125 * 1000; in xhci_service_interval_to_ns()
4787 sel = DIV_ROUND_UP(udev->u1_params.sel, 1000); in xhci_get_timeout_no_hub_lpm()
4788 pel = DIV_ROUND_UP(udev->u1_params.pel, 1000); in xhci_get_timeout_no_hub_lpm()
4793 sel = DIV_ROUND_UP(udev->u2_params.sel, 1000); in xhci_get_timeout_no_hub_lpm()
4794 pel = DIV_ROUND_UP(udev->u2_params.pel, 1000); in xhci_get_timeout_no_hub_lpm()
4799 dev_warn(&udev->dev, "%s: Can't get timeout for non-U1 or U2 state.\n", in xhci_get_timeout_no_hub_lpm()
4808 dev_dbg(&udev->dev, "Device-initiated %s disabled " in xhci_get_timeout_no_hub_lpm()
4812 dev_dbg(&udev->dev, "Device-initiated %s disabled " in xhci_get_timeout_no_hub_lpm()
4819 * - For control endpoints, U1 system exit latency (SEL) * 3
4820 * - For bulk endpoints, U1 SEL * 5
4821 * - For interrupt endpoints:
4822 * - Notification EPs, U1 SEL * 3
4823 * - Periodic EPs, max(105% of bInterval, U1 SEL * 2)
4824 * - For isochronous endpoints, max(105% of bInterval, U1 SEL * 2)
4837 timeout_ns = udev->u1_params.sel * 3; in xhci_calculate_intel_u1_timeout()
4840 timeout_ns = udev->u1_params.sel * 5; in xhci_calculate_intel_u1_timeout()
4845 timeout_ns = udev->u1_params.sel * 3; in xhci_calculate_intel_u1_timeout()
4853 if (timeout_ns < udev->u1_params.sel * 2) in xhci_calculate_intel_u1_timeout()
4854 timeout_ns = udev->u1_params.sel * 2; in xhci_calculate_intel_u1_timeout()
4863 /* Returns the hub-encoded U1 timeout value. */
4872 if (xhci_service_interval_to_ns(desc) <= udev->u1_params.mel) { in xhci_calculate_u1_timeout()
4873 dev_dbg(&udev->dev, "Disable U1, ESIT shorter than exit latency\n"); in xhci_calculate_u1_timeout()
4878 if (xhci->quirks & (XHCI_INTEL_HOST | XHCI_ZHAOXIN_HOST)) in xhci_calculate_u1_timeout()
4881 timeout_ns = udev->u1_params.sel; in xhci_calculate_u1_timeout()
4892 * USB 3.0 hub, we have to disable hub-initiated U1. in xhci_calculate_u1_timeout()
4896 dev_dbg(&udev->dev, "Hub-initiated U1 disabled due to long timeout %lluus\n", in xhci_calculate_u1_timeout()
4902 * - 10 ms (to avoid the bandwidth impact on the scheduler)
4903 * - largest bInterval of any active periodic endpoint (to avoid going
4905 * - the U2 Exit Latency of the device
4920 u2_del_ns = le16_to_cpu(udev->bos->ss_cap->bU2DevExitLat) * 1000ULL; in xhci_calculate_intel_u2_timeout()
4927 /* Returns the hub-encoded U2 timeout value. */
4936 if (xhci_service_interval_to_ns(desc) <= udev->u2_params.mel) { in xhci_calculate_u2_timeout()
4937 dev_dbg(&udev->dev, "Disable U2, ESIT shorter than exit latency\n"); in xhci_calculate_u2_timeout()
4942 if (xhci->quirks & (XHCI_INTEL_HOST | XHCI_ZHAOXIN_HOST)) in xhci_calculate_u2_timeout()
4945 timeout_ns = udev->u2_params.sel; in xhci_calculate_u2_timeout()
4950 * USB 3.0 hub, we have to disable hub-initiated U2. in xhci_calculate_u2_timeout()
4954 dev_dbg(&udev->dev, "Hub-initiated U2 disabled due to long timeout %lluus\n", in xhci_calculate_u2_timeout()
4984 /* If we found we can't enable hub-initiated LPM, and in xhci_update_timeout_for_endpoint()
4986 * device-initiated LPM as well, then we will disable LPM in xhci_update_timeout_for_endpoint()
4991 return -E2BIG; in xhci_update_timeout_for_endpoint()
5006 for (j = 0; j < alt->desc.bNumEndpoints; j++) { in xhci_update_timeout_for_interface()
5008 &alt->endpoint[j].desc, state, timeout)) in xhci_update_timeout_for_interface()
5009 return -E2BIG; in xhci_update_timeout_for_interface()
5018 struct usb_device *parent = udev->parent; in xhci_check_tier_policy()
5022 parent = parent->parent; in xhci_check_tier_policy()
5026 if (xhci->quirks & XHCI_INTEL_HOST && tier > 3) in xhci_check_tier_policy()
5028 if (xhci->quirks & XHCI_ZHAOXIN_HOST && tier > 2) in xhci_check_tier_policy()
5033 dev_dbg(&udev->dev, "Tier policy prevents U1/U2 LPM states for devices at tier %d\n", in xhci_check_tier_policy()
5035 return -E2BIG; in xhci_check_tier_policy()
5039 * If the tier check or timeout setting functions return with a non-zero exit
5057 dev_warn(&udev->dev, "Can't enable unknown link state %i\n", in xhci_calculate_lpm_timeout()
5065 if (xhci_update_timeout_for_endpoint(xhci, udev, &udev->ep0.desc, in xhci_calculate_lpm_timeout()
5069 config = udev->actconfig; in xhci_calculate_lpm_timeout()
5073 for (i = 0; i < config->desc.bNumInterfaces; i++) { in xhci_calculate_lpm_timeout()
5075 struct usb_interface *intf = config->interface[i]; in xhci_calculate_lpm_timeout()
5080 /* Check if any currently bound drivers want hub-initiated LPM in xhci_calculate_lpm_timeout()
5083 if (intf->dev.driver) { in xhci_calculate_lpm_timeout()
5084 driver = to_usb_driver(intf->dev.driver); in xhci_calculate_lpm_timeout()
5085 if (driver && driver->disable_hub_initiated_lpm) { in xhci_calculate_lpm_timeout()
5086 dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n", in xhci_calculate_lpm_timeout()
5087 state_name, driver->name); in xhci_calculate_lpm_timeout()
5096 if (!intf->cur_altsetting) in xhci_calculate_lpm_timeout()
5100 intf->cur_altsetting, in xhci_calculate_lpm_timeout()
5132 if ((udev->u1_params.timeout != USB3_LPM_DISABLED && !disabling_u1) || in calculate_max_exit_latency()
5134 u1_mel_us = DIV_ROUND_UP(udev->u1_params.mel, 1000); in calculate_max_exit_latency()
5135 if ((udev->u2_params.timeout != USB3_LPM_DISABLED && !disabling_u2) || in calculate_max_exit_latency()
5137 u2_mel_us = DIV_ROUND_UP(udev->u2_params.mel, 1000); in calculate_max_exit_latency()
5143 dev_warn(&udev->dev, "Link PM max exit latency of %lluus " in calculate_max_exit_latency()
5145 return -E2BIG; in calculate_max_exit_latency()
5150 /* Returns the USB3 hub-encoded value for the U1/U2 timeout. */
5161 /* The LPM timeout values are pretty host-controller specific, so don't in xhci_enable_usb3_lpm_timeout()
5162 * enable hub-initiated timeouts unless the vendor has provided in xhci_enable_usb3_lpm_timeout()
5165 if (!xhci || !(xhci->quirks & XHCI_LPM_SUPPORT) || in xhci_enable_usb3_lpm_timeout()
5166 !xhci->devs[udev->slot_id]) in xhci_enable_usb3_lpm_timeout()
5173 if (udev->parent && !udev->parent->parent) { in xhci_enable_usb3_lpm_timeout()
5174 port = xhci->usb3_rhub.ports[udev->portnum - 1]; in xhci_enable_usb3_lpm_timeout()
5175 if (port->lpm_incapable) in xhci_enable_usb3_lpm_timeout()
5200 if (!xhci || !(xhci->quirks & XHCI_LPM_SUPPORT) || in xhci_disable_usb3_lpm_timeout()
5201 !xhci->devs[udev->slot_id]) in xhci_disable_usb3_lpm_timeout()
5233 /*-------------------------------------------------------------------------*/
5251 if (!hdev->parent) in xhci_update_hub_device()
5254 vdev = xhci->devs[hdev->slot_id]; in xhci_update_hub_device()
5257 return -EINVAL; in xhci_update_hub_device()
5262 return -ENOMEM; in xhci_update_hub_device()
5264 ctrl_ctx = xhci_get_input_control_ctx(config_cmd->in_ctx); in xhci_update_hub_device()
5269 return -ENOMEM; in xhci_update_hub_device()
5272 spin_lock_irqsave(&xhci->lock, flags); in xhci_update_hub_device()
5273 if (hdev->speed == USB_SPEED_HIGH && in xhci_update_hub_device()
5277 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_update_hub_device()
5278 return -ENOMEM; in xhci_update_hub_device()
5281 xhci_slot_copy(xhci, config_cmd->in_ctx, vdev->out_ctx); in xhci_update_hub_device()
5282 ctrl_ctx->add_flags |= cpu_to_le32(SLOT_FLAG); in xhci_update_hub_device()
5283 slot_ctx = xhci_get_slot_ctx(xhci, config_cmd->in_ctx); in xhci_update_hub_device()
5284 slot_ctx->dev_info |= cpu_to_le32(DEV_HUB); in xhci_update_hub_device()
5290 if (tt->multi) in xhci_update_hub_device()
5291 slot_ctx->dev_info |= cpu_to_le32(DEV_MTT); in xhci_update_hub_device()
5292 else if (hdev->speed == USB_SPEED_FULL) in xhci_update_hub_device()
5293 slot_ctx->dev_info &= cpu_to_le32(~DEV_MTT); in xhci_update_hub_device()
5295 if (xhci->hci_version > 0x95) { in xhci_update_hub_device()
5298 (unsigned int) xhci->hci_version); in xhci_update_hub_device()
5299 slot_ctx->dev_info2 |= cpu_to_le32(XHCI_MAX_PORTS(hdev->maxchild)); in xhci_update_hub_device()
5300 /* Set TT think time - convert from ns to FS bit times. in xhci_update_hub_device()
5305 * High-spped hub. in xhci_update_hub_device()
5307 think_time = tt->think_time; in xhci_update_hub_device()
5309 think_time = (think_time / 666) - 1; in xhci_update_hub_device()
5310 if (xhci->hci_version < 0x100 || hdev->speed == USB_SPEED_HIGH) in xhci_update_hub_device()
5311 slot_ctx->tt_info |= in xhci_update_hub_device()
5316 (unsigned int) xhci->hci_version); in xhci_update_hub_device()
5318 slot_ctx->dev_state = 0; in xhci_update_hub_device()
5319 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_update_hub_device()
5322 (xhci->hci_version > 0x95) ? in xhci_update_hub_device()
5328 if (xhci->hci_version > 0x95) in xhci_update_hub_device()
5344 return readl(&xhci->run_regs->microframe_index) >> 3; in xhci_get_frame()
5349 xhci->usb2_rhub.hcd = hcd; in xhci_hcd_init_usb2_data()
5350 hcd->speed = HCD_USB2; in xhci_hcd_init_usb2_data()
5351 hcd->self.root_hub->speed = USB_SPEED_HIGH; in xhci_hcd_init_usb2_data()
5354 * (rate matching hub) as opposed to having an OHCI/UHCI in xhci_hcd_init_usb2_data()
5357 hcd->has_tt = 1; in xhci_hcd_init_usb2_data()
5367 * is a two digit BCD containig minor and sub-minor numbers. in xhci_hcd_init_usb3_data()
5373 if (xhci->usb3_rhub.min_rev == 0x1) in xhci_hcd_init_usb3_data()
5376 minor_rev = xhci->usb3_rhub.min_rev / 0x10; in xhci_hcd_init_usb3_data()
5380 hcd->speed = HCD_USB32; in xhci_hcd_init_usb3_data()
5381 hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; in xhci_hcd_init_usb3_data()
5382 hcd->self.root_hub->rx_lanes = 2; in xhci_hcd_init_usb3_data()
5383 hcd->self.root_hub->tx_lanes = 2; in xhci_hcd_init_usb3_data()
5384 hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x2; in xhci_hcd_init_usb3_data()
5387 hcd->speed = HCD_USB31; in xhci_hcd_init_usb3_data()
5388 hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; in xhci_hcd_init_usb3_data()
5389 hcd->self.root_hub->ssp_rate = USB_SSP_GEN_2x1; in xhci_hcd_init_usb3_data()
5395 xhci->usb3_rhub.hcd = hcd; in xhci_hcd_init_usb3_data()
5405 struct device *dev = hcd->self.sysdev; in xhci_gen_setup()
5408 /* Accept arbitrarily long scatter-gather lists */ in xhci_gen_setup()
5409 hcd->self.sg_tablesize = ~0; in xhci_gen_setup()
5412 hcd->self.no_sg_constraint = 1; in xhci_gen_setup()
5415 hcd->self.no_stop_on_short = 1; in xhci_gen_setup()
5424 mutex_init(&xhci->mutex); in xhci_gen_setup()
5425 xhci->main_hcd = hcd; in xhci_gen_setup()
5426 xhci->cap_regs = hcd->regs; in xhci_gen_setup()
5427 xhci->op_regs = hcd->regs + in xhci_gen_setup()
5428 HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)); in xhci_gen_setup()
5429 xhci->run_regs = hcd->regs + in xhci_gen_setup()
5430 (readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK); in xhci_gen_setup()
5431 /* Cache read-only capability registers */ in xhci_gen_setup()
5432 xhci->hcs_params1 = readl(&xhci->cap_regs->hcs_params1); in xhci_gen_setup()
5433 xhci->hcs_params2 = readl(&xhci->cap_regs->hcs_params2); in xhci_gen_setup()
5434 xhci->hcs_params3 = readl(&xhci->cap_regs->hcs_params3); in xhci_gen_setup()
5435 xhci->hci_version = HC_VERSION(readl(&xhci->cap_regs->hc_capbase)); in xhci_gen_setup()
5436 xhci->hcc_params = readl(&xhci->cap_regs->hcc_params); in xhci_gen_setup()
5437 if (xhci->hci_version > 0x100) in xhci_gen_setup()
5438 xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2); in xhci_gen_setup()
5440 /* xhci-plat or xhci-pci might have set max_interrupters already */ in xhci_gen_setup()
5441 if ((!xhci->max_interrupters) || in xhci_gen_setup()
5442 xhci->max_interrupters > HCS_MAX_INTRS(xhci->hcs_params1)) in xhci_gen_setup()
5443 xhci->max_interrupters = HCS_MAX_INTRS(xhci->hcs_params1); in xhci_gen_setup()
5445 xhci->quirks |= quirks; in xhci_gen_setup()
5454 if (xhci->hci_version > 0x96) in xhci_gen_setup()
5455 xhci->quirks |= XHCI_SPURIOUS_SUCCESS; in xhci_gen_setup()
5457 if (xhci->hci_version == 0x95 && link_quirk) { in xhci_gen_setup()
5459 xhci->quirks |= XHCI_LINK_TRB_QUIRK; in xhci_gen_setup()
5477 * On some xHCI controllers (e.g. R-Car SoCs), the AC64 bit (bit 0) in xhci_gen_setup()
5478 * of HCCPARAMS1 is set to 1. However, the xHCs don't support 64-bit in xhci_gen_setup()
5480 * bit of xhci->hcc_params to call dma_set_coherent_mask(dev, in xhci_gen_setup()
5483 if (xhci->quirks & XHCI_NO_64BIT_SUPPORT) in xhci_gen_setup()
5484 xhci->hcc_params &= ~BIT(0); in xhci_gen_setup()
5486 /* Set dma_mask and coherent_dma_mask to 64-bits, in xhci_gen_setup()
5487 * if xHC supports 64-bit addressing */ in xhci_gen_setup()
5488 if (HCC_64BIT_ADDR(xhci->hcc_params) && in xhci_gen_setup()
5490 xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n"); in xhci_gen_setup()
5494 * This is to avoid error in cases where a 32-bit USB in xhci_gen_setup()
5495 * controller is used on a 64-bit capable system. in xhci_gen_setup()
5500 xhci_dbg(xhci, "Enabling 32-bit DMA addresses.\n"); in xhci_gen_setup()
5517 xhci->hcc_params, xhci->hci_version, xhci->quirks); in xhci_gen_setup()
5534 spin_lock_irqsave(&xhci->lock, flags); in xhci_clear_tt_buffer_complete()
5535 udev = (struct usb_device *)ep->hcpriv; in xhci_clear_tt_buffer_complete()
5536 slot_id = udev->slot_id; in xhci_clear_tt_buffer_complete()
5537 ep_index = xhci_get_endpoint_index(&ep->desc); in xhci_clear_tt_buffer_complete()
5539 xhci->devs[slot_id]->eps[ep_index].ep_state &= ~EP_CLEARING_TT; in xhci_clear_tt_buffer_complete()
5541 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_clear_tt_buffer_complete()
5545 .description = "xhci-hcd",
5550 * generic hardware linkage
5616 /* Copy the generic table to drv then apply the overrides */ in xhci_init_driver()
5620 drv->hcd_priv_size += over->extra_priv_size; in xhci_init_driver()
5621 if (over->reset) in xhci_init_driver()
5622 drv->reset = over->reset; in xhci_init_driver()
5623 if (over->start) in xhci_init_driver()
5624 drv->start = over->start; in xhci_init_driver()
5625 if (over->add_endpoint) in xhci_init_driver()
5626 drv->add_endpoint = over->add_endpoint; in xhci_init_driver()
5627 if (over->drop_endpoint) in xhci_init_driver()
5628 drv->drop_endpoint = over->drop_endpoint; in xhci_init_driver()
5629 if (over->check_bandwidth) in xhci_init_driver()
5630 drv->check_bandwidth = over->check_bandwidth; in xhci_init_driver()
5631 if (over->reset_bandwidth) in xhci_init_driver()
5632 drv->reset_bandwidth = over->reset_bandwidth; in xhci_init_driver()
5633 if (over->update_hub_device) in xhci_init_driver()
5634 drv->update_hub_device = over->update_hub_device; in xhci_init_driver()
5635 if (over->hub_control) in xhci_init_driver()
5636 drv->hub_control = over->hub_control; in xhci_init_driver()
5666 return -ENODEV; in xhci_hcd_init()