Lines Matching full:xhci
3 * xHCI host controller driver
22 #include "xhci.h"
23 #include "xhci-trace.h"
24 #include "xhci-mtk.h"
25 #include "xhci-debugfs.h"
26 #include "xhci-dbgcap.h"
86 * Disable interrupts and begin the xHCI halting process.
88 void xhci_quiesce(struct xhci_hcd *xhci) in xhci_quiesce() argument
95 halted = readl(&xhci->op_regs->status) & STS_HALT; in xhci_quiesce()
99 cmd = readl(&xhci->op_regs->command); in xhci_quiesce()
101 writel(cmd, &xhci->op_regs->command); in xhci_quiesce()
112 int xhci_halt(struct xhci_hcd *xhci) in xhci_halt() argument
115 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Halt the HC"); in xhci_halt()
116 xhci_quiesce(xhci); in xhci_halt()
118 ret = xhci_handshake(&xhci->op_regs->status, in xhci_halt()
121 xhci_warn(xhci, "Host halt failed, %d\n", ret); in xhci_halt()
124 xhci->xhc_state |= XHCI_STATE_HALTED; in xhci_halt()
125 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; in xhci_halt()
132 int xhci_start(struct xhci_hcd *xhci) in xhci_start() argument
137 temp = readl(&xhci->op_regs->command); in xhci_start()
139 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Turn on HC, cmd = 0x%x.", in xhci_start()
141 writel(temp, &xhci->op_regs->command); in xhci_start()
147 ret = xhci_handshake(&xhci->op_regs->status, in xhci_start()
150 xhci_err(xhci, "Host took too long to start, " in xhci_start()
155 xhci->xhc_state = 0; in xhci_start()
156 xhci->run_graceperiod = jiffies + msecs_to_jiffies(500); in xhci_start()
169 int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us) in xhci_reset() argument
175 state = readl(&xhci->op_regs->status); in xhci_reset()
178 xhci_warn(xhci, "Host not accessible, reset failed.\n"); in xhci_reset()
183 xhci_warn(xhci, "Host controller not halted, aborting reset.\n"); in xhci_reset()
187 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Reset the HC"); in xhci_reset()
188 command = readl(&xhci->op_regs->command); in xhci_reset()
190 writel(command, &xhci->op_regs->command); in xhci_reset()
192 /* Existing Intel xHCI controllers require a delay of 1 mS, in xhci_reset()
199 if (xhci->quirks & XHCI_INTEL_HOST) in xhci_reset()
202 ret = xhci_handshake(&xhci->op_regs->command, CMD_RESET, 0, timeout_us); in xhci_reset()
206 if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL) in xhci_reset()
207 usb_asmedia_modifyflowcontrol(to_pci_dev(xhci_to_hcd(xhci)->self.controller)); in xhci_reset()
209 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_reset()
212 * xHCI cannot write to any doorbells or operational registers other in xhci_reset()
215 ret = xhci_handshake(&xhci->op_regs->status, STS_CNR, 0, timeout_us); in xhci_reset()
217 xhci->usb2_rhub.bus_state.port_c_suspend = 0; in xhci_reset()
218 xhci->usb2_rhub.bus_state.suspended_ports = 0; in xhci_reset()
219 xhci->usb2_rhub.bus_state.resuming_ports = 0; in xhci_reset()
220 xhci->usb3_rhub.bus_state.port_c_suspend = 0; in xhci_reset()
221 xhci->usb3_rhub.bus_state.suspended_ports = 0; in xhci_reset()
222 xhci->usb3_rhub.bus_state.resuming_ports = 0; in xhci_reset()
227 static void xhci_zero_64b_regs(struct xhci_hcd *xhci) in xhci_zero_64b_regs() argument
229 struct device *dev = xhci_to_hcd(xhci)->self.sysdev; in xhci_zero_64b_regs()
250 if (!(xhci->quirks & XHCI_ZERO_64B_REGS) || !domain || in xhci_zero_64b_regs()
254 xhci_info(xhci, "Zeroing 64bit base registers, expecting fault\n"); in xhci_zero_64b_regs()
257 val = readl(&xhci->op_regs->command); in xhci_zero_64b_regs()
259 writel(val, &xhci->op_regs->command); in xhci_zero_64b_regs()
262 val = readl(&xhci->op_regs->status); in xhci_zero_64b_regs()
264 writel(val, &xhci->op_regs->status); in xhci_zero_64b_regs()
267 val = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); in xhci_zero_64b_regs()
269 xhci_write_64(xhci, 0, &xhci->op_regs->dcbaa_ptr); in xhci_zero_64b_regs()
270 val = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); in xhci_zero_64b_regs()
272 xhci_write_64(xhci, 0, &xhci->op_regs->cmd_ring); in xhci_zero_64b_regs()
274 intrs = min_t(u32, HCS_MAX_INTRS(xhci->hcs_params1), in xhci_zero_64b_regs()
275 ARRAY_SIZE(xhci->run_regs->ir_set)); in xhci_zero_64b_regs()
280 ir = &xhci->run_regs->ir_set[i]; in xhci_zero_64b_regs()
281 val = xhci_read_64(xhci, &ir->erst_base); in xhci_zero_64b_regs()
283 xhci_write_64(xhci, 0, &ir->erst_base); in xhci_zero_64b_regs()
284 val= xhci_read_64(xhci, &ir->erst_dequeue); in xhci_zero_64b_regs()
286 xhci_write_64(xhci, 0, &ir->erst_dequeue); in xhci_zero_64b_regs()
290 err = xhci_handshake(&xhci->op_regs->status, in xhci_zero_64b_regs()
294 xhci_info(xhci, "Fault detected\n"); in xhci_zero_64b_regs()
301 static int xhci_setup_msi(struct xhci_hcd *xhci) in xhci_setup_msi() argument
307 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); in xhci_setup_msi()
311 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_msi()
317 0, "xhci_hcd", xhci_to_hcd(xhci)); in xhci_setup_msi()
319 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_msi()
330 static int xhci_setup_msix(struct xhci_hcd *xhci) in xhci_setup_msix() argument
333 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_setup_msix()
339 * with max number of interrupters based on the xhci HCSPARAMS1. in xhci_setup_msix()
343 xhci->msix_count = min(num_online_cpus() + 1, in xhci_setup_msix()
344 HCS_MAX_INTRS(xhci->hcs_params1)); in xhci_setup_msix()
346 ret = pci_alloc_irq_vectors(pdev, xhci->msix_count, xhci->msix_count, in xhci_setup_msix()
349 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_msix()
354 for (i = 0; i < xhci->msix_count; i++) { in xhci_setup_msix()
356 "xhci_hcd", xhci_to_hcd(xhci)); in xhci_setup_msix()
365 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "disable MSI-X interrupt"); in xhci_setup_msix()
367 free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); in xhci_setup_msix()
373 static void xhci_cleanup_msix(struct xhci_hcd *xhci) in xhci_cleanup_msix() argument
375 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_cleanup_msix()
378 if (xhci->quirks & XHCI_PLAT) in xhci_cleanup_msix()
388 for (i = 0; i < xhci->msix_count; i++) in xhci_cleanup_msix()
389 free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); in xhci_cleanup_msix()
391 free_irq(pci_irq_vector(pdev, 0), xhci_to_hcd(xhci)); in xhci_cleanup_msix()
398 static void __maybe_unused xhci_msix_sync_irqs(struct xhci_hcd *xhci) in xhci_msix_sync_irqs() argument
400 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_msix_sync_irqs()
406 for (i = 0; i < xhci->msix_count; i++) in xhci_msix_sync_irqs()
413 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_try_enable_msi() local
417 /* The xhci platform device has set up IRQs through usb_add_hcd. */ in xhci_try_enable_msi()
418 if (xhci->quirks & XHCI_PLAT) in xhci_try_enable_msi()
421 pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); in xhci_try_enable_msi()
426 if (xhci->quirks & XHCI_BROKEN_MSI) in xhci_try_enable_msi()
434 ret = xhci_setup_msix(xhci); in xhci_try_enable_msi()
437 ret = xhci_setup_msi(xhci); in xhci_try_enable_msi()
445 xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n"); in xhci_try_enable_msi()
458 xhci_err(xhci, "request interrupt %d failed\n", in xhci_try_enable_msi()
473 static inline void xhci_cleanup_msix(struct xhci_hcd *xhci) in xhci_cleanup_msix() argument
477 static inline void xhci_msix_sync_irqs(struct xhci_hcd *xhci) in xhci_msix_sync_irqs() argument
485 struct xhci_hcd *xhci; in compliance_mode_recovery() local
491 xhci = from_timer(xhci, t, comp_mode_recovery_timer); in compliance_mode_recovery()
492 rhub = &xhci->usb3_rhub; in compliance_mode_recovery()
501 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in compliance_mode_recovery()
504 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in compliance_mode_recovery()
506 hcd = xhci->shared_hcd; in compliance_mode_recovery()
515 if (xhci->port_status_u0 != ((1 << rhub->num_ports) - 1)) in compliance_mode_recovery()
516 mod_timer(&xhci->comp_mode_recovery_timer, in compliance_mode_recovery()
527 * status event is generated when entering compliance mode (per xhci spec),
530 static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci) in compliance_mode_recovery_timer_init() argument
532 xhci->port_status_u0 = 0; in compliance_mode_recovery_timer_init()
533 timer_setup(&xhci->comp_mode_recovery_timer, compliance_mode_recovery, in compliance_mode_recovery_timer_init()
535 xhci->comp_mode_recovery_timer.expires = jiffies + in compliance_mode_recovery_timer_init()
538 add_timer(&xhci->comp_mode_recovery_timer); in compliance_mode_recovery_timer_init()
539 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in compliance_mode_recovery_timer_init()
570 static int xhci_all_ports_seen_u0(struct xhci_hcd *xhci) in xhci_all_ports_seen_u0() argument
572 return (xhci->port_status_u0 == ((1 << xhci->usb3_rhub.num_ports) - 1)); in xhci_all_ports_seen_u0()
585 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_init() local
588 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_init"); in xhci_init()
589 spin_lock_init(&xhci->lock); in xhci_init()
590 if (xhci->hci_version == 0x95 && link_quirk) { in xhci_init()
591 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_init()
593 xhci->quirks |= XHCI_LINK_TRB_QUIRK; in xhci_init()
595 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_init()
596 "xHCI doesn't need link TRB QUIRK"); in xhci_init()
598 retval = xhci_mem_init(xhci, GFP_KERNEL); in xhci_init()
599 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Finished xhci_init"); in xhci_init()
603 xhci->quirks |= XHCI_COMP_MODE_QUIRK; in xhci_init()
604 compliance_mode_recovery_timer_init(xhci); in xhci_init()
613 static int xhci_run_finished(struct xhci_hcd *xhci) in xhci_run_finished() argument
615 if (xhci_start(xhci)) { in xhci_run_finished()
616 xhci_halt(xhci); in xhci_run_finished()
619 xhci->shared_hcd->state = HC_STATE_RUNNING; in xhci_run_finished()
620 xhci->cmd_ring_state = CMD_RING_STATE_RUNNING; in xhci_run_finished()
622 if (xhci->quirks & XHCI_NEC_HOST) in xhci_run_finished()
623 xhci_ring_cmd_db(xhci); in xhci_run_finished()
625 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_run_finished()
647 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_run() local
649 /* Start the xHCI host controller running only after the USB 2.0 roothub in xhci_run()
655 return xhci_run_finished(xhci); in xhci_run()
657 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_run"); in xhci_run()
663 temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); in xhci_run()
665 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_run()
668 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_run()
670 temp = readl(&xhci->ir_set->irq_control); in xhci_run()
672 temp |= (xhci->imod_interval / 250) & ER_IRQ_INTERVAL_MASK; in xhci_run()
673 writel(temp, &xhci->ir_set->irq_control); in xhci_run()
676 temp = readl(&xhci->op_regs->command); in xhci_run()
678 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_run()
680 writel(temp, &xhci->op_regs->command); in xhci_run()
682 temp = readl(&xhci->ir_set->irq_pending); in xhci_run()
683 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_run()
685 xhci->ir_set, (unsigned int) ER_IRQ_ENABLE(temp)); in xhci_run()
686 writel(ER_IRQ_ENABLE(temp), &xhci->ir_set->irq_pending); in xhci_run()
688 if (xhci->quirks & XHCI_NEC_HOST) { in xhci_run()
691 command = xhci_alloc_command(xhci, false, GFP_KERNEL); in xhci_run()
695 ret = xhci_queue_vendor_command(xhci, command, 0, 0, 0, in xhci_run()
698 xhci_free_command(xhci, command); in xhci_run()
700 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_run()
705 xhci_dbc_init(xhci); in xhci_run()
707 xhci_debugfs_init(xhci); in xhci_run()
714 * Stop xHCI driver.
725 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_stop() local
727 mutex_lock(&xhci->mutex); in xhci_stop()
731 mutex_unlock(&xhci->mutex); in xhci_stop()
735 xhci_dbc_exit(xhci); in xhci_stop()
737 spin_lock_irq(&xhci->lock); in xhci_stop()
738 xhci->xhc_state |= XHCI_STATE_HALTED; in xhci_stop()
739 xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; in xhci_stop()
740 xhci_halt(xhci); in xhci_stop()
741 xhci_reset(xhci, XHCI_RESET_SHORT_USEC); in xhci_stop()
742 spin_unlock_irq(&xhci->lock); in xhci_stop()
744 xhci_cleanup_msix(xhci); in xhci_stop()
747 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_stop()
748 (!(xhci_all_ports_seen_u0(xhci)))) { in xhci_stop()
749 del_timer_sync(&xhci->comp_mode_recovery_timer); in xhci_stop()
750 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_stop()
755 if (xhci->quirks & XHCI_AMD_PLL_FIX) in xhci_stop()
758 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_stop()
760 temp = readl(&xhci->op_regs->status); in xhci_stop()
761 writel((temp & ~0x1fff) | STS_EINT, &xhci->op_regs->status); in xhci_stop()
762 temp = readl(&xhci->ir_set->irq_pending); in xhci_stop()
763 writel(ER_IRQ_DISABLE(temp), &xhci->ir_set->irq_pending); in xhci_stop()
765 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "cleaning up memory"); in xhci_stop()
766 xhci_mem_cleanup(xhci); in xhci_stop()
767 xhci_debugfs_exit(xhci); in xhci_stop()
768 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_stop()
770 readl(&xhci->op_regs->status)); in xhci_stop()
771 mutex_unlock(&xhci->mutex); in xhci_stop()
785 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_shutdown() local
787 if (xhci->quirks & XHCI_SPURIOUS_REBOOT) in xhci_shutdown()
791 xhci_dbg(xhci, "%s: stopping usb%d port polling.\n", in xhci_shutdown()
796 if (xhci->shared_hcd) { in xhci_shutdown()
797 clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); in xhci_shutdown()
798 del_timer_sync(&xhci->shared_hcd->rh_timer); in xhci_shutdown()
801 spin_lock_irq(&xhci->lock); in xhci_shutdown()
802 xhci_halt(xhci); in xhci_shutdown()
808 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP || in xhci_shutdown()
809 xhci->quirks & XHCI_RESET_TO_DEFAULT) in xhci_shutdown()
810 xhci_reset(xhci, XHCI_RESET_SHORT_USEC); in xhci_shutdown()
812 spin_unlock_irq(&xhci->lock); in xhci_shutdown()
814 xhci_cleanup_msix(xhci); in xhci_shutdown()
816 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_shutdown()
818 readl(&xhci->op_regs->status)); in xhci_shutdown()
823 static void xhci_save_registers(struct xhci_hcd *xhci) in xhci_save_registers() argument
825 xhci->s3.command = readl(&xhci->op_regs->command); in xhci_save_registers()
826 xhci->s3.dev_nt = readl(&xhci->op_regs->dev_notification); in xhci_save_registers()
827 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); in xhci_save_registers()
828 xhci->s3.config_reg = readl(&xhci->op_regs->config_reg); in xhci_save_registers()
829 xhci->s3.erst_size = readl(&xhci->ir_set->erst_size); in xhci_save_registers()
830 xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base); in xhci_save_registers()
831 xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); in xhci_save_registers()
832 xhci->s3.irq_pending = readl(&xhci->ir_set->irq_pending); in xhci_save_registers()
833 xhci->s3.irq_control = readl(&xhci->ir_set->irq_control); in xhci_save_registers()
836 static void xhci_restore_registers(struct xhci_hcd *xhci) in xhci_restore_registers() argument
838 writel(xhci->s3.command, &xhci->op_regs->command); in xhci_restore_registers()
839 writel(xhci->s3.dev_nt, &xhci->op_regs->dev_notification); in xhci_restore_registers()
840 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr); in xhci_restore_registers()
841 writel(xhci->s3.config_reg, &xhci->op_regs->config_reg); in xhci_restore_registers()
842 writel(xhci->s3.erst_size, &xhci->ir_set->erst_size); in xhci_restore_registers()
843 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base); in xhci_restore_registers()
844 xhci_write_64(xhci, xhci->s3.erst_dequeue, &xhci->ir_set->erst_dequeue); in xhci_restore_registers()
845 writel(xhci->s3.irq_pending, &xhci->ir_set->irq_pending); in xhci_restore_registers()
846 writel(xhci->s3.irq_control, &xhci->ir_set->irq_control); in xhci_restore_registers()
849 static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci) in xhci_set_cmd_ring_deq() argument
854 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); in xhci_set_cmd_ring_deq()
856 (xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg, in xhci_set_cmd_ring_deq()
857 xhci->cmd_ring->dequeue) & in xhci_set_cmd_ring_deq()
859 xhci->cmd_ring->cycle_state; in xhci_set_cmd_ring_deq()
860 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_set_cmd_ring_deq()
863 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring); in xhci_set_cmd_ring_deq()
875 static void xhci_clear_command_ring(struct xhci_hcd *xhci) in xhci_clear_command_ring() argument
880 ring = xhci->cmd_ring; in xhci_clear_command_ring()
910 xhci_set_cmd_ring_deq(xhci); in xhci_clear_command_ring()
918 * Internal wake causes immediate xHCI wake after suspend. PORT_CSC write done
922 static void xhci_disable_hub_port_wake(struct xhci_hcd *xhci, in xhci_disable_hub_port_wake() argument
930 spin_lock_irqsave(&xhci->lock, flags); in xhci_disable_hub_port_wake()
947 xhci_dbg(xhci, "config port %d-%d wake bits, portsc: 0x%x, write: 0x%x\n", in xhci_disable_hub_port_wake()
951 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_disable_hub_port_wake()
954 static bool xhci_pending_portevent(struct xhci_hcd *xhci) in xhci_pending_portevent() argument
961 status = readl(&xhci->op_regs->status); in xhci_pending_portevent()
967 * being written to the Event Ring. See note in xhci 1.1 section 4.19.2. in xhci_pending_portevent()
970 port_index = xhci->usb2_rhub.num_ports; in xhci_pending_portevent()
971 ports = xhci->usb2_rhub.ports; in xhci_pending_portevent()
978 port_index = xhci->usb3_rhub.num_ports; in xhci_pending_portevent()
979 ports = xhci->usb3_rhub.ports; in xhci_pending_portevent()
995 int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) in xhci_suspend() argument
999 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_suspend()
1007 xhci->shared_hcd->state != HC_STATE_SUSPENDED) in xhci_suspend()
1011 xhci_disable_hub_port_wake(xhci, &xhci->usb3_rhub, do_wakeup); in xhci_suspend()
1012 xhci_disable_hub_port_wake(xhci, &xhci->usb2_rhub, do_wakeup); in xhci_suspend()
1017 xhci_dbc_suspend(xhci); in xhci_suspend()
1020 xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); in xhci_suspend()
1023 clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); in xhci_suspend()
1024 del_timer_sync(&xhci->shared_hcd->rh_timer); in xhci_suspend()
1026 if (xhci->quirks & XHCI_SUSPEND_DELAY) in xhci_suspend()
1029 spin_lock_irq(&xhci->lock); in xhci_suspend()
1031 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); in xhci_suspend()
1036 command = readl(&xhci->op_regs->command); in xhci_suspend()
1038 writel(command, &xhci->op_regs->command); in xhci_suspend()
1041 delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1; in xhci_suspend()
1043 if (xhci_handshake(&xhci->op_regs->status, in xhci_suspend()
1045 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); in xhci_suspend()
1046 spin_unlock_irq(&xhci->lock); in xhci_suspend()
1049 xhci_clear_command_ring(xhci); in xhci_suspend()
1052 xhci_save_registers(xhci); in xhci_suspend()
1055 command = readl(&xhci->op_regs->command); in xhci_suspend()
1057 writel(command, &xhci->op_regs->command); in xhci_suspend()
1058 xhci->broken_suspend = 0; in xhci_suspend()
1059 if (xhci_handshake(&xhci->op_regs->status, in xhci_suspend()
1067 * if SRE and HCE bits are not set (as per xhci in xhci_suspend()
1070 res = readl(&xhci->op_regs->status); in xhci_suspend()
1071 if ((xhci->quirks & XHCI_SNPS_BROKEN_SUSPEND) && in xhci_suspend()
1074 xhci->broken_suspend = 1; in xhci_suspend()
1076 xhci_warn(xhci, "WARN: xHC save state timeout\n"); in xhci_suspend()
1077 spin_unlock_irq(&xhci->lock); in xhci_suspend()
1081 spin_unlock_irq(&xhci->lock); in xhci_suspend()
1084 * Deleting Compliance Mode Recovery Timer because the xHCI Host in xhci_suspend()
1087 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_suspend()
1088 (!(xhci_all_ports_seen_u0(xhci)))) { in xhci_suspend()
1089 del_timer_sync(&xhci->comp_mode_recovery_timer); in xhci_suspend()
1090 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_suspend()
1097 xhci_msix_sync_irqs(xhci); in xhci_suspend()
1109 int xhci_resume(struct xhci_hcd *xhci, bool hibernated) in xhci_resume() argument
1112 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_resume()
1126 if (time_before(jiffies, xhci->usb2_rhub.bus_state.next_statechange) || in xhci_resume()
1127 time_before(jiffies, xhci->usb3_rhub.bus_state.next_statechange)) in xhci_resume()
1131 set_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); in xhci_resume()
1133 spin_lock_irq(&xhci->lock); in xhci_resume()
1135 if (hibernated || xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_suspend) in xhci_resume()
1143 retval = xhci_handshake(&xhci->op_regs->status, in xhci_resume()
1146 xhci_warn(xhci, "Controller not ready at resume %d\n", in xhci_resume()
1148 spin_unlock_irq(&xhci->lock); in xhci_resume()
1152 xhci_restore_registers(xhci); in xhci_resume()
1154 xhci_set_cmd_ring_deq(xhci); in xhci_resume()
1157 command = readl(&xhci->op_regs->command); in xhci_resume()
1159 writel(command, &xhci->op_regs->command); in xhci_resume()
1162 * restore so setting the timeout to 100ms. Xhci specification in xhci_resume()
1165 if (xhci_handshake(&xhci->op_regs->status, in xhci_resume()
1167 xhci_warn(xhci, "WARN: xHC restore state timeout\n"); in xhci_resume()
1168 spin_unlock_irq(&xhci->lock); in xhci_resume()
1173 temp = readl(&xhci->op_regs->status); in xhci_resume()
1178 if (!xhci->broken_suspend) in xhci_resume()
1179 xhci_warn(xhci, "xHC error in resume, USBSTS 0x%x, Reinit\n", temp); in xhci_resume()
1183 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && in xhci_resume()
1184 !(xhci_all_ports_seen_u0(xhci))) { in xhci_resume()
1185 del_timer_sync(&xhci->comp_mode_recovery_timer); in xhci_resume()
1186 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_resume()
1191 usb_root_hub_lost_power(xhci->main_hcd->self.root_hub); in xhci_resume()
1192 usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub); in xhci_resume()
1194 xhci_dbg(xhci, "Stop HCD\n"); in xhci_resume()
1195 xhci_halt(xhci); in xhci_resume()
1196 xhci_zero_64b_regs(xhci); in xhci_resume()
1197 retval = xhci_reset(xhci, XHCI_RESET_LONG_USEC); in xhci_resume()
1198 spin_unlock_irq(&xhci->lock); in xhci_resume()
1201 xhci_cleanup_msix(xhci); in xhci_resume()
1203 xhci_dbg(xhci, "// Disabling event ring interrupts\n"); in xhci_resume()
1204 temp = readl(&xhci->op_regs->status); in xhci_resume()
1205 writel((temp & ~0x1fff) | STS_EINT, &xhci->op_regs->status); in xhci_resume()
1206 temp = readl(&xhci->ir_set->irq_pending); in xhci_resume()
1207 writel(ER_IRQ_DISABLE(temp), &xhci->ir_set->irq_pending); in xhci_resume()
1209 xhci_dbg(xhci, "cleaning up memory\n"); in xhci_resume()
1210 xhci_mem_cleanup(xhci); in xhci_resume()
1211 xhci_debugfs_exit(xhci); in xhci_resume()
1212 xhci_dbg(xhci, "xhci_stop completed - status = %x\n", in xhci_resume()
1213 readl(&xhci->op_regs->status)); in xhci_resume()
1222 secondary_hcd = xhci->shared_hcd; in xhci_resume()
1224 xhci_dbg(xhci, "Initialize the xhci_hcd\n"); in xhci_resume()
1230 xhci_dbg(xhci, "Start the primary HCD\n"); in xhci_resume()
1233 xhci_dbg(xhci, "Start the secondary HCD\n"); in xhci_resume()
1237 xhci->shared_hcd->state = HC_STATE_SUSPENDED; in xhci_resume()
1242 command = readl(&xhci->op_regs->command); in xhci_resume()
1244 writel(command, &xhci->op_regs->command); in xhci_resume()
1245 xhci_handshake(&xhci->op_regs->status, STS_HALT, in xhci_resume()
1257 spin_unlock_irq(&xhci->lock); in xhci_resume()
1259 xhci_dbc_resume(xhci); in xhci_resume()
1268 pending_portevent = xhci_pending_portevent(xhci); in xhci_resume()
1271 pending_portevent = xhci_pending_portevent(xhci); in xhci_resume()
1275 usb_hcd_resume_root_hub(xhci->shared_hcd); in xhci_resume()
1285 if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && !comp_timer_running) in xhci_resume()
1286 compliance_mode_recovery_timer_init(xhci); in xhci_resume()
1288 if (xhci->quirks & XHCI_ASMEDIA_MODIFY_FLOWCONTROL) in xhci_resume()
1292 xhci_dbg(xhci, "%s: starting port polling.\n", __func__); in xhci_resume()
1293 set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); in xhci_resume()
1294 usb_hcd_poll_rh_status(xhci->shared_hcd); in xhci_resume()
1342 * address from the XHCI endpoint index.
1386 struct xhci_hcd *xhci; in xhci_check_args() local
1390 pr_debug("xHCI %s called with invalid args\n", func); in xhci_check_args()
1394 pr_debug("xHCI %s called for root hub\n", func); in xhci_check_args()
1398 xhci = hcd_to_xhci(hcd); in xhci_check_args()
1400 if (!udev->slot_id || !xhci->devs[udev->slot_id]) { in xhci_check_args()
1401 xhci_dbg(xhci, "xHCI %s called with unaddressed device\n", in xhci_check_args()
1406 virt_dev = xhci->devs[udev->slot_id]; in xhci_check_args()
1408 xhci_dbg(xhci, "xHCI %s called with udev and " in xhci_check_args()
1414 if (xhci->xhc_state & XHCI_STATE_HALTED) in xhci_check_args()
1420 static int xhci_configure_endpoint(struct xhci_hcd *xhci,
1430 static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, in xhci_check_maxpacket() argument
1441 out_ctx = xhci->devs[slot_id]->out_ctx; in xhci_check_maxpacket()
1442 ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); in xhci_check_maxpacket()
1446 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_check_maxpacket()
1448 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_check_maxpacket()
1451 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_check_maxpacket()
1452 "Max packet size in xHCI HW = %d", in xhci_check_maxpacket()
1454 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_check_maxpacket()
1462 command = xhci_alloc_command(xhci, true, mem_flags); in xhci_check_maxpacket()
1466 command->in_ctx = xhci->devs[slot_id]->in_ctx; in xhci_check_maxpacket()
1469 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_check_maxpacket()
1475 xhci_endpoint_copy(xhci, xhci->devs[slot_id]->in_ctx, in xhci_check_maxpacket()
1476 xhci->devs[slot_id]->out_ctx, ep_index); in xhci_check_maxpacket()
1478 ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, ep_index); in xhci_check_maxpacket()
1486 ret = xhci_configure_endpoint(xhci, urb->dev, command, in xhci_check_maxpacket()
1506 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_urb_enqueue() local
1523 ep_state = &xhci->devs[slot_id]->eps[ep_index].ep_state; in xhci_urb_enqueue()
1527 xhci_dbg(xhci, "urb submitted during PCI suspend\n"); in xhci_urb_enqueue()
1530 if (xhci->devs[slot_id]->flags & VDEV_PORT_ERROR) { in xhci_urb_enqueue()
1531 xhci_dbg(xhci, "Can't queue urb, port error, link inactive\n"); in xhci_urb_enqueue()
1560 ret = xhci_check_maxpacket(xhci, slot_id, in xhci_urb_enqueue()
1570 spin_lock_irqsave(&xhci->lock, flags); in xhci_urb_enqueue()
1572 if (xhci->xhc_state & XHCI_STATE_DYING) { in xhci_urb_enqueue()
1573 xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for non-responsive xHCI host.\n", in xhci_urb_enqueue()
1579 xhci_warn(xhci, "WARN: Can't enqueue URB, ep in streams transition state %x\n", in xhci_urb_enqueue()
1585 xhci_warn(xhci, "Can't enqueue URB while manually clearing toggle\n"); in xhci_urb_enqueue()
1593 ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb, in xhci_urb_enqueue()
1597 ret = xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb, in xhci_urb_enqueue()
1601 ret = xhci_queue_intr_tx(xhci, GFP_ATOMIC, urb, in xhci_urb_enqueue()
1605 ret = xhci_queue_isoc_tx_prepare(xhci, GFP_ATOMIC, urb, in xhci_urb_enqueue()
1614 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_urb_enqueue()
1636 * endpoint command, as noted in the xHCI 0.95 errata.
1654 struct xhci_hcd *xhci; in xhci_urb_dequeue() local
1663 xhci = hcd_to_xhci(hcd); in xhci_urb_dequeue()
1664 spin_lock_irqsave(&xhci->lock, flags); in xhci_urb_dequeue()
1674 vdev = xhci->devs[urb->dev->slot_id]; in xhci_urb_dequeue()
1681 ep_ring = xhci_urb_to_transfer_ring(xhci, urb); in xhci_urb_dequeue()
1686 temp = readl(&xhci->op_regs->status); in xhci_urb_dequeue()
1687 if (temp == ~(u32)0 || xhci->xhc_state & XHCI_STATE_DYING) { in xhci_urb_dequeue()
1688 xhci_hc_died(xhci); in xhci_urb_dequeue()
1698 xhci_err(xhci, "Canceled URB td not found on endpoint ring"); in xhci_urb_dequeue()
1707 if (xhci->xhc_state & XHCI_STATE_HALTED) { in xhci_urb_dequeue()
1708 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, in xhci_urb_dequeue()
1724 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, in xhci_urb_dequeue()
1742 command = xhci_alloc_command(xhci, false, GFP_ATOMIC); in xhci_urb_dequeue()
1751 xhci_queue_stop_endpoint(xhci, command, urb->dev->slot_id, in xhci_urb_dequeue()
1753 xhci_ring_cmd_db(xhci); in xhci_urb_dequeue()
1756 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_urb_dequeue()
1763 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_urb_dequeue()
1779 * the xhci->devs[slot_id] structure.
1784 struct xhci_hcd *xhci; in xhci_drop_endpoint() local
1796 xhci = hcd_to_xhci(hcd); in xhci_drop_endpoint()
1797 if (xhci->xhc_state & XHCI_STATE_DYING) in xhci_drop_endpoint()
1800 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev); in xhci_drop_endpoint()
1803 xhci_dbg(xhci, "xHCI %s - can't drop slot or ep 0 %#x\n", in xhci_drop_endpoint()
1808 in_ctx = xhci->devs[udev->slot_id]->in_ctx; in xhci_drop_endpoint()
1809 out_ctx = xhci->devs[udev->slot_id]->out_ctx; in xhci_drop_endpoint()
1812 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_drop_endpoint()
1818 ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); in xhci_drop_endpoint()
1826 if (xhci->devs[udev->slot_id]->eps[ep_index].ring != NULL) in xhci_drop_endpoint()
1827 xhci_warn(xhci, "xHCI %s called with disabled ep %p\n", in xhci_drop_endpoint()
1838 xhci_debugfs_remove_endpoint(xhci, xhci->devs[udev->slot_id], ep_index); in xhci_drop_endpoint()
1840 xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep); in xhci_drop_endpoint()
1842 if (xhci->quirks & XHCI_MTK_HOST) in xhci_drop_endpoint()
1845 xhci_dbg(xhci, "drop ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x\n", in xhci_drop_endpoint()
1864 * for mutual exclusion to protect the xhci->devs[slot_id] structure.
1869 struct xhci_hcd *xhci; in xhci_add_endpoint() local
1885 xhci = hcd_to_xhci(hcd); in xhci_add_endpoint()
1886 if (xhci->xhc_state & XHCI_STATE_DYING) in xhci_add_endpoint()
1895 xhci_dbg(xhci, "xHCI %s - can't add slot or ep 0 %#x\n", in xhci_add_endpoint()
1900 virt_dev = xhci->devs[udev->slot_id]; in xhci_add_endpoint()
1904 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_add_endpoint()
1915 xhci_warn(xhci, "Trying to add endpoint 0x%x " in xhci_add_endpoint()
1925 xhci_warn(xhci, "xHCI %s called with enabled ep %p\n", in xhci_add_endpoint()
1935 if (xhci_endpoint_init(xhci, virt_dev, udev, ep, GFP_NOIO) < 0) { in xhci_add_endpoint()
1941 if (xhci->quirks & XHCI_MTK_HOST) { in xhci_add_endpoint()
1944 xhci_ring_free(xhci, virt_dev->eps[ep_index].new_ring); in xhci_add_endpoint()
1964 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); in xhci_add_endpoint()
1967 xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x\n", in xhci_add_endpoint()
1975 static void xhci_zero_in_ctx(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev) in xhci_zero_in_ctx() argument
1984 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_zero_in_ctx()
1996 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); in xhci_zero_in_ctx()
2001 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, i); in xhci_zero_in_ctx()
2009 static int xhci_configure_endpoint_result(struct xhci_hcd *xhci, in xhci_configure_endpoint_result() argument
2017 xhci_warn(xhci, "Timeout while waiting for configure endpoint command\n"); in xhci_configure_endpoint_result()
2046 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_configure_endpoint_result()
2051 xhci_err(xhci, "ERROR: unexpected command completion code 0x%x.\n", in xhci_configure_endpoint_result()
2059 static int xhci_evaluate_context_result(struct xhci_hcd *xhci, in xhci_evaluate_context_result() argument
2067 xhci_warn(xhci, "Timeout while waiting for evaluate context command\n"); in xhci_evaluate_context_result()
2072 "WARN: xHCI driver setup invalid evaluate context command.\n"); in xhci_evaluate_context_result()
2096 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_evaluate_context_result()
2101 xhci_err(xhci, "ERROR: unexpected command completion code 0x%x.\n", in xhci_evaluate_context_result()
2109 static u32 xhci_count_num_new_endpoints(struct xhci_hcd *xhci, in xhci_count_num_new_endpoints() argument
2130 static unsigned int xhci_count_num_dropped_endpoints(struct xhci_hcd *xhci, in xhci_count_num_dropped_endpoints() argument
2154 * Must be called with xhci->lock held.
2156 static int xhci_reserve_host_resources(struct xhci_hcd *xhci, in xhci_reserve_host_resources() argument
2161 added_eps = xhci_count_num_new_endpoints(xhci, ctrl_ctx); in xhci_reserve_host_resources()
2162 if (xhci->num_active_eps + added_eps > xhci->limit_active_eps) { in xhci_reserve_host_resources()
2163 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_reserve_host_resources()
2166 xhci->num_active_eps, added_eps, in xhci_reserve_host_resources()
2167 xhci->limit_active_eps); in xhci_reserve_host_resources()
2170 xhci->num_active_eps += added_eps; in xhci_reserve_host_resources()
2171 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_reserve_host_resources()
2173 xhci->num_active_eps); in xhci_reserve_host_resources()
2181 * Must be called with xhci->lock held.
2183 static void xhci_free_host_resources(struct xhci_hcd *xhci, in xhci_free_host_resources() argument
2188 num_failed_eps = xhci_count_num_new_endpoints(xhci, ctrl_ctx); in xhci_free_host_resources()
2189 xhci->num_active_eps -= num_failed_eps; in xhci_free_host_resources()
2190 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_free_host_resources()
2193 xhci->num_active_eps); in xhci_free_host_resources()
2200 * Must be called with xhci->lock held.
2202 static void xhci_finish_resource_reservation(struct xhci_hcd *xhci, in xhci_finish_resource_reservation() argument
2207 num_dropped_eps = xhci_count_num_dropped_endpoints(xhci, ctrl_ctx); in xhci_finish_resource_reservation()
2208 xhci->num_active_eps -= num_dropped_eps; in xhci_finish_resource_reservation()
2210 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_finish_resource_reservation()
2213 xhci->num_active_eps); in xhci_finish_resource_reservation()
2249 static int xhci_check_tt_bw_table(struct xhci_hcd *xhci, in xhci_check_tt_bw_table() argument
2257 bw_table = &xhci->rh_bw[virt_dev->real_port - 1].bw_table; in xhci_check_tt_bw_table()
2279 static int xhci_check_ss_bw(struct xhci_hcd *xhci, in xhci_check_ss_bw() argument
2336 static int xhci_check_bw_table(struct xhci_hcd *xhci, in xhci_check_bw_table() argument
2352 return xhci_check_ss_bw(xhci, virt_dev); in xhci_check_bw_table()
2373 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_check_bw_table()
2376 if (xhci_check_tt_bw_table(xhci, virt_dev, old_active_eps)) { in xhci_check_bw_table()
2377 xhci_warn(xhci, "Not enough bandwidth on HS bus for " in xhci_check_bw_table()
2381 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_check_bw_table()
2386 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_check_bw_table()
2469 xhci_warn(xhci, "Not enough bandwidth. " in xhci_check_bw_table()
2492 xhci->rh_bw[port_index].num_active_tts; in xhci_check_bw_table()
2495 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_check_bw_table()
2504 xhci_warn(xhci, "Not enough bandwidth. Proposed: %u, Max: %u\n", in xhci_check_bw_table()
2539 static void xhci_drop_ep_from_interval_table(struct xhci_hcd *xhci, in xhci_drop_ep_from_interval_table() argument
2554 xhci->devs[udev->slot_id]->bw_table->ss_bw_in -= in xhci_drop_ep_from_interval_table()
2557 xhci->devs[udev->slot_id]->bw_table->ss_bw_out -= in xhci_drop_ep_from_interval_table()
2603 static void xhci_add_ep_to_interval_table(struct xhci_hcd *xhci, in xhci_add_ep_to_interval_table() argument
2619 xhci->devs[udev->slot_id]->bw_table->ss_bw_in += in xhci_add_ep_to_interval_table()
2622 xhci->devs[udev->slot_id]->bw_table->ss_bw_out += in xhci_add_ep_to_interval_table()
2677 void xhci_update_tt_active_eps(struct xhci_hcd *xhci, in xhci_update_tt_active_eps() argument
2685 rh_bw_info = &xhci->rh_bw[virt_dev->real_port - 1]; in xhci_update_tt_active_eps()
2697 static int xhci_reserve_bandwidth(struct xhci_hcd *xhci, in xhci_reserve_bandwidth() argument
2711 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_reserve_bandwidth()
2727 xhci_drop_ep_from_interval_table(xhci, in xhci_reserve_bandwidth()
2735 xhci_update_bw_info(xhci, virt_dev->in_ctx, ctrl_ctx, virt_dev); in xhci_reserve_bandwidth()
2739 xhci_add_ep_to_interval_table(xhci, in xhci_reserve_bandwidth()
2747 if (!xhci_check_bw_table(xhci, virt_dev, old_active_eps)) { in xhci_reserve_bandwidth()
2751 xhci_update_tt_active_eps(xhci, virt_dev, old_active_eps); in xhci_reserve_bandwidth()
2764 xhci_drop_ep_from_interval_table(xhci, in xhci_reserve_bandwidth()
2776 xhci_add_ep_to_interval_table(xhci, in xhci_reserve_bandwidth()
2790 static int xhci_configure_endpoint(struct xhci_hcd *xhci, in xhci_configure_endpoint() argument
2804 spin_lock_irqsave(&xhci->lock, flags); in xhci_configure_endpoint()
2806 if (xhci->xhc_state & XHCI_STATE_DYING) { in xhci_configure_endpoint()
2807 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2811 virt_dev = xhci->devs[udev->slot_id]; in xhci_configure_endpoint()
2815 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2816 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_configure_endpoint()
2821 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK) && in xhci_configure_endpoint()
2822 xhci_reserve_host_resources(xhci, ctrl_ctx)) { in xhci_configure_endpoint()
2823 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2824 xhci_warn(xhci, "Not enough host resources, " in xhci_configure_endpoint()
2826 xhci->num_active_eps); in xhci_configure_endpoint()
2829 if ((xhci->quirks & XHCI_SW_BW_CHECKING) && !ctx_change && in xhci_configure_endpoint()
2830 xhci_reserve_bandwidth(xhci, virt_dev, command->in_ctx)) { in xhci_configure_endpoint()
2831 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) in xhci_configure_endpoint()
2832 xhci_free_host_resources(xhci, ctrl_ctx); in xhci_configure_endpoint()
2833 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2834 xhci_warn(xhci, "Not enough bandwidth\n"); in xhci_configure_endpoint()
2838 slot_ctx = xhci_get_slot_ctx(xhci, command->in_ctx); in xhci_configure_endpoint()
2844 ret = xhci_queue_configure_endpoint(xhci, command, in xhci_configure_endpoint()
2848 ret = xhci_queue_evaluate_context(xhci, command, in xhci_configure_endpoint()
2852 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) in xhci_configure_endpoint()
2853 xhci_free_host_resources(xhci, ctrl_ctx); in xhci_configure_endpoint()
2854 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2855 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_configure_endpoint()
2859 xhci_ring_cmd_db(xhci); in xhci_configure_endpoint()
2860 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2866 ret = xhci_configure_endpoint_result(xhci, udev, in xhci_configure_endpoint()
2869 ret = xhci_evaluate_context_result(xhci, udev, in xhci_configure_endpoint()
2872 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) { in xhci_configure_endpoint()
2873 spin_lock_irqsave(&xhci->lock, flags); in xhci_configure_endpoint()
2878 xhci_free_host_resources(xhci, ctrl_ctx); in xhci_configure_endpoint()
2880 xhci_finish_resource_reservation(xhci, ctrl_ctx); in xhci_configure_endpoint()
2881 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_configure_endpoint()
2886 static void xhci_check_bw_drop_ep_streams(struct xhci_hcd *xhci, in xhci_check_bw_drop_ep_streams() argument
2892 xhci_warn(xhci, "WARN: endpoint 0x%02x has streams on set_interface, freeing streams.\n", in xhci_check_bw_drop_ep_streams()
2894 xhci_free_stream_info(xhci, ep->stream_info); in xhci_check_bw_drop_ep_streams()
2907 * else should be touching the xhci->devs[slot_id] structure, so we
2908 * don't need to take the xhci->lock for manipulating that.
2914 struct xhci_hcd *xhci; in xhci_check_bandwidth() local
2923 xhci = hcd_to_xhci(hcd); in xhci_check_bandwidth()
2924 if ((xhci->xhc_state & XHCI_STATE_DYING) || in xhci_check_bandwidth()
2925 (xhci->xhc_state & XHCI_STATE_REMOVING)) in xhci_check_bandwidth()
2928 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev); in xhci_check_bandwidth()
2929 virt_dev = xhci->devs[udev->slot_id]; in xhci_check_bandwidth()
2931 command = xhci_alloc_command(xhci, true, GFP_KERNEL); in xhci_check_bandwidth()
2940 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_check_bandwidth()
2956 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); in xhci_check_bandwidth()
2968 ret = xhci_configure_endpoint(xhci, udev, command, in xhci_check_bandwidth()
2978 xhci_free_endpoint_ring(xhci, virt_dev, i); in xhci_check_bandwidth()
2979 xhci_check_bw_drop_ep_streams(xhci, virt_dev, i); in xhci_check_bandwidth()
2982 xhci_zero_in_ctx(xhci, virt_dev); in xhci_check_bandwidth()
2994 xhci_free_endpoint_ring(xhci, virt_dev, i); in xhci_check_bandwidth()
2996 xhci_check_bw_drop_ep_streams(xhci, virt_dev, i); in xhci_check_bandwidth()
2999 xhci_debugfs_create_endpoint(xhci, virt_dev, i); in xhci_check_bandwidth()
3010 struct xhci_hcd *xhci; in xhci_reset_bandwidth() local
3017 xhci = hcd_to_xhci(hcd); in xhci_reset_bandwidth()
3019 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev); in xhci_reset_bandwidth()
3020 virt_dev = xhci->devs[udev->slot_id]; in xhci_reset_bandwidth()
3024 xhci_debugfs_remove_endpoint(xhci, virt_dev, i); in xhci_reset_bandwidth()
3025 xhci_ring_free(xhci, virt_dev->eps[i].new_ring); in xhci_reset_bandwidth()
3029 xhci_zero_in_ctx(xhci, virt_dev); in xhci_reset_bandwidth()
3032 static void xhci_setup_input_ctx_for_config_ep(struct xhci_hcd *xhci, in xhci_setup_input_ctx_for_config_ep() argument
3040 xhci_slot_copy(xhci, in_ctx, out_ctx); in xhci_setup_input_ctx_for_config_ep()
3044 static void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci, in xhci_setup_input_ctx_for_quirk() argument
3054 in_ctx = xhci->devs[slot_id]->in_ctx; in xhci_setup_input_ctx_for_quirk()
3057 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_setup_input_ctx_for_quirk()
3062 xhci_endpoint_copy(xhci, xhci->devs[slot_id]->in_ctx, in xhci_setup_input_ctx_for_quirk()
3063 xhci->devs[slot_id]->out_ctx, ep_index); in xhci_setup_input_ctx_for_quirk()
3064 ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index); in xhci_setup_input_ctx_for_quirk()
3068 xhci_warn(xhci, "WARN Cannot submit config ep after " in xhci_setup_input_ctx_for_quirk()
3070 xhci_warn(xhci, "WARN deq seg = %p, deq ptr = %p\n", in xhci_setup_input_ctx_for_quirk()
3078 xhci_setup_input_ctx_for_config_ep(xhci, xhci->devs[slot_id]->in_ctx, in xhci_setup_input_ctx_for_quirk()
3079 xhci->devs[slot_id]->out_ctx, ctrl_ctx, in xhci_setup_input_ctx_for_quirk()
3083 void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, unsigned int slot_id, in xhci_cleanup_stalled_ring() argument
3089 xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep, in xhci_cleanup_stalled_ring()
3094 xhci_find_new_dequeue_state(xhci, slot_id, ep_index, stream_id, td, in xhci_cleanup_stalled_ring()
3103 if (!(xhci->quirks & XHCI_RESET_EP_QUIRK)) { in xhci_cleanup_stalled_ring()
3104 xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep, in xhci_cleanup_stalled_ring()
3106 xhci_queue_new_dequeue_state(xhci, slot_id, in xhci_cleanup_stalled_ring()
3114 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_cleanup_stalled_ring()
3117 xhci_setup_input_ctx_for_quirk(xhci, slot_id, in xhci_cleanup_stalled_ring()
3125 struct xhci_hcd *xhci; in xhci_endpoint_disable() local
3132 xhci = hcd_to_xhci(hcd); in xhci_endpoint_disable()
3134 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_disable()
3140 vdev = xhci->devs[udev->slot_id]; in xhci_endpoint_disable()
3151 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_disable()
3157 xhci_dbg(xhci, "endpoint disable with ep_state 0x%x\n", in xhci_endpoint_disable()
3161 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_disable()
3173 * endpoint. Refer to the additional note in xhci spcification section 4.6.8.
3179 struct xhci_hcd *xhci; in xhci_endpoint_reset() local
3190 xhci = hcd_to_xhci(hcd); in xhci_endpoint_reset()
3194 vdev = xhci->devs[udev->slot_id]; in xhci_endpoint_reset()
3209 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_reset()
3212 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3215 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3226 stop_cmd = xhci_alloc_command(xhci, true, GFP_NOWAIT); in xhci_endpoint_reset()
3230 cfg_cmd = xhci_alloc_command_with_ctx(xhci, true, GFP_NOWAIT); in xhci_endpoint_reset()
3234 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_reset()
3247 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3248 xhci_free_command(xhci, cfg_cmd); in xhci_endpoint_reset()
3252 err = xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, in xhci_endpoint_reset()
3255 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3256 xhci_free_command(xhci, cfg_cmd); in xhci_endpoint_reset()
3257 xhci_dbg(xhci, "%s: Failed to queue stop ep command, %d ", in xhci_endpoint_reset()
3262 xhci_ring_cmd_db(xhci); in xhci_endpoint_reset()
3263 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3267 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_reset()
3272 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3273 xhci_free_command(xhci, cfg_cmd); in xhci_endpoint_reset()
3274 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_endpoint_reset()
3279 xhci_setup_input_ctx_for_config_ep(xhci, cfg_cmd->in_ctx, vdev->out_ctx, in xhci_endpoint_reset()
3281 xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index); in xhci_endpoint_reset()
3283 err = xhci_queue_configure_endpoint(xhci, cfg_cmd, cfg_cmd->in_ctx->dma, in xhci_endpoint_reset()
3286 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3287 xhci_free_command(xhci, cfg_cmd); in xhci_endpoint_reset()
3288 xhci_dbg(xhci, "%s: Failed to queue config ep command, %d ", in xhci_endpoint_reset()
3293 xhci_ring_cmd_db(xhci); in xhci_endpoint_reset()
3294 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3298 xhci_free_command(xhci, cfg_cmd); in xhci_endpoint_reset()
3300 xhci_free_command(xhci, stop_cmd); in xhci_endpoint_reset()
3301 spin_lock_irqsave(&xhci->lock, flags); in xhci_endpoint_reset()
3304 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_endpoint_reset()
3307 static int xhci_check_streams_endpoint(struct xhci_hcd *xhci, in xhci_check_streams_endpoint() argument
3317 ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__); in xhci_check_streams_endpoint()
3321 xhci_warn(xhci, "WARN: SuperSpeed Endpoint Companion" in xhci_check_streams_endpoint()
3328 ep_state = xhci->devs[slot_id]->eps[ep_index].ep_state; in xhci_check_streams_endpoint()
3331 xhci_warn(xhci, "WARN: SuperSpeed bulk endpoint 0x%x " in xhci_check_streams_endpoint()
3334 xhci_warn(xhci, "Send email to xHCI maintainer and ask for " in xhci_check_streams_endpoint()
3338 if (!list_empty(&xhci->devs[slot_id]->eps[ep_index].ring->td_list)) { in xhci_check_streams_endpoint()
3339 xhci_warn(xhci, "Cannot setup streams for SuperSpeed bulk " in xhci_check_streams_endpoint()
3347 static void xhci_calculate_streams_entries(struct xhci_hcd *xhci, in xhci_calculate_streams_entries() argument
3357 * level page entries), but that's an optional feature for xHCI host in xhci_calculate_streams_entries()
3360 max_streams = HCC_MAX_PSA(xhci->hcc_params); in xhci_calculate_streams_entries()
3362 xhci_dbg(xhci, "xHCI HW only supports %u stream ctx entries.\n", in xhci_calculate_streams_entries()
3373 static int xhci_calculate_streams_and_bitmask(struct xhci_hcd *xhci, in xhci_calculate_streams_and_bitmask() argument
3384 ret = xhci_check_streams_endpoint(xhci, udev, in xhci_calculate_streams_and_bitmask()
3391 xhci_dbg(xhci, "Ep 0x%x only supports %u stream IDs.\n", in xhci_calculate_streams_and_bitmask()
3405 static u32 xhci_calculate_no_streams_bitmask(struct xhci_hcd *xhci, in xhci_calculate_no_streams_bitmask() argument
3416 if (!xhci->devs[slot_id]) in xhci_calculate_no_streams_bitmask()
3421 ep_state = xhci->devs[slot_id]->eps[ep_index].ep_state; in xhci_calculate_no_streams_bitmask()
3424 xhci_warn(xhci, "WARN Can't disable streams for " in xhci_calculate_no_streams_bitmask()
3433 xhci_warn(xhci, "WARN Can't disable streams for " in xhci_calculate_no_streams_bitmask()
3437 xhci_warn(xhci, "WARN xhci_free_streams() called " in xhci_calculate_no_streams_bitmask()
3467 struct xhci_hcd *xhci; in xhci_alloc_streams() local
3481 * stream 0 that is reserved for xHCI usage. in xhci_alloc_streams()
3484 xhci = hcd_to_xhci(hcd); in xhci_alloc_streams()
3485 xhci_dbg(xhci, "Driver wants %u stream IDs (including stream 0).\n", in xhci_alloc_streams()
3489 if ((xhci->quirks & XHCI_BROKEN_STREAMS) || in xhci_alloc_streams()
3490 HCC_MAX_PSA(xhci->hcc_params) < 4) { in xhci_alloc_streams()
3491 xhci_dbg(xhci, "xHCI controller does not support streams.\n"); in xhci_alloc_streams()
3495 config_cmd = xhci_alloc_command_with_ctx(xhci, true, mem_flags); in xhci_alloc_streams()
3501 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_alloc_streams()
3503 xhci_free_command(xhci, config_cmd); in xhci_alloc_streams()
3511 spin_lock_irqsave(&xhci->lock, flags); in xhci_alloc_streams()
3512 ret = xhci_calculate_streams_and_bitmask(xhci, udev, eps, in xhci_alloc_streams()
3515 xhci_free_command(xhci, config_cmd); in xhci_alloc_streams()
3516 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_streams()
3520 xhci_warn(xhci, "WARN: endpoints can't handle " in xhci_alloc_streams()
3522 xhci_free_command(xhci, config_cmd); in xhci_alloc_streams()
3523 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_streams()
3526 vdev = xhci->devs[udev->slot_id]; in xhci_alloc_streams()
3534 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_streams()
3540 xhci_calculate_streams_entries(xhci, &num_streams, &num_stream_ctxs); in xhci_alloc_streams()
3541 xhci_dbg(xhci, "Need %u stream ctx entries for %u stream IDs.\n", in xhci_alloc_streams()
3547 vdev->eps[ep_index].stream_info = xhci_alloc_stream_info(xhci, in xhci_alloc_streams()
3563 ep_ctx = xhci_get_ep_ctx(xhci, config_cmd->in_ctx, ep_index); in xhci_alloc_streams()
3565 xhci_endpoint_copy(xhci, config_cmd->in_ctx, in xhci_alloc_streams()
3567 xhci_setup_streams_ep_input_ctx(xhci, ep_ctx, in xhci_alloc_streams()
3573 xhci_setup_input_ctx_for_config_ep(xhci, config_cmd->in_ctx, in xhci_alloc_streams()
3578 ret = xhci_configure_endpoint(xhci, udev, config_cmd, in xhci_alloc_streams()
3588 spin_lock_irqsave(&xhci->lock, flags); in xhci_alloc_streams()
3592 xhci_dbg(xhci, "Slot %u ep ctx %u now has streams.\n", in xhci_alloc_streams()
3596 xhci_free_command(xhci, config_cmd); in xhci_alloc_streams()
3597 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_streams()
3601 xhci_debugfs_create_stream_files(xhci, vdev, ep_index); in xhci_alloc_streams()
3610 xhci_free_stream_info(xhci, vdev->eps[ep_index].stream_info); in xhci_alloc_streams()
3617 xhci_endpoint_zero(xhci, vdev, eps[i]); in xhci_alloc_streams()
3619 xhci_free_command(xhci, config_cmd); in xhci_alloc_streams()
3634 struct xhci_hcd *xhci; in xhci_free_streams() local
3642 xhci = hcd_to_xhci(hcd); in xhci_free_streams()
3643 vdev = xhci->devs[udev->slot_id]; in xhci_free_streams()
3646 spin_lock_irqsave(&xhci->lock, flags); in xhci_free_streams()
3647 changed_ep_bitmask = xhci_calculate_no_streams_bitmask(xhci, in xhci_free_streams()
3650 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_streams()
3662 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_streams()
3663 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_free_streams()
3672 ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, ep_index); in xhci_free_streams()
3673 xhci->devs[udev->slot_id]->eps[ep_index].ep_state |= in xhci_free_streams()
3676 xhci_endpoint_copy(xhci, command->in_ctx, in xhci_free_streams()
3681 xhci_setup_input_ctx_for_config_ep(xhci, command->in_ctx, in xhci_free_streams()
3684 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_streams()
3689 ret = xhci_configure_endpoint(xhci, udev, command, in xhci_free_streams()
3698 spin_lock_irqsave(&xhci->lock, flags); in xhci_free_streams()
3701 xhci_free_stream_info(xhci, vdev->eps[ep_index].stream_info); in xhci_free_streams()
3709 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_streams()
3719 * Must be called with xhci->lock held.
3721 void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci, in xhci_free_device_endpoint_resources() argument
3734 xhci->num_active_eps -= num_dropped_eps; in xhci_free_device_endpoint_resources()
3736 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_free_device_endpoint_resources()
3740 xhci->num_active_eps); in xhci_free_device_endpoint_resources()
3766 struct xhci_hcd *xhci; in xhci_discover_or_reset_device() local
3776 xhci = hcd_to_xhci(hcd); in xhci_discover_or_reset_device()
3778 virt_dev = xhci->devs[slot_id]; in xhci_discover_or_reset_device()
3780 xhci_dbg(xhci, "The device to be reset with slot ID %u does " in xhci_discover_or_reset_device()
3797 xhci_dbg(xhci, "The device to be reset with slot ID %u does " in xhci_discover_or_reset_device()
3808 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); in xhci_discover_or_reset_device()
3815 xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id); in xhci_discover_or_reset_device()
3822 reset_device_cmd = xhci_alloc_command(xhci, true, GFP_NOIO); in xhci_discover_or_reset_device()
3824 xhci_dbg(xhci, "Couldn't allocate command structure.\n"); in xhci_discover_or_reset_device()
3829 spin_lock_irqsave(&xhci->lock, flags); in xhci_discover_or_reset_device()
3831 ret = xhci_queue_reset_device(xhci, reset_device_cmd, slot_id); in xhci_discover_or_reset_device()
3833 xhci_dbg(xhci, "FIXME: allocate a command ring segment\n"); in xhci_discover_or_reset_device()
3834 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_discover_or_reset_device()
3837 xhci_ring_cmd_db(xhci); in xhci_discover_or_reset_device()
3838 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_discover_or_reset_device()
3851 xhci_warn(xhci, "Timeout waiting for reset device command\n"); in xhci_discover_or_reset_device()
3856 xhci_dbg(xhci, "Can't reset device (slot ID %u) in %s state\n", in xhci_discover_or_reset_device()
3858 xhci_get_slot_state(xhci, virt_dev->out_ctx)); in xhci_discover_or_reset_device()
3859 xhci_dbg(xhci, "Not freeing device rings.\n"); in xhci_discover_or_reset_device()
3864 xhci_dbg(xhci, "Successful reset device command.\n"); in xhci_discover_or_reset_device()
3867 if (xhci_is_vendor_info_code(xhci, ret)) in xhci_discover_or_reset_device()
3869 xhci_warn(xhci, "Unknown completion code %u for " in xhci_discover_or_reset_device()
3876 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) { in xhci_discover_or_reset_device()
3877 spin_lock_irqsave(&xhci->lock, flags); in xhci_discover_or_reset_device()
3879 xhci_free_device_endpoint_resources(xhci, virt_dev, false); in xhci_discover_or_reset_device()
3880 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_discover_or_reset_device()
3888 xhci_warn(xhci, "WARN: endpoint 0x%02x has streams on device reset, freeing streams.\n", in xhci_discover_or_reset_device()
3890 xhci_free_stream_info(xhci, ep->stream_info); in xhci_discover_or_reset_device()
3896 xhci_debugfs_remove_endpoint(xhci, virt_dev, i); in xhci_discover_or_reset_device()
3897 xhci_free_endpoint_ring(xhci, virt_dev, i); in xhci_discover_or_reset_device()
3900 xhci_drop_ep_from_interval_table(xhci, in xhci_discover_or_reset_device()
3909 xhci_update_tt_active_eps(xhci, virt_dev, old_active_eps); in xhci_discover_or_reset_device()
3914 xhci_free_command(xhci, reset_device_cmd); in xhci_discover_or_reset_device()
3925 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_free_dev() local
3936 if (xhci->quirks & XHCI_RESET_ON_RESUME) in xhci_free_dev()
3946 virt_dev = xhci->devs[udev->slot_id]; in xhci_free_dev()
3947 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); in xhci_free_dev()
3956 xhci_disable_slot(xhci, udev->slot_id); in xhci_free_dev()
3958 spin_lock_irqsave(&xhci->lock, flags); in xhci_free_dev()
3959 xhci_free_virt_device(xhci, udev->slot_id); in xhci_free_dev()
3960 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_free_dev()
3964 int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id) in xhci_disable_slot() argument
3971 command = xhci_alloc_command(xhci, true, GFP_KERNEL); in xhci_disable_slot()
3975 xhci_debugfs_remove_slot(xhci, slot_id); in xhci_disable_slot()
3977 spin_lock_irqsave(&xhci->lock, flags); in xhci_disable_slot()
3979 state = readl(&xhci->op_regs->status); in xhci_disable_slot()
3980 if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) || in xhci_disable_slot()
3981 (xhci->xhc_state & XHCI_STATE_HALTED)) { in xhci_disable_slot()
3982 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_disable_slot()
3987 ret = xhci_queue_slot_control(xhci, command, TRB_DISABLE_SLOT, in xhci_disable_slot()
3990 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_disable_slot()
3994 xhci_ring_cmd_db(xhci); in xhci_disable_slot()
3995 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_disable_slot()
4000 xhci_warn(xhci, "Unsuccessful disable slot %u command, status %d\n", in xhci_disable_slot()
4003 xhci_free_command(xhci, command); in xhci_disable_slot()
4012 * Must be called with xhci->lock held.
4014 static int xhci_reserve_host_control_ep_resources(struct xhci_hcd *xhci) in xhci_reserve_host_control_ep_resources() argument
4016 if (xhci->num_active_eps + 1 > xhci->limit_active_eps) { in xhci_reserve_host_control_ep_resources()
4017 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_reserve_host_control_ep_resources()
4020 xhci->num_active_eps, xhci->limit_active_eps); in xhci_reserve_host_control_ep_resources()
4023 xhci->num_active_eps += 1; in xhci_reserve_host_control_ep_resources()
4024 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_reserve_host_control_ep_resources()
4026 xhci->num_active_eps); in xhci_reserve_host_control_ep_resources()
4037 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_alloc_dev() local
4044 command = xhci_alloc_command(xhci, true, GFP_KERNEL); in xhci_alloc_dev()
4048 spin_lock_irqsave(&xhci->lock, flags); in xhci_alloc_dev()
4049 ret = xhci_queue_slot_control(xhci, command, TRB_ENABLE_SLOT, 0); in xhci_alloc_dev()
4051 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_dev()
4052 xhci_dbg(xhci, "FIXME: allocate a command ring segment\n"); in xhci_alloc_dev()
4053 xhci_free_command(xhci, command); in xhci_alloc_dev()
4056 xhci_ring_cmd_db(xhci); in xhci_alloc_dev()
4057 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_dev()
4063 xhci_err(xhci, "Error while assigning device slot ID\n"); in xhci_alloc_dev()
4064 xhci_err(xhci, "Max number of devices this xHCI host supports is %u.\n", in xhci_alloc_dev()
4066 readl(&xhci->cap_regs->hcs_params1))); in xhci_alloc_dev()
4067 xhci_free_command(xhci, command); in xhci_alloc_dev()
4071 xhci_free_command(xhci, command); in xhci_alloc_dev()
4073 if ((xhci->quirks & XHCI_EP_LIMIT_QUIRK)) { in xhci_alloc_dev()
4074 spin_lock_irqsave(&xhci->lock, flags); in xhci_alloc_dev()
4075 ret = xhci_reserve_host_control_ep_resources(xhci); in xhci_alloc_dev()
4077 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_dev()
4078 xhci_warn(xhci, "Not enough host resources, " in xhci_alloc_dev()
4080 xhci->num_active_eps); in xhci_alloc_dev()
4083 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_alloc_dev()
4089 if (!xhci_alloc_virt_device(xhci, slot_id, udev, GFP_NOIO)) { in xhci_alloc_dev()
4090 xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n"); in xhci_alloc_dev()
4093 vdev = xhci->devs[slot_id]; in xhci_alloc_dev()
4094 slot_ctx = xhci_get_slot_ctx(xhci, vdev->out_ctx); in xhci_alloc_dev()
4099 xhci_debugfs_create_slot(xhci, slot_id); in xhci_alloc_dev()
4105 if (xhci->quirks & XHCI_RESET_ON_RESUME) in xhci_alloc_dev()
4113 xhci_disable_slot(xhci, udev->slot_id); in xhci_alloc_dev()
4114 xhci_free_virt_device(xhci, udev->slot_id); in xhci_alloc_dev()
4130 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_setup_device() local
4136 mutex_lock(&xhci->mutex); in xhci_setup_device()
4138 if (xhci->xhc_state) { /* dying, removing or halted */ in xhci_setup_device()
4144 xhci_dbg_trace(xhci, trace_xhci_dbg_address, in xhci_setup_device()
4150 virt_dev = xhci->devs[udev->slot_id]; in xhci_setup_device()
4158 xhci_warn(xhci, "Virt dev invalid for slot_id 0x%x!\n", in xhci_setup_device()
4163 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); in xhci_setup_device()
4169 xhci_dbg(xhci, "Slot already in default state\n"); in xhci_setup_device()
4174 command = xhci_alloc_command(xhci, true, GFP_KERNEL); in xhci_setup_device()
4182 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); in xhci_setup_device()
4185 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_setup_device()
4192 * virt_device realloaction after a resume with an xHCI power loss, in xhci_setup_device()
4196 xhci_setup_addressable_virt_dev(xhci, udev); in xhci_setup_device()
4199 xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev); in xhci_setup_device()
4203 trace_xhci_address_ctx(xhci, virt_dev->in_ctx, in xhci_setup_device()
4207 spin_lock_irqsave(&xhci->lock, flags); in xhci_setup_device()
4209 ret = xhci_queue_address_device(xhci, command, virt_dev->in_ctx->dma, in xhci_setup_device()
4212 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_setup_device()
4213 xhci_dbg_trace(xhci, trace_xhci_dbg_address, in xhci_setup_device()
4217 xhci_ring_cmd_db(xhci); in xhci_setup_device()
4218 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_setup_device()
4230 xhci_warn(xhci, "Timeout while waiting for setup device command\n"); in xhci_setup_device()
4235 xhci_err(xhci, "Setup ERROR: setup %s command for slot %d.\n", in xhci_setup_device()
4242 mutex_unlock(&xhci->mutex); in xhci_setup_device()
4243 ret = xhci_disable_slot(xhci, udev->slot_id); in xhci_setup_device()
4244 xhci_free_virt_device(xhci, udev->slot_id); in xhci_setup_device()
4247 xhci_setup_addressable_virt_dev(xhci, udev); in xhci_setup_device()
4258 xhci_dbg_trace(xhci, trace_xhci_dbg_address, in xhci_setup_device()
4262 xhci_err(xhci, in xhci_setup_device()
4265 trace_xhci_address_ctx(xhci, virt_dev->out_ctx, 1); in xhci_setup_device()
4271 temp_64 = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); in xhci_setup_device()
4272 xhci_dbg_trace(xhci, trace_xhci_dbg_address, in xhci_setup_device()
4274 xhci_dbg_trace(xhci, trace_xhci_dbg_address, in xhci_setup_device()
4277 &xhci->dcbaa->dev_context_ptrs[udev->slot_id], in xhci_setup_device()
4279 le64_to_cpu(xhci->dcbaa->dev_context_ptrs[udev->slot_id])); in xhci_setup_device()
4280 xhci_dbg_trace(xhci, trace_xhci_dbg_address, in xhci_setup_device()
4283 trace_xhci_address_ctx(xhci, virt_dev->in_ctx, in xhci_setup_device()
4289 trace_xhci_address_ctx(xhci, virt_dev->out_ctx, in xhci_setup_device()
4294 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); in xhci_setup_device()
4297 xhci_dbg_trace(xhci, trace_xhci_dbg_address, in xhci_setup_device()
4301 mutex_unlock(&xhci->mutex); in xhci_setup_device()
4337 static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci, in xhci_change_max_exit_latency() argument
4347 spin_lock_irqsave(&xhci->lock, flags); in xhci_change_max_exit_latency()
4349 virt_dev = xhci->devs[udev->slot_id]; in xhci_change_max_exit_latency()
4354 * hub_port_finish_reset() is done and xhci->devs[] are re-allocated in xhci_change_max_exit_latency()
4358 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_change_max_exit_latency()
4363 command = xhci->lpm_command; in xhci_change_max_exit_latency()
4366 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_change_max_exit_latency()
4367 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_change_max_exit_latency()
4372 xhci_slot_copy(xhci, command->in_ctx, virt_dev->out_ctx); in xhci_change_max_exit_latency()
4373 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_change_max_exit_latency()
4376 slot_ctx = xhci_get_slot_ctx(xhci, command->in_ctx); in xhci_change_max_exit_latency()
4381 xhci_dbg_trace(xhci, trace_xhci_dbg_context_change, in xhci_change_max_exit_latency()
4385 ret = xhci_configure_endpoint(xhci, udev, command, in xhci_change_max_exit_latency()
4389 spin_lock_irqsave(&xhci->lock, flags); in xhci_change_max_exit_latency()
4391 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_change_max_exit_latency()
4403 static int xhci_calculate_hird_besl(struct xhci_hcd *xhci, in xhci_calculate_hird_besl() argument
4410 u2del = HCS_U2_LATENCY(xhci->hcs_params3); in xhci_calculate_hird_besl()
4447 /* xHCI l1 is set in steps of 256us, xHCI 1.0 section 5.4.11.2 */ in xhci_calculate_usb2_hw_lpm_params()
4462 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_set_usb2_hardware_lpm() local
4471 if (xhci->quirks & XHCI_HW_LPM_DISABLE) in xhci_set_usb2_hardware_lpm()
4474 if (hcd->speed >= HCD_USB3 || !xhci->hw_lpm_support || in xhci_set_usb2_hardware_lpm()
4485 spin_lock_irqsave(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4487 ports = xhci->usb2_rhub.ports; in xhci_set_usb2_hardware_lpm()
4493 xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", in xhci_set_usb2_hardware_lpm()
4501 * systems. See XHCI_DEFAULT_BESL definition in xhci.h in xhci_set_usb2_hardware_lpm()
4511 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4513 /* USB 3.0 code dedicate one xhci->lpm_command->in_ctx in xhci_set_usb2_hardware_lpm()
4521 ret = xhci_change_max_exit_latency(xhci, udev, in xhci_set_usb2_hardware_lpm()
4527 spin_lock_irqsave(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4534 hird = xhci_calculate_hird_besl(xhci, udev); in xhci_set_usb2_hardware_lpm()
4551 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4553 xhci_change_max_exit_latency(xhci, udev, 0); in xhci_set_usb2_hardware_lpm()
4562 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_set_usb2_hardware_lpm()
4570 static int xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int port, in xhci_check_usb2_port_capability() argument
4576 for (i = 0; i < xhci->num_ext_caps; i++) { in xhci_check_usb2_port_capability()
4577 if (xhci->ext_caps[i] & capability) { in xhci_check_usb2_port_capability()
4579 port_offset = XHCI_EXT_PORT_OFF(xhci->ext_caps[i]) - 1; in xhci_check_usb2_port_capability()
4580 port_count = XHCI_EXT_PORT_COUNT(xhci->ext_caps[i]); in xhci_check_usb2_port_capability()
4591 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_update_device() local
4602 if (xhci->hw_lpm_support == 1 && in xhci_update_device()
4604 xhci, portnum, XHCI_HLC)) { in xhci_update_device()
4608 if (xhci_check_usb2_port_capability(xhci, portnum, in xhci_update_device()
4713 static u16 xhci_calculate_u1_timeout(struct xhci_hcd *xhci, in xhci_calculate_u1_timeout() argument
4727 if (xhci->quirks & XHCI_INTEL_HOST) in xhci_calculate_u1_timeout()
4777 static u16 xhci_calculate_u2_timeout(struct xhci_hcd *xhci, in xhci_calculate_u2_timeout() argument
4791 if (xhci->quirks & XHCI_INTEL_HOST) in xhci_calculate_u2_timeout()
4808 static u16 xhci_call_host_update_timeout_for_endpoint(struct xhci_hcd *xhci, in xhci_call_host_update_timeout_for_endpoint() argument
4815 return xhci_calculate_u1_timeout(xhci, udev, desc); in xhci_call_host_update_timeout_for_endpoint()
4817 return xhci_calculate_u2_timeout(xhci, udev, desc); in xhci_call_host_update_timeout_for_endpoint()
4822 static int xhci_update_timeout_for_endpoint(struct xhci_hcd *xhci, in xhci_update_timeout_for_endpoint() argument
4830 alt_timeout = xhci_call_host_update_timeout_for_endpoint(xhci, udev, in xhci_update_timeout_for_endpoint()
4847 static int xhci_update_timeout_for_interface(struct xhci_hcd *xhci, in xhci_update_timeout_for_interface() argument
4856 if (xhci_update_timeout_for_endpoint(xhci, udev, in xhci_update_timeout_for_interface()
4888 static int xhci_check_tier_policy(struct xhci_hcd *xhci, in xhci_check_tier_policy() argument
4892 if (xhci->quirks & XHCI_INTEL_HOST) in xhci_check_tier_policy()
4906 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_calculate_lpm_timeout() local
4922 if (xhci_check_tier_policy(xhci, udev, state) < 0) in xhci_calculate_lpm_timeout()
4928 if (xhci_update_timeout_for_endpoint(xhci, udev, &udev->ep0.desc, in xhci_calculate_lpm_timeout()
4962 if (xhci_update_timeout_for_interface(xhci, udev, in xhci_calculate_lpm_timeout()
5006 /* xHCI host controller max exit latency field is only 16 bits wide. */ in calculate_max_exit_latency()
5019 struct xhci_hcd *xhci; in xhci_enable_usb3_lpm_timeout() local
5025 xhci = hcd_to_xhci(hcd); in xhci_enable_usb3_lpm_timeout()
5030 if (!xhci || !(xhci->quirks & XHCI_LPM_SUPPORT) || in xhci_enable_usb3_lpm_timeout()
5031 !xhci->devs[udev->slot_id]) in xhci_enable_usb3_lpm_timeout()
5036 port = xhci->usb3_rhub.ports[udev->portnum - 1]; in xhci_enable_usb3_lpm_timeout()
5049 ret = xhci_change_max_exit_latency(xhci, udev, mel); in xhci_enable_usb3_lpm_timeout()
5058 struct xhci_hcd *xhci; in xhci_disable_usb3_lpm_timeout() local
5061 xhci = hcd_to_xhci(hcd); in xhci_disable_usb3_lpm_timeout()
5062 if (!xhci || !(xhci->quirks & XHCI_LPM_SUPPORT) || in xhci_disable_usb3_lpm_timeout()
5063 !xhci->devs[udev->slot_id]) in xhci_disable_usb3_lpm_timeout()
5067 return xhci_change_max_exit_latency(xhci, udev, mel); in xhci_disable_usb3_lpm_timeout()
5103 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_update_hub_device() local
5116 vdev = xhci->devs[hdev->slot_id]; in xhci_update_hub_device()
5118 xhci_warn(xhci, "Cannot update hub desc for unknown device.\n"); in xhci_update_hub_device()
5122 config_cmd = xhci_alloc_command_with_ctx(xhci, true, mem_flags); in xhci_update_hub_device()
5128 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", in xhci_update_hub_device()
5130 xhci_free_command(xhci, config_cmd); in xhci_update_hub_device()
5134 spin_lock_irqsave(&xhci->lock, flags); in xhci_update_hub_device()
5136 xhci_alloc_tt_info(xhci, vdev, hdev, tt, GFP_ATOMIC)) { in xhci_update_hub_device()
5137 xhci_dbg(xhci, "Could not allocate xHCI TT structure.\n"); in xhci_update_hub_device()
5138 xhci_free_command(xhci, config_cmd); in xhci_update_hub_device()
5139 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_update_hub_device()
5143 xhci_slot_copy(xhci, config_cmd->in_ctx, vdev->out_ctx); in xhci_update_hub_device()
5145 slot_ctx = xhci_get_slot_ctx(xhci, config_cmd->in_ctx); in xhci_update_hub_device()
5149 * but it may be already set to 1 when setup an xHCI virtual in xhci_update_hub_device()
5157 if (xhci->hci_version > 0x95) { in xhci_update_hub_device()
5158 xhci_dbg(xhci, "xHCI version %x needs hub " in xhci_update_hub_device()
5160 (unsigned int) xhci->hci_version); in xhci_update_hub_device()
5166 * xHCI 1.0: this field shall be 0 if the device is not a in xhci_update_hub_device()
5172 if (xhci->hci_version < 0x100 || hdev->speed == USB_SPEED_HIGH) in xhci_update_hub_device()
5176 xhci_dbg(xhci, "xHCI version %x doesn't need hub " in xhci_update_hub_device()
5178 (unsigned int) xhci->hci_version); in xhci_update_hub_device()
5181 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_update_hub_device()
5183 xhci_dbg(xhci, "Set up %s for hub device.\n", in xhci_update_hub_device()
5184 (xhci->hci_version > 0x95) ? in xhci_update_hub_device()
5190 if (xhci->hci_version > 0x95) in xhci_update_hub_device()
5191 ret = xhci_configure_endpoint(xhci, hdev, config_cmd, in xhci_update_hub_device()
5194 ret = xhci_configure_endpoint(xhci, hdev, config_cmd, in xhci_update_hub_device()
5197 xhci_free_command(xhci, config_cmd); in xhci_update_hub_device()
5204 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_get_frame() local
5206 return readl(&xhci->run_regs->microframe_index) >> 3; in xhci_get_frame()
5211 struct xhci_hcd *xhci; in xhci_gen_setup() local
5226 /* XHCI controllers don't stop the ep queue on short packets :| */ in xhci_gen_setup()
5229 xhci = hcd_to_xhci(hcd); in xhci_gen_setup()
5232 xhci->main_hcd = hcd; in xhci_gen_setup()
5233 xhci->usb2_rhub.hcd = hcd; in xhci_gen_setup()
5235 * The xHCI driver will register the USB 3.0 roothub. in xhci_gen_setup()
5240 * USB 2.0 roothub under xHCI has an integrated TT, in xhci_gen_setup()
5247 * Early xHCI 1.1 spec did not mention USB 3.1 capable hosts in xhci_gen_setup()
5250 * This was later clarified in xHCI 1.2. in xhci_gen_setup()
5255 if (xhci->usb3_rhub.min_rev == 0x1) in xhci_gen_setup()
5258 minor_rev = xhci->usb3_rhub.min_rev / 0x10; in xhci_gen_setup()
5272 xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n", in xhci_gen_setup()
5276 xhci->usb3_rhub.hcd = hcd; in xhci_gen_setup()
5277 /* xHCI private pointer was set in xhci_pci_probe for the second in xhci_gen_setup()
5283 mutex_init(&xhci->mutex); in xhci_gen_setup()
5284 xhci->cap_regs = hcd->regs; in xhci_gen_setup()
5285 xhci->op_regs = hcd->regs + in xhci_gen_setup()
5286 HC_LENGTH(readl(&xhci->cap_regs->hc_capbase)); in xhci_gen_setup()
5287 xhci->run_regs = hcd->regs + in xhci_gen_setup()
5288 (readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK); in xhci_gen_setup()
5290 xhci->hcs_params1 = readl(&xhci->cap_regs->hcs_params1); in xhci_gen_setup()
5291 xhci->hcs_params2 = readl(&xhci->cap_regs->hcs_params2); in xhci_gen_setup()
5292 xhci->hcs_params3 = readl(&xhci->cap_regs->hcs_params3); in xhci_gen_setup()
5293 xhci->hcc_params = readl(&xhci->cap_regs->hc_capbase); in xhci_gen_setup()
5294 xhci->hci_version = HC_VERSION(xhci->hcc_params); in xhci_gen_setup()
5295 xhci->hcc_params = readl(&xhci->cap_regs->hcc_params); in xhci_gen_setup()
5296 if (xhci->hci_version > 0x100) in xhci_gen_setup()
5297 xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2); in xhci_gen_setup()
5299 xhci->quirks |= quirks; in xhci_gen_setup()
5301 get_quirks(dev, xhci); in xhci_gen_setup()
5303 /* In xhci controllers which follow xhci 1.0 spec gives a spurious in xhci_gen_setup()
5307 if (xhci->hci_version > 0x96) in xhci_gen_setup()
5308 xhci->quirks |= XHCI_SPURIOUS_SUCCESS; in xhci_gen_setup()
5311 retval = xhci_halt(xhci); in xhci_gen_setup()
5315 xhci_zero_64b_regs(xhci); in xhci_gen_setup()
5317 xhci_dbg(xhci, "Resetting HCD\n"); in xhci_gen_setup()
5319 retval = xhci_reset(xhci, XHCI_RESET_LONG_USEC); in xhci_gen_setup()
5322 xhci_dbg(xhci, "Reset complete\n"); in xhci_gen_setup()
5325 * On some xHCI controllers (e.g. R-Car SoCs), the AC64 bit (bit 0) in xhci_gen_setup()
5328 * bit of xhci->hcc_params to call dma_set_coherent_mask(dev, in xhci_gen_setup()
5331 if (xhci->quirks & XHCI_NO_64BIT_SUPPORT) in xhci_gen_setup()
5332 xhci->hcc_params &= ~BIT(0); in xhci_gen_setup()
5336 if (HCC_64BIT_ADDR(xhci->hcc_params) && in xhci_gen_setup()
5338 xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n"); in xhci_gen_setup()
5348 xhci_dbg(xhci, "Enabling 32-bit DMA addresses.\n"); in xhci_gen_setup()
5352 xhci_dbg(xhci, "Calling HCD init\n"); in xhci_gen_setup()
5357 xhci_dbg(xhci, "Called HCD init\n"); in xhci_gen_setup()
5359 xhci_info(xhci, "hcc params 0x%08x hci version 0x%x quirks 0x%016llx\n", in xhci_gen_setup()
5360 xhci->hcc_params, xhci->hci_version, xhci->quirks); in xhci_gen_setup()
5369 struct xhci_hcd *xhci; in xhci_clear_tt_buffer_complete() local
5375 xhci = hcd_to_xhci(hcd); in xhci_clear_tt_buffer_complete()
5377 spin_lock_irqsave(&xhci->lock, flags); in xhci_clear_tt_buffer_complete()
5382 xhci->devs[slot_id]->eps[ep_index].ep_state &= ~EP_CLEARING_TT; in xhci_clear_tt_buffer_complete()
5383 xhci_ring_doorbell_for_active_rings(xhci, slot_id, ep_index); in xhci_clear_tt_buffer_complete()
5384 spin_unlock_irqrestore(&xhci->lock, flags); in xhci_clear_tt_buffer_complete()
5388 .description = "xhci-hcd",
5389 .product_desc = "xHCI Host Controller",