Lines Matching +full:single +full:- +full:tt

1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2001-2004 by David Brownell
6 /* this file is part of ehci-hcd.c */
8 /*-------------------------------------------------------------------------*/
14 * entries describing USB transactions, max 16-20kB/entry (with 4kB-aligned
20 * an ongoing challenge. That's in "ehci-sched.c".
28 /*-------------------------------------------------------------------------*/
30 /* PID Codes that are used here, from EHCI specification, Table 3-16. */
45 qtd->hw_buf[0] = cpu_to_hc32(ehci, (u32)addr); in qtd_fill()
46 qtd->hw_buf_hi[0] = cpu_to_hc32(ehci, (u32)(addr >> 32)); in qtd_fill()
47 count = 0x1000 - (buf & 0x0fff); /* rest of that page */ in qtd_fill()
54 /* per-qtd limit: from 16K to 20K (best alignment) */ in qtd_fill()
57 qtd->hw_buf[i] = cpu_to_hc32(ehci, (u32)addr); in qtd_fill()
58 qtd->hw_buf_hi[i] = cpu_to_hc32(ehci, in qtd_fill()
69 count -= (count % maxpacket); in qtd_fill()
71 qtd->hw_token = cpu_to_hc32(ehci, (count << 16) | token); in qtd_fill()
72 qtd->length = count; in qtd_fill()
77 /*-------------------------------------------------------------------------*/
82 struct ehci_qh_hw *hw = qh->hw; in qh_update()
85 WARN_ON(qh->qh_state != QH_STATE_IDLE); in qh_update()
87 hw->hw_qtd_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_update()
88 hw->hw_alt_next = EHCI_LIST_END(ehci); in qh_update()
92 * and set the pseudo-toggle in udev. Only usb_clear_halt() will in qh_update()
95 if (!(hw->hw_info1 & cpu_to_hc32(ehci, QH_TOGGLE_CTL))) { in qh_update()
98 is_out = qh->is_out; in qh_update()
99 epnum = (hc32_to_cpup(ehci, &hw->hw_info1) >> 8) & 0x0f; in qh_update()
100 if (unlikely(!usb_gettoggle(qh->ps.udev, epnum, is_out))) { in qh_update()
101 hw->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE); in qh_update()
102 usb_settoggle(qh->ps.udev, epnum, is_out, 1); in qh_update()
106 hw->hw_token &= cpu_to_hc32(ehci, QTD_TOGGLE | QTD_STS_PING); in qh_update()
110 * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
118 qtd = list_entry(qh->qtd_list.next, struct ehci_qtd, qtd_list); in qh_refresh()
127 if (qh->hw->hw_token & ACTIVE_BIT(ehci)) { in qh_refresh()
128 qh->hw->hw_qtd_next = qtd->hw_next; in qh_refresh()
129 if (qh->should_be_inactive) in qh_refresh()
134 qh->should_be_inactive = 0; in qh_refresh()
137 /*-------------------------------------------------------------------------*/
145 struct ehci_qh *qh = ep->hcpriv; in ehci_clear_tt_buffer_complete()
148 spin_lock_irqsave(&ehci->lock, flags); in ehci_clear_tt_buffer_complete()
149 qh->clearing_tt = 0; in ehci_clear_tt_buffer_complete()
150 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list) in ehci_clear_tt_buffer_complete()
151 && ehci->rh_state == EHCI_RH_RUNNING) in ehci_clear_tt_buffer_complete()
153 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_clear_tt_buffer_complete()
161 * the TT buffer may be left in an indeterminate state. We in ehci_clear_tt_buffer()
162 * have to clear the TT buffer. in ehci_clear_tt_buffer()
166 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { in ehci_clear_tt_buffer()
168 struct usb_device *tt = urb->dev->tt->hub; in ehci_clear_tt_buffer() local
169 dev_dbg(&tt->dev, in ehci_clear_tt_buffer()
170 "clear tt buffer port %d, a%d ep%d t%08x\n", in ehci_clear_tt_buffer()
171 urb->dev->ttport, urb->dev->devnum, in ehci_clear_tt_buffer()
172 usb_pipeendpoint(urb->pipe), token); in ehci_clear_tt_buffer()
175 || urb->dev->tt->hub != in ehci_clear_tt_buffer()
176 ehci_to_hcd(ehci)->self.root_hub) { in ehci_clear_tt_buffer()
178 qh->clearing_tt = 1; in ehci_clear_tt_buffer()
181 /* REVISIT ARC-derived cores don't clear the root in ehci_clear_tt_buffer()
182 * hub TT buffer in this way... in ehci_clear_tt_buffer()
195 int status = -EINPROGRESS; in qtd_copy_status()
199 urb->actual_length += length - QTD_LENGTH (token); in qtd_copy_status()
202 if (unlikely(urb->unlinked)) in qtd_copy_status()
207 status = -EREMOTEIO; in qtd_copy_status()
213 status = -EOVERFLOW; in qtd_copy_status()
216 * EHCI Specification, Table 4-13. in qtd_copy_status()
220 status = -EPROTO; in qtd_copy_status()
221 /* CERR nonzero + halt --> stall */ in qtd_copy_status()
223 status = -EPIPE; in qtd_copy_status()
230 /* fs/ls interrupt xfer missed the complete-split */ in qtd_copy_status()
231 status = -EPROTO; in qtd_copy_status()
234 ? -ENOSR /* hc couldn't read data */ in qtd_copy_status()
235 : -ECOMM; /* hc couldn't write data */ in qtd_copy_status()
239 urb->dev->devpath, in qtd_copy_status()
240 usb_pipeendpoint(urb->pipe), in qtd_copy_status()
241 usb_pipein(urb->pipe) ? "in" : "out"); in qtd_copy_status()
242 status = -EPROTO; in qtd_copy_status()
244 status = -EPROTO; in qtd_copy_status()
254 if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { in ehci_urb_done()
255 /* ... update hc-wide periodic stats */ in ehci_urb_done()
256 ehci_to_hcd(ehci)->self.bandwidth_int_reqs--; in ehci_urb_done()
259 if (unlikely(urb->unlinked)) { in ehci_urb_done()
260 INCR(ehci->stats.unlink); in ehci_urb_done()
262 /* report non-error and short read status as zero */ in ehci_urb_done()
263 if (status == -EINPROGRESS || status == -EREMOTEIO) in ehci_urb_done()
265 INCR(ehci->stats.complete); in ehci_urb_done()
271 __func__, urb->dev->devpath, urb, in ehci_urb_done()
272 usb_pipeendpoint (urb->pipe), in ehci_urb_done()
273 usb_pipein (urb->pipe) ? "in" : "out", in ehci_urb_done()
275 urb->actual_length, urb->transfer_buffer_length); in ehci_urb_done()
286 * Chases up to qh->hw_current. Returns nonzero if the caller should
292 struct ehci_qtd *last, *end = qh->dummy; in qh_completions()
297 struct ehci_qh_hw *hw = qh->hw; in qh_completions()
305 * It's a bug for qh->qh_state to be anything other than in qh_completions()
309 state = qh->qh_state; in qh_completions()
310 qh->qh_state = QH_STATE_COMPLETING; in qh_completions()
315 last_status = -EINPROGRESS; in qh_completions()
316 qh->dequeue_during_giveback = 0; in qh_completions()
318 /* remove de-activated QTDs from front of queue. in qh_completions()
323 list_for_each_safe (entry, tmp, &qh->qtd_list) { in qh_completions()
329 urb = qtd->urb; in qh_completions()
333 if (likely (last->urb != urb)) { in qh_completions()
334 ehci_urb_done(ehci, last->urb, last_status); in qh_completions()
335 last_status = -EINPROGRESS; in qh_completions()
347 token = hc32_to_cpu(ehci, qtd->hw_token); in qh_completions()
349 /* always clean up qtds the hc de-activated */ in qh_completions()
353 /* Report Data Buffer Error: non-fatal but useful */ in qh_completions()
358 usb_endpoint_num(&urb->ep->desc), in qh_completions()
359 usb_endpoint_dir_in(&urb->ep->desc) ? "in" : "out", in qh_completions()
360 urb->transfer_buffer_length, in qh_completions()
374 ++qh->xacterrs < QH_XACTERR_MAX && in qh_completions()
375 !urb->unlinked) { in qh_completions()
378 qtd->length - QTD_LENGTH(token), qtd->length, qh->xacterrs); in qh_completions()
388 qtd->hw_token = cpu_to_hc32(ehci, in qh_completions()
391 hw->hw_token = cpu_to_hc32(ehci, in qh_completions()
396 qh->unlink_reason |= QH_UNLINK_HALTED; in qh_completions()
403 * most other single-qtd reads ... the queue stops if in qh_completions()
408 && !(qtd->hw_alt_next in qh_completions()
411 qh->unlink_reason |= QH_UNLINK_SHORT_READ; in qh_completions()
416 && ehci->rh_state >= EHCI_RH_RUNNING)) { in qh_completions()
424 if (ehci->rh_state < EHCI_RH_RUNNING) { in qh_completions()
425 last_status = -ESHUTDOWN; in qh_completions()
426 qh->unlink_reason |= QH_UNLINK_SHUTDOWN; in qh_completions()
432 else if (last_status == -EINPROGRESS && !urb->unlinked) in qh_completions()
444 qh->qtd_list.next == &qtd->qtd_list && in qh_completions()
445 (hw->hw_token & ACTIVE_BIT(ehci))) { in qh_completions()
446 token = hc32_to_cpu(ehci, hw->hw_token); in qh_completions()
447 hw->hw_token &= ~ACTIVE_BIT(ehci); in qh_completions()
448 qh->should_be_inactive = 1; in qh_completions()
451 * async transaction in the TT buffer. in qh_completions()
465 if (last_status == -EINPROGRESS) { in qh_completions()
467 qtd->length, token); in qh_completions()
468 if (last_status == -EREMOTEIO in qh_completions()
469 && (qtd->hw_alt_next in qh_completions()
471 last_status = -EINPROGRESS; in qh_completions()
473 /* As part of low/full-speed endpoint-halt processing in qh_completions()
474 * we must clear the TT buffer (11.17.5). in qh_completions()
476 if (unlikely(last_status != -EINPROGRESS && in qh_completions()
477 last_status != -EREMOTEIO)) { in qh_completions()
478 /* The TT's in some hubs malfunction when they in qh_completions()
481 * STALL can't leave the TT buffer in a busy in qh_completions()
482 * state (if you believe Figures 11-48 - 11-51 in qh_completions()
483 * in the USB 2.0 spec), we won't clear the TT in qh_completions()
487 if (last_status != -EPIPE) in qh_completions()
496 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { in qh_completions()
497 last = list_entry (qtd->qtd_list.prev, in qh_completions()
499 last->hw_next = qtd->hw_next; in qh_completions()
503 list_del (&qtd->qtd_list); in qh_completions()
507 qh->xacterrs = 0; in qh_completions()
512 ehci_urb_done(ehci, last->urb, last_status); in qh_completions()
517 if (unlikely(qh->dequeue_during_giveback)) { in qh_completions()
526 qh->qh_state = state; in qh_completions()
534 * - HC reads first part of QH; in qh_completions()
535 * - CPU updates that first part and the token; in qh_completions()
536 * - HC reads rest of that QH, including token in qh_completions()
543 if (stopped != 0 || hw->hw_qtd_next == EHCI_LIST_END(ehci)) in qh_completions()
544 qh->unlink_reason |= QH_UNLINK_DUMMY_OVERLAY; in qh_completions()
547 return qh->unlink_reason; in qh_completions()
550 /*-------------------------------------------------------------------------*/
567 list_del (&qtd->qtd_list); in qtd_list_free()
596 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
597 qtd->urb = urb; in qh_urb_transaction()
603 len = urb->transfer_buffer_length; in qh_urb_transaction()
604 is_input = usb_pipein (urb->pipe); in qh_urb_transaction()
605 if (usb_pipecontrol (urb->pipe)) { in qh_urb_transaction()
607 qtd_fill(ehci, qtd, urb->setup_dma, in qh_urb_transaction()
617 qtd->urb = urb; in qh_urb_transaction()
618 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
619 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
629 i = urb->num_mapped_sgs; in qh_urb_transaction()
631 sg = urb->sg; in qh_urb_transaction()
634 /* urb->transfer_buffer_length may be smaller than the in qh_urb_transaction()
640 buf = urb->transfer_dma; in qh_urb_transaction()
648 maxpacket = usb_endpoint_maxp(&urb->ep->desc); in qh_urb_transaction()
660 this_sg_len -= this_qtd_len; in qh_urb_transaction()
661 len -= this_qtd_len; in qh_urb_transaction()
670 qtd->hw_alt_next = ehci->async->hw->hw_alt_next; in qh_urb_transaction()
673 if ((maxpacket & (this_qtd_len + (maxpacket - 1))) == 0) in qh_urb_transaction()
677 if (--i <= 0 || len <= 0) in qh_urb_transaction()
688 qtd->urb = urb; in qh_urb_transaction()
689 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
690 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
698 if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 in qh_urb_transaction()
699 || usb_pipecontrol (urb->pipe))) in qh_urb_transaction()
700 qtd->hw_alt_next = EHCI_LIST_END(ehci); in qh_urb_transaction()
707 if (likely (urb->transfer_buffer_length != 0)) { in qh_urb_transaction()
710 if (usb_pipecontrol (urb->pipe)) { in qh_urb_transaction()
712 token ^= 0x0100; /* "in" <--> "out" */ in qh_urb_transaction()
714 } else if (usb_pipeout(urb->pipe) in qh_urb_transaction()
715 && (urb->transfer_flags & URB_ZERO_PACKET) in qh_urb_transaction()
716 && !(urb->transfer_buffer_length % maxpacket)) { in qh_urb_transaction()
724 qtd->urb = urb; in qh_urb_transaction()
725 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
726 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
734 if (likely (!(urb->transfer_flags & URB_NO_INTERRUPT))) in qh_urb_transaction()
735 qtd->hw_token |= cpu_to_hc32(ehci, QTD_IOC); in qh_urb_transaction()
743 /*-------------------------------------------------------------------------*/
757 * just one microframe in the s-mask. For split interrupt transactions
758 * there are additional complications: c-mask, maybe FSTNs.
772 struct usb_tt *tt = urb->dev->tt; in qh_make() local
781 info1 |= usb_pipeendpoint (urb->pipe) << 8; in qh_make()
782 info1 |= usb_pipedevice (urb->pipe) << 0; in qh_make()
784 is_input = usb_pipein (urb->pipe); in qh_make()
785 type = usb_pipetype (urb->pipe); in qh_make()
786 ep = usb_pipe_endpoint (urb->dev, urb->pipe); in qh_make()
787 maxp = usb_endpoint_maxp (&ep->desc); in qh_make()
788 mult = usb_endpoint_maxp_mult (&ep->desc); in qh_make()
799 * - allowing for high bandwidth, how many nsec/uframe are used? in qh_make()
800 * - split transactions need a second CSPLIT uframe; same question in qh_make()
801 * - splits also need a schedule gap (for full/low speed I/O) in qh_make()
802 * - qh has a polling interval in qh_make()
804 * For control/bulk requests, the HC or TT handles these. in qh_make()
809 qh->ps.usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH, in qh_make()
811 qh->ps.phase = NO_FRAME; in qh_make()
813 if (urb->dev->speed == USB_SPEED_HIGH) { in qh_make()
814 qh->ps.c_usecs = 0; in qh_make()
815 qh->gap_uf = 0; in qh_make()
817 if (urb->interval > 1 && urb->interval < 8) { in qh_make()
822 urb->interval = 1; in qh_make()
823 } else if (urb->interval > ehci->periodic_size << 3) { in qh_make()
824 urb->interval = ehci->periodic_size << 3; in qh_make()
826 qh->ps.period = urb->interval >> 3; in qh_make()
830 1 << (urb->ep->desc.bInterval - 1)); in qh_make()
832 /* Allow urb->interval to override */ in qh_make()
833 qh->ps.bw_uperiod = min_t(unsigned, tmp, urb->interval); in qh_make()
834 qh->ps.bw_period = qh->ps.bw_uperiod >> 3; in qh_make()
839 qh->gap_uf = 1 + usb_calc_bus_time (urb->dev->speed, in qh_make()
844 qh->ps.c_usecs = qh->ps.usecs + HS_USECS(0); in qh_make()
845 qh->ps.usecs = HS_USECS(1); in qh_make()
847 qh->ps.usecs += HS_USECS(1); in qh_make()
848 qh->ps.c_usecs = HS_USECS(0); in qh_make()
851 think_time = tt ? tt->think_time : 0; in qh_make()
852 qh->ps.tt_usecs = NS_TO_US(think_time + in qh_make()
853 usb_calc_bus_time (urb->dev->speed, in qh_make()
855 if (urb->interval > ehci->periodic_size) in qh_make()
856 urb->interval = ehci->periodic_size; in qh_make()
857 qh->ps.period = urb->interval; in qh_make()
861 urb->ep->desc.bInterval); in qh_make()
864 /* Allow urb->interval to override */ in qh_make()
865 qh->ps.bw_period = min_t(unsigned, tmp, urb->interval); in qh_make()
866 qh->ps.bw_uperiod = qh->ps.bw_period << 3; in qh_make()
870 /* support for tt scheduling, and access to toggles */ in qh_make()
871 qh->ps.udev = urb->dev; in qh_make()
872 qh->ps.ep = urb->ep; in qh_make()
874 /* using TT? */ in qh_make()
875 switch (urb->dev->speed) { in qh_make()
885 info1 |= QH_CONTROL_EP; /* for TT */ in qh_make()
893 * port number in the queue head was 0..N-1 instead of 1..N. in qh_make()
896 info2 |= (urb->dev->ttport-1) << 23; in qh_make()
898 info2 |= urb->dev->ttport << 23; in qh_make()
900 /* set the address of the TT; for TDI's integrated in qh_make()
901 * root hub tt, leave it zeroed. in qh_make()
903 if (tt && tt->hub != ehci_to_hcd(ehci)->self.root_hub) in qh_make()
904 info2 |= tt->hub->devnum << 16; in qh_make()
906 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */ in qh_make()
910 case USB_SPEED_HIGH: /* no TT involved */ in qh_make()
933 ehci_dbg(ehci, "bogus dev %p speed %d\n", urb->dev, in qh_make()
934 urb->dev->speed); in qh_make()
940 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets s-mask } */ in qh_make()
943 qh->qh_state = QH_STATE_IDLE; in qh_make()
944 hw = qh->hw; in qh_make()
945 hw->hw_info1 = cpu_to_hc32(ehci, info1); in qh_make()
946 hw->hw_info2 = cpu_to_hc32(ehci, info2); in qh_make()
947 qh->is_out = !is_input; in qh_make()
948 usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1); in qh_make()
952 /*-------------------------------------------------------------------------*/
956 if (ehci->async_count++) in enable_async()
960 ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_DISABLE_ASYNC); in enable_async()
969 if (--ehci->async_count) in disable_async()
973 WARN_ON(ehci->async->qh_next.qh || !list_empty(&ehci->async_unlink) || in disable_async()
974 !list_empty(&ehci->async_idle)); in disable_async()
984 __hc32 dma = QH_NEXT(ehci, qh->qh_dma); in qh_link_async()
987 /* Don't link a QH if there's a Clear-TT-Buffer pending */ in qh_link_async()
988 if (unlikely(qh->clearing_tt)) in qh_link_async()
991 WARN_ON(qh->qh_state != QH_STATE_IDLE); in qh_link_async()
997 head = ehci->async; in qh_link_async()
998 qh->qh_next = head->qh_next; in qh_link_async()
999 qh->hw->hw_next = head->hw->hw_next; in qh_link_async()
1002 head->qh_next.qh = qh; in qh_link_async()
1003 head->hw->hw_next = dma; in qh_link_async()
1005 qh->qh_state = QH_STATE_LINKED; in qh_link_async()
1006 qh->xacterrs = 0; in qh_link_async()
1007 qh->unlink_reason = 0; in qh_link_async()
1013 /*-------------------------------------------------------------------------*/
1034 /* can't sleep here, we have ehci->lock... */ in qh_append_tds()
1044 qtd = list_entry (qtd_list->next, struct ehci_qtd, in qh_append_tds()
1051 if (usb_pipedevice (urb->pipe) == 0) in qh_append_tds()
1052 qh->hw->hw_info1 &= ~qh_addr_mask; in qh_append_tds()
1068 token = qtd->hw_token; in qh_append_tds()
1069 qtd->hw_token = HALT_BIT(ehci); in qh_append_tds()
1071 dummy = qh->dummy; in qh_append_tds()
1073 dma = dummy->qtd_dma; in qh_append_tds()
1075 dummy->qtd_dma = dma; in qh_append_tds()
1077 list_del (&qtd->qtd_list); in qh_append_tds()
1078 list_add (&dummy->qtd_list, qtd_list); in qh_append_tds()
1079 list_splice_tail(qtd_list, &qh->qtd_list); in qh_append_tds()
1081 ehci_qtd_init(ehci, qtd, qtd->qtd_dma); in qh_append_tds()
1082 qh->dummy = qtd; in qh_append_tds()
1085 dma = qtd->qtd_dma; in qh_append_tds()
1086 qtd = list_entry (qh->qtd_list.prev, in qh_append_tds()
1088 qtd->hw_next = QTD_NEXT(ehci, dma); in qh_append_tds()
1092 dummy->hw_token = token; in qh_append_tds()
1094 urb->hcpriv = qh; in qh_append_tds()
1100 /*-------------------------------------------------------------------------*/
1114 epnum = urb->ep->desc.bEndpointAddress; in submit_async()
1119 qtd = list_entry(qtd_list->next, struct ehci_qtd, qtd_list); in submit_async()
1122 __func__, urb->dev->devpath, urb, in submit_async()
1124 urb->transfer_buffer_length, in submit_async()
1125 qtd, urb->ep->hcpriv); in submit_async()
1129 spin_lock_irqsave (&ehci->lock, flags); in submit_async()
1131 rc = -ESHUTDOWN; in submit_async()
1138 qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); in submit_async()
1141 rc = -ENOMEM; in submit_async()
1146 * the HC and TT handle it when the TT has a buffer ready. in submit_async()
1148 if (likely (qh->qh_state == QH_STATE_IDLE)) in submit_async()
1151 spin_unlock_irqrestore (&ehci->lock, flags); in submit_async()
1157 /*-------------------------------------------------------------------------*/
1166 * performed; TRUE - SETUP and FALSE - IN+STATUS
1189 return -1; in ehci_submit_single_step_set_feature()
1190 list_add_tail(&qtd->qtd_list, head); in ehci_submit_single_step_set_feature()
1191 qtd->urb = urb; in ehci_submit_single_step_set_feature()
1196 len = urb->transfer_buffer_length; in ehci_submit_single_step_set_feature()
1204 qtd_fill(ehci, qtd, urb->setup_dma, in ehci_submit_single_step_set_feature()
1216 token ^= QTD_TOGGLE; /*We need to start IN with DATA-1 Pid-sequence*/ in ehci_submit_single_step_set_feature()
1217 buf = urb->transfer_dma; in ehci_submit_single_step_set_feature()
1221 maxpacket = usb_endpoint_maxp(&urb->ep->desc); in ehci_submit_single_step_set_feature()
1229 qtd->hw_alt_next = EHCI_LIST_END(ehci); in ehci_submit_single_step_set_feature()
1232 token ^= 0x0100; /* "in" <--> "out" */ in ehci_submit_single_step_set_feature()
1239 qtd->urb = urb; in ehci_submit_single_step_set_feature()
1240 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in ehci_submit_single_step_set_feature()
1241 list_add_tail(&qtd->qtd_list, head); in ehci_submit_single_step_set_feature()
1252 return -1; in ehci_submit_single_step_set_feature()
1256 /*-------------------------------------------------------------------------*/
1263 qh->qh_state = QH_STATE_UNLINK_WAIT; in single_unlink_async()
1264 list_add_tail(&qh->unlink_node, &ehci->async_unlink); in single_unlink_async()
1267 prev = ehci->async; in single_unlink_async()
1268 while (prev->qh_next.qh != qh) in single_unlink_async()
1269 prev = prev->qh_next.qh; in single_unlink_async()
1271 prev->hw->hw_next = qh->hw->hw_next; in single_unlink_async()
1272 prev->qh_next = qh->qh_next; in single_unlink_async()
1273 if (ehci->qh_scan_next == qh) in single_unlink_async()
1274 ehci->qh_scan_next = qh->qh_next.qh; in single_unlink_async()
1280 if (unlikely(ehci->rh_state < EHCI_RH_RUNNING)) { in start_iaa_cycle()
1284 } else if (ehci->rh_state == EHCI_RH_RUNNING && in start_iaa_cycle()
1285 !ehci->iaa_in_progress) { in start_iaa_cycle()
1290 ehci_writel(ehci, ehci->command | CMD_IAAD, in start_iaa_cycle()
1291 &ehci->regs->command); in start_iaa_cycle()
1292 ehci_readl(ehci, &ehci->regs->command); in start_iaa_cycle()
1293 ehci->iaa_in_progress = true; in start_iaa_cycle()
1300 if (ehci->has_synopsys_hc_bug) in end_iaa_cycle()
1301 ehci_writel(ehci, (u32) ehci->async->qh_dma, in end_iaa_cycle()
1302 &ehci->regs->async_next); in end_iaa_cycle()
1305 ehci->iaa_in_progress = false; in end_iaa_cycle()
1317 if (list_empty(&ehci->async_unlink)) in end_unlink_async()
1319 qh = list_first_entry(&ehci->async_unlink, struct ehci_qh, in end_unlink_async()
1326 early_exit = ehci->async_unlinking; in end_unlink_async()
1329 if (ehci->rh_state < EHCI_RH_RUNNING) in end_unlink_async()
1330 list_splice_tail_init(&ehci->async_unlink, &ehci->async_idle); in end_unlink_async()
1334 * after the IAA interrupt occurs. In self-defense, always go in end_unlink_async()
1337 else if (qh->qh_state == QH_STATE_UNLINK) { in end_unlink_async()
1342 list_move_tail(&qh->unlink_node, &ehci->async_idle); in end_unlink_async()
1359 else if (qh->unlink_reason & (QH_UNLINK_HALTED | in end_unlink_async()
1364 else if ((qh->unlink_reason & QH_UNLINK_QUEUE_EMPTY) && in end_unlink_async()
1365 list_empty(&qh->qtd_list)) in end_unlink_async()
1369 else if (qh->hw->hw_token & cpu_to_hc32(ehci, QTD_STS_HALT)) in end_unlink_async()
1376 qh_current = qh->hw->hw_current; in end_unlink_async()
1377 qh_token = qh->hw->hw_token; in end_unlink_async()
1378 if (qh_current != ehci->old_current || in end_unlink_async()
1379 qh_token != ehci->old_token) { in end_unlink_async()
1380 ehci->old_current = qh_current; in end_unlink_async()
1381 ehci->old_token = qh_token; in end_unlink_async()
1387 qh->qh_state = QH_STATE_UNLINK; in end_unlink_async()
1390 ehci->old_current = ~0; /* Prepare for next QH */ in end_unlink_async()
1393 if (!list_empty(&ehci->async_unlink)) in end_unlink_async()
1404 ehci->async_unlinking = true; in end_unlink_async()
1405 while (!list_empty(&ehci->async_idle)) { in end_unlink_async()
1406 qh = list_first_entry(&ehci->async_idle, struct ehci_qh, in end_unlink_async()
1408 list_del(&qh->unlink_node); in end_unlink_async()
1410 qh->qh_state = QH_STATE_IDLE; in end_unlink_async()
1411 qh->qh_next.qh = NULL; in end_unlink_async()
1413 if (!list_empty(&qh->qtd_list)) in end_unlink_async()
1415 if (!list_empty(&qh->qtd_list) && in end_unlink_async()
1416 ehci->rh_state == EHCI_RH_RUNNING) in end_unlink_async()
1420 ehci->async_unlinking = false; in end_unlink_async()
1432 for (qh = ehci->async->qh_next.qh; qh; qh = qh->qh_next.qh) { in unlink_empty_async()
1433 if (list_empty(&qh->qtd_list) && in unlink_empty_async()
1434 qh->qh_state == QH_STATE_LINKED) { in unlink_empty_async()
1436 if (qh->unlink_cycle != ehci->async_unlink_cycle) in unlink_empty_async()
1442 if (list_empty(&ehci->async_unlink) && qh_to_unlink) { in unlink_empty_async()
1443 qh_to_unlink->unlink_reason |= QH_UNLINK_QUEUE_EMPTY; in unlink_empty_async()
1445 --count; in unlink_empty_async()
1451 ++ehci->async_unlink_cycle; in unlink_empty_async()
1462 while (ehci->async->qh_next.qh) { in unlink_empty_async_suspended()
1463 qh = ehci->async->qh_next.qh; in unlink_empty_async_suspended()
1464 WARN_ON(!list_empty(&qh->qtd_list)); in unlink_empty_async_suspended()
1472 /* caller must own ehci->lock */
1477 if (qh->qh_state != QH_STATE_LINKED) in start_unlink_async()
1484 /*-------------------------------------------------------------------------*/
1491 ehci->qh_scan_next = ehci->async->qh_next.qh; in scan_async()
1492 while (ehci->qh_scan_next) { in scan_async()
1493 qh = ehci->qh_scan_next; in scan_async()
1494 ehci->qh_scan_next = qh->qh_next.qh; in scan_async()
1497 if (!list_empty(&qh->qtd_list)) { in scan_async()
1502 * drops the lock. That's why ehci->qh_scan_next in scan_async()
1504 * gets unlinked then ehci->qh_scan_next is adjusted in scan_async()
1510 } else if (list_empty(&qh->qtd_list) in scan_async()
1511 && qh->qh_state == QH_STATE_LINKED) { in scan_async()
1512 qh->unlink_cycle = ehci->async_unlink_cycle; in scan_async()
1520 * as HCD schedule-scanning costs. Delay for any qh in scan_async()
1521 * we just scanned, there's a not-unusual case that it in scan_async()
1524 if (check_unlinks_later && ehci->rh_state == EHCI_RH_RUNNING && in scan_async()
1525 !(ehci->enabled_hrtimer_events & in scan_async()
1528 ++ehci->async_unlink_cycle; in scan_async()