Lines Matching +full:ps +full:- +full:speed

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".
25 * buffer low/full speed data so the host collects it at high speed.
28 /*-------------------------------------------------------------------------*/
41 qtd->hw_buf[0] = cpu_to_hc32(ehci, (u32)addr); in qtd_fill()
42 qtd->hw_buf_hi[0] = cpu_to_hc32(ehci, (u32)(addr >> 32)); in qtd_fill()
43 count = 0x1000 - (buf & 0x0fff); /* rest of that page */ in qtd_fill()
50 /* per-qtd limit: from 16K to 20K (best alignment) */ in qtd_fill()
53 qtd->hw_buf[i] = cpu_to_hc32(ehci, (u32)addr); in qtd_fill()
54 qtd->hw_buf_hi[i] = cpu_to_hc32(ehci, in qtd_fill()
65 count -= (count % maxpacket); in qtd_fill()
67 qtd->hw_token = cpu_to_hc32(ehci, (count << 16) | token); in qtd_fill()
68 qtd->length = count; in qtd_fill()
73 /*-------------------------------------------------------------------------*/
78 struct ehci_qh_hw *hw = qh->hw; in qh_update()
81 WARN_ON(qh->qh_state != QH_STATE_IDLE); in qh_update()
83 hw->hw_qtd_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_update()
84 hw->hw_alt_next = EHCI_LIST_END(ehci); in qh_update()
88 * and set the pseudo-toggle in udev. Only usb_clear_halt() will in qh_update()
91 if (!(hw->hw_info1 & cpu_to_hc32(ehci, QH_TOGGLE_CTL))) { in qh_update()
94 is_out = qh->is_out; in qh_update()
95 epnum = (hc32_to_cpup(ehci, &hw->hw_info1) >> 8) & 0x0f; in qh_update()
96 if (unlikely(!usb_gettoggle(qh->ps.udev, epnum, is_out))) { in qh_update()
97 hw->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE); in qh_update()
98 usb_settoggle(qh->ps.udev, epnum, is_out, 1); in qh_update()
102 hw->hw_token &= cpu_to_hc32(ehci, QTD_TOGGLE | QTD_STS_PING); in qh_update()
106 * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
114 qtd = list_entry(qh->qtd_list.next, struct ehci_qtd, qtd_list); in qh_refresh()
123 if (qh->hw->hw_token & ACTIVE_BIT(ehci)) { in qh_refresh()
124 qh->hw->hw_qtd_next = qtd->hw_next; in qh_refresh()
125 if (qh->should_be_inactive) in qh_refresh()
130 qh->should_be_inactive = 0; in qh_refresh()
133 /*-------------------------------------------------------------------------*/
141 struct ehci_qh *qh = ep->hcpriv; in ehci_clear_tt_buffer_complete()
144 spin_lock_irqsave(&ehci->lock, flags); in ehci_clear_tt_buffer_complete()
145 qh->clearing_tt = 0; in ehci_clear_tt_buffer_complete()
146 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list) in ehci_clear_tt_buffer_complete()
147 && ehci->rh_state == EHCI_RH_RUNNING) in ehci_clear_tt_buffer_complete()
149 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_clear_tt_buffer_complete()
162 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { in ehci_clear_tt_buffer()
164 struct usb_device *tt = urb->dev->tt->hub; in ehci_clear_tt_buffer()
165 dev_dbg(&tt->dev, in ehci_clear_tt_buffer()
167 urb->dev->ttport, urb->dev->devnum, in ehci_clear_tt_buffer()
168 usb_pipeendpoint(urb->pipe), token); in ehci_clear_tt_buffer()
171 || urb->dev->tt->hub != in ehci_clear_tt_buffer()
172 ehci_to_hcd(ehci)->self.root_hub) { in ehci_clear_tt_buffer()
174 qh->clearing_tt = 1; in ehci_clear_tt_buffer()
177 /* REVISIT ARC-derived cores don't clear the root in ehci_clear_tt_buffer()
191 int status = -EINPROGRESS; in qtd_copy_status()
195 urb->actual_length += length - QTD_LENGTH (token); in qtd_copy_status()
198 if (unlikely(urb->unlinked)) in qtd_copy_status()
203 status = -EREMOTEIO; in qtd_copy_status()
209 status = -EOVERFLOW; in qtd_copy_status()
212 * EHCI Specification, Table 4-13. in qtd_copy_status()
216 status = -EPROTO; in qtd_copy_status()
217 /* CERR nonzero + halt --> stall */ in qtd_copy_status()
219 status = -EPIPE; in qtd_copy_status()
226 /* fs/ls interrupt xfer missed the complete-split */ in qtd_copy_status()
227 status = -EPROTO; in qtd_copy_status()
230 ? -ENOSR /* hc couldn't read data */ in qtd_copy_status()
231 : -ECOMM; /* hc couldn't write data */ in qtd_copy_status()
235 urb->dev->devpath, in qtd_copy_status()
236 usb_pipeendpoint(urb->pipe), in qtd_copy_status()
237 usb_pipein(urb->pipe) ? "in" : "out"); in qtd_copy_status()
238 status = -EPROTO; in qtd_copy_status()
240 status = -EPROTO; in qtd_copy_status()
250 if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { in ehci_urb_done()
251 /* ... update hc-wide periodic stats */ in ehci_urb_done()
252 ehci_to_hcd(ehci)->self.bandwidth_int_reqs--; in ehci_urb_done()
255 if (unlikely(urb->unlinked)) { in ehci_urb_done()
256 INCR(ehci->stats.unlink); in ehci_urb_done()
258 /* report non-error and short read status as zero */ in ehci_urb_done()
259 if (status == -EINPROGRESS || status == -EREMOTEIO) in ehci_urb_done()
261 INCR(ehci->stats.complete); in ehci_urb_done()
267 __func__, urb->dev->devpath, urb, in ehci_urb_done()
268 usb_pipeendpoint (urb->pipe), in ehci_urb_done()
269 usb_pipein (urb->pipe) ? "in" : "out", in ehci_urb_done()
271 urb->actual_length, urb->transfer_buffer_length); in ehci_urb_done()
282 * Chases up to qh->hw_current. Returns nonzero if the caller should
288 struct ehci_qtd *last, *end = qh->dummy; in qh_completions()
293 struct ehci_qh_hw *hw = qh->hw; in qh_completions()
301 * It's a bug for qh->qh_state to be anything other than in qh_completions()
305 state = qh->qh_state; in qh_completions()
306 qh->qh_state = QH_STATE_COMPLETING; in qh_completions()
311 last_status = -EINPROGRESS; in qh_completions()
312 qh->dequeue_during_giveback = 0; in qh_completions()
314 /* remove de-activated QTDs from front of queue. in qh_completions()
319 list_for_each_safe (entry, tmp, &qh->qtd_list) { in qh_completions()
325 urb = qtd->urb; in qh_completions()
329 if (likely (last->urb != urb)) { in qh_completions()
330 ehci_urb_done(ehci, last->urb, last_status); in qh_completions()
331 last_status = -EINPROGRESS; in qh_completions()
343 token = hc32_to_cpu(ehci, qtd->hw_token); in qh_completions()
345 /* always clean up qtds the hc de-activated */ in qh_completions()
349 /* Report Data Buffer Error: non-fatal but useful */ in qh_completions()
354 usb_endpoint_num(&urb->ep->desc), in qh_completions()
355 usb_endpoint_dir_in(&urb->ep->desc) ? "in" : "out", in qh_completions()
356 urb->transfer_buffer_length, in qh_completions()
370 ++qh->xacterrs < QH_XACTERR_MAX && in qh_completions()
371 !urb->unlinked) { in qh_completions()
374 qtd->length - QTD_LENGTH(token), qtd->length, qh->xacterrs); in qh_completions()
384 qtd->hw_token = cpu_to_hc32(ehci, in qh_completions()
387 hw->hw_token = cpu_to_hc32(ehci, in qh_completions()
392 qh->unlink_reason |= QH_UNLINK_HALTED; in qh_completions()
399 * most other single-qtd reads ... the queue stops if in qh_completions()
404 && !(qtd->hw_alt_next in qh_completions()
407 qh->unlink_reason |= QH_UNLINK_SHORT_READ; in qh_completions()
412 && ehci->rh_state >= EHCI_RH_RUNNING)) { in qh_completions()
420 if (ehci->rh_state < EHCI_RH_RUNNING) { in qh_completions()
421 last_status = -ESHUTDOWN; in qh_completions()
422 qh->unlink_reason |= QH_UNLINK_SHUTDOWN; in qh_completions()
428 else if (last_status == -EINPROGRESS && !urb->unlinked) in qh_completions()
440 qh->qtd_list.next == &qtd->qtd_list && in qh_completions()
441 (hw->hw_token & ACTIVE_BIT(ehci))) { in qh_completions()
442 token = hc32_to_cpu(ehci, hw->hw_token); in qh_completions()
443 hw->hw_token &= ~ACTIVE_BIT(ehci); in qh_completions()
444 qh->should_be_inactive = 1; in qh_completions()
461 if (last_status == -EINPROGRESS) { in qh_completions()
463 qtd->length, token); in qh_completions()
464 if (last_status == -EREMOTEIO in qh_completions()
465 && (qtd->hw_alt_next in qh_completions()
467 last_status = -EINPROGRESS; in qh_completions()
469 /* As part of low/full-speed endpoint-halt processing in qh_completions()
472 if (unlikely(last_status != -EINPROGRESS && in qh_completions()
473 last_status != -EREMOTEIO)) { in qh_completions()
478 * state (if you believe Figures 11-48 - 11-51 in qh_completions()
483 if (last_status != -EPIPE) in qh_completions()
492 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { in qh_completions()
493 last = list_entry (qtd->qtd_list.prev, in qh_completions()
495 last->hw_next = qtd->hw_next; in qh_completions()
499 list_del (&qtd->qtd_list); in qh_completions()
503 qh->xacterrs = 0; in qh_completions()
508 ehci_urb_done(ehci, last->urb, last_status); in qh_completions()
513 if (unlikely(qh->dequeue_during_giveback)) { in qh_completions()
522 qh->qh_state = state; in qh_completions()
530 * - HC reads first part of QH; in qh_completions()
531 * - CPU updates that first part and the token; in qh_completions()
532 * - HC reads rest of that QH, including token in qh_completions()
539 if (stopped != 0 || hw->hw_qtd_next == EHCI_LIST_END(ehci)) in qh_completions()
540 qh->unlink_reason |= QH_UNLINK_DUMMY_OVERLAY; in qh_completions()
543 return qh->unlink_reason; in qh_completions()
546 /*-------------------------------------------------------------------------*/
563 list_del (&qtd->qtd_list); in qtd_list_free()
592 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
593 qtd->urb = urb; in qh_urb_transaction()
599 len = urb->transfer_buffer_length; in qh_urb_transaction()
600 is_input = usb_pipein (urb->pipe); in qh_urb_transaction()
601 if (usb_pipecontrol (urb->pipe)) { in qh_urb_transaction()
603 qtd_fill(ehci, qtd, urb->setup_dma, in qh_urb_transaction()
613 qtd->urb = urb; in qh_urb_transaction()
614 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
615 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
625 i = urb->num_mapped_sgs; in qh_urb_transaction()
627 sg = urb->sg; in qh_urb_transaction()
630 /* urb->transfer_buffer_length may be smaller than the in qh_urb_transaction()
636 buf = urb->transfer_dma; in qh_urb_transaction()
644 maxpacket = usb_endpoint_maxp(&urb->ep->desc); in qh_urb_transaction()
656 this_sg_len -= this_qtd_len; in qh_urb_transaction()
657 len -= this_qtd_len; in qh_urb_transaction()
666 qtd->hw_alt_next = ehci->async->hw->hw_alt_next; in qh_urb_transaction()
669 if ((maxpacket & (this_qtd_len + (maxpacket - 1))) == 0) in qh_urb_transaction()
673 if (--i <= 0 || len <= 0) in qh_urb_transaction()
684 qtd->urb = urb; in qh_urb_transaction()
685 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
686 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
694 if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 in qh_urb_transaction()
695 || usb_pipecontrol (urb->pipe))) in qh_urb_transaction()
696 qtd->hw_alt_next = EHCI_LIST_END(ehci); in qh_urb_transaction()
703 if (likely (urb->transfer_buffer_length != 0)) { in qh_urb_transaction()
706 if (usb_pipecontrol (urb->pipe)) { in qh_urb_transaction()
708 token ^= (PID_CODE_IN << 8); /* "in" <--> "out" */ in qh_urb_transaction()
710 } else if (usb_pipeout(urb->pipe) in qh_urb_transaction()
711 && (urb->transfer_flags & URB_ZERO_PACKET) in qh_urb_transaction()
712 && !(urb->transfer_buffer_length % maxpacket)) { in qh_urb_transaction()
720 qtd->urb = urb; in qh_urb_transaction()
721 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
722 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
730 if (likely (!(urb->transfer_flags & URB_NO_INTERRUPT))) in qh_urb_transaction()
731 qtd->hw_token |= cpu_to_hc32(ehci, QTD_IOC); in qh_urb_transaction()
739 /*-------------------------------------------------------------------------*/
753 * just one microframe in the s-mask. For split interrupt transactions
754 * there are additional complications: c-mask, maybe FSTNs.
768 struct usb_tt *tt = urb->dev->tt; in qh_make()
777 info1 |= usb_pipeendpoint (urb->pipe) << 8; in qh_make()
778 info1 |= usb_pipedevice (urb->pipe) << 0; in qh_make()
780 is_input = usb_pipein (urb->pipe); in qh_make()
781 type = usb_pipetype (urb->pipe); in qh_make()
782 ep = usb_pipe_endpoint (urb->dev, urb->pipe); in qh_make()
783 maxp = usb_endpoint_maxp (&ep->desc); in qh_make()
784 mult = usb_endpoint_maxp_mult (&ep->desc); in qh_make()
795 * - allowing for high bandwidth, how many nsec/uframe are used? in qh_make()
796 * - split transactions need a second CSPLIT uframe; same question in qh_make()
797 * - splits also need a schedule gap (for full/low speed I/O) in qh_make()
798 * - qh has a polling interval in qh_make()
805 qh->ps.usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH, in qh_make()
807 qh->ps.phase = NO_FRAME; in qh_make()
809 if (urb->dev->speed == USB_SPEED_HIGH) { in qh_make()
810 qh->ps.c_usecs = 0; in qh_make()
811 qh->gap_uf = 0; in qh_make()
813 if (urb->interval > 1 && urb->interval < 8) { in qh_make()
818 urb->interval = 1; in qh_make()
819 } else if (urb->interval > ehci->periodic_size << 3) { in qh_make()
820 urb->interval = ehci->periodic_size << 3; in qh_make()
822 qh->ps.period = urb->interval >> 3; in qh_make()
826 1 << (urb->ep->desc.bInterval - 1)); in qh_make()
828 /* Allow urb->interval to override */ in qh_make()
829 qh->ps.bw_uperiod = min_t(unsigned, tmp, urb->interval); in qh_make()
830 qh->ps.bw_period = qh->ps.bw_uperiod >> 3; in qh_make()
835 qh->gap_uf = 1 + usb_calc_bus_time (urb->dev->speed, in qh_make()
840 qh->ps.c_usecs = qh->ps.usecs + HS_USECS(0); in qh_make()
841 qh->ps.usecs = HS_USECS(1); in qh_make()
843 qh->ps.usecs += HS_USECS(1); in qh_make()
844 qh->ps.c_usecs = HS_USECS(0); in qh_make()
847 think_time = tt ? tt->think_time : 0; in qh_make()
848 qh->ps.tt_usecs = NS_TO_US(think_time + in qh_make()
849 usb_calc_bus_time (urb->dev->speed, in qh_make()
851 if (urb->interval > ehci->periodic_size) in qh_make()
852 urb->interval = ehci->periodic_size; in qh_make()
853 qh->ps.period = urb->interval; in qh_make()
857 urb->ep->desc.bInterval); in qh_make()
860 /* Allow urb->interval to override */ in qh_make()
861 qh->ps.bw_period = min_t(unsigned, tmp, urb->interval); in qh_make()
862 qh->ps.bw_uperiod = qh->ps.bw_period << 3; in qh_make()
867 qh->ps.udev = urb->dev; in qh_make()
868 qh->ps.ep = urb->ep; in qh_make()
871 switch (urb->dev->speed) { in qh_make()
889 * port number in the queue head was 0..N-1 instead of 1..N. in qh_make()
892 info2 |= (urb->dev->ttport-1) << 23; in qh_make()
894 info2 |= urb->dev->ttport << 23; in qh_make()
899 if (tt && tt->hub != ehci_to_hcd(ehci)->self.root_hub) in qh_make()
900 info2 |= tt->hub->devnum << 16; in qh_make()
902 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */ in qh_make()
915 /* The USB spec says that high speed bulk endpoints in qh_make()
929 ehci_dbg(ehci, "bogus dev %p speed %d\n", urb->dev, in qh_make()
930 urb->dev->speed); in qh_make()
936 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets s-mask } */ in qh_make()
939 qh->qh_state = QH_STATE_IDLE; in qh_make()
940 hw = qh->hw; in qh_make()
941 hw->hw_info1 = cpu_to_hc32(ehci, info1); in qh_make()
942 hw->hw_info2 = cpu_to_hc32(ehci, info2); in qh_make()
943 qh->is_out = !is_input; in qh_make()
944 usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1); in qh_make()
948 /*-------------------------------------------------------------------------*/
952 if (ehci->async_count++) in enable_async()
956 ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_DISABLE_ASYNC); in enable_async()
965 if (--ehci->async_count) in disable_async()
969 WARN_ON(ehci->async->qh_next.qh || !list_empty(&ehci->async_unlink) || in disable_async()
970 !list_empty(&ehci->async_idle)); in disable_async()
980 __hc32 dma = QH_NEXT(ehci, qh->qh_dma); in qh_link_async()
983 /* Don't link a QH if there's a Clear-TT-Buffer pending */ in qh_link_async()
984 if (unlikely(qh->clearing_tt)) in qh_link_async()
987 WARN_ON(qh->qh_state != QH_STATE_IDLE); in qh_link_async()
993 head = ehci->async; in qh_link_async()
994 qh->qh_next = head->qh_next; in qh_link_async()
995 qh->hw->hw_next = head->hw->hw_next; in qh_link_async()
998 head->qh_next.qh = qh; in qh_link_async()
999 head->hw->hw_next = dma; in qh_link_async()
1001 qh->qh_state = QH_STATE_LINKED; in qh_link_async()
1002 qh->xacterrs = 0; in qh_link_async()
1003 qh->unlink_reason = 0; in qh_link_async()
1009 /*-------------------------------------------------------------------------*/
1030 /* can't sleep here, we have ehci->lock... */ in qh_append_tds()
1040 qtd = list_entry (qtd_list->next, struct ehci_qtd, in qh_append_tds()
1047 if (usb_pipedevice (urb->pipe) == 0) in qh_append_tds()
1048 qh->hw->hw_info1 &= ~qh_addr_mask; in qh_append_tds()
1064 token = qtd->hw_token; in qh_append_tds()
1065 qtd->hw_token = HALT_BIT(ehci); in qh_append_tds()
1067 dummy = qh->dummy; in qh_append_tds()
1069 dma = dummy->qtd_dma; in qh_append_tds()
1071 dummy->qtd_dma = dma; in qh_append_tds()
1073 list_del (&qtd->qtd_list); in qh_append_tds()
1074 list_add (&dummy->qtd_list, qtd_list); in qh_append_tds()
1075 list_splice_tail(qtd_list, &qh->qtd_list); in qh_append_tds()
1077 ehci_qtd_init(ehci, qtd, qtd->qtd_dma); in qh_append_tds()
1078 qh->dummy = qtd; in qh_append_tds()
1081 dma = qtd->qtd_dma; in qh_append_tds()
1082 qtd = list_entry (qh->qtd_list.prev, in qh_append_tds()
1084 qtd->hw_next = QTD_NEXT(ehci, dma); in qh_append_tds()
1088 dummy->hw_token = token; in qh_append_tds()
1090 urb->hcpriv = qh; in qh_append_tds()
1096 /*-------------------------------------------------------------------------*/
1110 epnum = urb->ep->desc.bEndpointAddress; in submit_async()
1115 qtd = list_entry(qtd_list->next, struct ehci_qtd, qtd_list); in submit_async()
1118 __func__, urb->dev->devpath, urb, in submit_async()
1120 urb->transfer_buffer_length, in submit_async()
1121 qtd, urb->ep->hcpriv); in submit_async()
1125 spin_lock_irqsave (&ehci->lock, flags); in submit_async()
1127 rc = -ESHUTDOWN; in submit_async()
1134 qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); in submit_async()
1137 rc = -ENOMEM; in submit_async()
1144 if (likely (qh->qh_state == QH_STATE_IDLE)) in submit_async()
1147 spin_unlock_irqrestore (&ehci->lock, flags); in submit_async()
1153 /*-------------------------------------------------------------------------*/
1162 * performed; TRUE - SETUP and FALSE - IN+STATUS
1185 return -1; in ehci_submit_single_step_set_feature()
1186 list_add_tail(&qtd->qtd_list, head); in ehci_submit_single_step_set_feature()
1187 qtd->urb = urb; in ehci_submit_single_step_set_feature()
1192 len = urb->transfer_buffer_length; in ehci_submit_single_step_set_feature()
1200 qtd_fill(ehci, qtd, urb->setup_dma, in ehci_submit_single_step_set_feature()
1212 token ^= QTD_TOGGLE; /*We need to start IN with DATA-1 Pid-sequence*/ in ehci_submit_single_step_set_feature()
1213 buf = urb->transfer_dma; in ehci_submit_single_step_set_feature()
1217 maxpacket = usb_endpoint_maxp(&urb->ep->desc); in ehci_submit_single_step_set_feature()
1225 qtd->hw_alt_next = EHCI_LIST_END(ehci); in ehci_submit_single_step_set_feature()
1228 token ^= (PID_CODE_IN << 8); /* "in" <--> "out" */ in ehci_submit_single_step_set_feature()
1235 qtd->urb = urb; in ehci_submit_single_step_set_feature()
1236 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in ehci_submit_single_step_set_feature()
1237 list_add_tail(&qtd->qtd_list, head); in ehci_submit_single_step_set_feature()
1248 return -1; in ehci_submit_single_step_set_feature()
1252 /*-------------------------------------------------------------------------*/
1259 qh->qh_state = QH_STATE_UNLINK_WAIT; in single_unlink_async()
1260 list_add_tail(&qh->unlink_node, &ehci->async_unlink); in single_unlink_async()
1263 prev = ehci->async; in single_unlink_async()
1264 while (prev->qh_next.qh != qh) in single_unlink_async()
1265 prev = prev->qh_next.qh; in single_unlink_async()
1267 prev->hw->hw_next = qh->hw->hw_next; in single_unlink_async()
1268 prev->qh_next = qh->qh_next; in single_unlink_async()
1269 if (ehci->qh_scan_next == qh) in single_unlink_async()
1270 ehci->qh_scan_next = qh->qh_next.qh; in single_unlink_async()
1276 if (unlikely(ehci->rh_state < EHCI_RH_RUNNING)) { in start_iaa_cycle()
1280 } else if (ehci->rh_state == EHCI_RH_RUNNING && in start_iaa_cycle()
1281 !ehci->iaa_in_progress) { in start_iaa_cycle()
1286 ehci_writel(ehci, ehci->command | CMD_IAAD, in start_iaa_cycle()
1287 &ehci->regs->command); in start_iaa_cycle()
1288 ehci_readl(ehci, &ehci->regs->command); in start_iaa_cycle()
1289 ehci->iaa_in_progress = true; in start_iaa_cycle()
1296 if (ehci->has_synopsys_hc_bug) in end_iaa_cycle()
1297 ehci_writel(ehci, (u32) ehci->async->qh_dma, in end_iaa_cycle()
1298 &ehci->regs->async_next); in end_iaa_cycle()
1301 ehci->iaa_in_progress = false; in end_iaa_cycle()
1313 if (list_empty(&ehci->async_unlink)) in end_unlink_async()
1315 qh = list_first_entry(&ehci->async_unlink, struct ehci_qh, in end_unlink_async()
1322 early_exit = ehci->async_unlinking; in end_unlink_async()
1325 if (ehci->rh_state < EHCI_RH_RUNNING) in end_unlink_async()
1326 list_splice_tail_init(&ehci->async_unlink, &ehci->async_idle); in end_unlink_async()
1330 * after the IAA interrupt occurs. In self-defense, always go in end_unlink_async()
1333 else if (qh->qh_state == QH_STATE_UNLINK) { in end_unlink_async()
1338 list_move_tail(&qh->unlink_node, &ehci->async_idle); in end_unlink_async()
1355 else if (qh->unlink_reason & (QH_UNLINK_HALTED | in end_unlink_async()
1360 else if ((qh->unlink_reason & QH_UNLINK_QUEUE_EMPTY) && in end_unlink_async()
1361 list_empty(&qh->qtd_list)) in end_unlink_async()
1365 else if (qh->hw->hw_token & cpu_to_hc32(ehci, QTD_STS_HALT)) in end_unlink_async()
1372 qh_current = qh->hw->hw_current; in end_unlink_async()
1373 qh_token = qh->hw->hw_token; in end_unlink_async()
1374 if (qh_current != ehci->old_current || in end_unlink_async()
1375 qh_token != ehci->old_token) { in end_unlink_async()
1376 ehci->old_current = qh_current; in end_unlink_async()
1377 ehci->old_token = qh_token; in end_unlink_async()
1383 qh->qh_state = QH_STATE_UNLINK; in end_unlink_async()
1386 ehci->old_current = ~0; /* Prepare for next QH */ in end_unlink_async()
1389 if (!list_empty(&ehci->async_unlink)) in end_unlink_async()
1400 ehci->async_unlinking = true; in end_unlink_async()
1401 while (!list_empty(&ehci->async_idle)) { in end_unlink_async()
1402 qh = list_first_entry(&ehci->async_idle, struct ehci_qh, in end_unlink_async()
1404 list_del(&qh->unlink_node); in end_unlink_async()
1406 qh->qh_state = QH_STATE_IDLE; in end_unlink_async()
1407 qh->qh_next.qh = NULL; in end_unlink_async()
1409 if (!list_empty(&qh->qtd_list)) in end_unlink_async()
1411 if (!list_empty(&qh->qtd_list) && in end_unlink_async()
1412 ehci->rh_state == EHCI_RH_RUNNING) in end_unlink_async()
1416 ehci->async_unlinking = false; in end_unlink_async()
1428 for (qh = ehci->async->qh_next.qh; qh; qh = qh->qh_next.qh) { in unlink_empty_async()
1429 if (list_empty(&qh->qtd_list) && in unlink_empty_async()
1430 qh->qh_state == QH_STATE_LINKED) { in unlink_empty_async()
1432 if (qh->unlink_cycle != ehci->async_unlink_cycle) in unlink_empty_async()
1438 if (list_empty(&ehci->async_unlink) && qh_to_unlink) { in unlink_empty_async()
1439 qh_to_unlink->unlink_reason |= QH_UNLINK_QUEUE_EMPTY; in unlink_empty_async()
1441 --count; in unlink_empty_async()
1447 ++ehci->async_unlink_cycle; in unlink_empty_async()
1458 while (ehci->async->qh_next.qh) { in unlink_empty_async_suspended()
1459 qh = ehci->async->qh_next.qh; in unlink_empty_async_suspended()
1460 WARN_ON(!list_empty(&qh->qtd_list)); in unlink_empty_async_suspended()
1468 /* caller must own ehci->lock */
1473 if (qh->qh_state != QH_STATE_LINKED) in start_unlink_async()
1480 /*-------------------------------------------------------------------------*/
1487 ehci->qh_scan_next = ehci->async->qh_next.qh; in scan_async()
1488 while (ehci->qh_scan_next) { in scan_async()
1489 qh = ehci->qh_scan_next; in scan_async()
1490 ehci->qh_scan_next = qh->qh_next.qh; in scan_async()
1493 if (!list_empty(&qh->qtd_list)) { in scan_async()
1498 * drops the lock. That's why ehci->qh_scan_next in scan_async()
1500 * gets unlinked then ehci->qh_scan_next is adjusted in scan_async()
1506 } else if (list_empty(&qh->qtd_list) in scan_async()
1507 && qh->qh_state == QH_STATE_LINKED) { in scan_async()
1508 qh->unlink_cycle = ehci->async_unlink_cycle; in scan_async()
1516 * as HCD schedule-scanning costs. Delay for any qh in scan_async()
1517 * we just scanned, there's a not-unusual case that it in scan_async()
1520 if (check_unlinks_later && ehci->rh_state == EHCI_RH_RUNNING && in scan_async()
1521 !(ehci->enabled_hrtimer_events & in scan_async()
1524 ++ehci->async_unlink_cycle; in scan_async()