• Home
  • Raw
  • Download

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 /*-------------------------------------------------------------------------*/
30 /* PID Codes that are used here, from EHCI specification, Table 3-16. */
44 qtd->hw_buf[0] = cpu_to_hc32(ehci, (u32)addr); in qtd_fill()
45 qtd->hw_buf_hi[0] = cpu_to_hc32(ehci, (u32)(addr >> 32)); in qtd_fill()
46 count = 0x1000 - (buf & 0x0fff); /* rest of that page */ in qtd_fill()
53 /* per-qtd limit: from 16K to 20K (best alignment) */ in qtd_fill()
56 qtd->hw_buf[i] = cpu_to_hc32(ehci, (u32)addr); in qtd_fill()
57 qtd->hw_buf_hi[i] = cpu_to_hc32(ehci, in qtd_fill()
68 count -= (count % maxpacket); in qtd_fill()
70 qtd->hw_token = cpu_to_hc32(ehci, (count << 16) | token); in qtd_fill()
71 qtd->length = count; in qtd_fill()
76 /*-------------------------------------------------------------------------*/
81 struct ehci_qh_hw *hw = qh->hw; in qh_update()
84 WARN_ON(qh->qh_state != QH_STATE_IDLE); in qh_update()
86 hw->hw_qtd_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_update()
87 hw->hw_alt_next = EHCI_LIST_END(ehci); in qh_update()
91 * and set the pseudo-toggle in udev. Only usb_clear_halt() will in qh_update()
94 if (!(hw->hw_info1 & cpu_to_hc32(ehci, QH_TOGGLE_CTL))) { in qh_update()
97 is_out = qh->is_out; in qh_update()
98 epnum = (hc32_to_cpup(ehci, &hw->hw_info1) >> 8) & 0x0f; in qh_update()
99 if (unlikely(!usb_gettoggle(qh->ps.udev, epnum, is_out))) { in qh_update()
100 hw->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE); in qh_update()
101 usb_settoggle(qh->ps.udev, epnum, is_out, 1); in qh_update()
105 hw->hw_token &= cpu_to_hc32(ehci, QTD_TOGGLE | QTD_STS_PING); in qh_update()
109 * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
117 qtd = list_entry(qh->qtd_list.next, struct ehci_qtd, qtd_list); in qh_refresh()
126 if (qh->hw->hw_token & ACTIVE_BIT(ehci)) { in qh_refresh()
127 qh->hw->hw_qtd_next = qtd->hw_next; in qh_refresh()
128 if (qh->should_be_inactive) in qh_refresh()
133 qh->should_be_inactive = 0; in qh_refresh()
136 /*-------------------------------------------------------------------------*/
144 struct ehci_qh *qh = ep->hcpriv; in ehci_clear_tt_buffer_complete()
147 spin_lock_irqsave(&ehci->lock, flags); in ehci_clear_tt_buffer_complete()
148 qh->clearing_tt = 0; in ehci_clear_tt_buffer_complete()
149 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list) in ehci_clear_tt_buffer_complete()
150 && ehci->rh_state == EHCI_RH_RUNNING) in ehci_clear_tt_buffer_complete()
152 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_clear_tt_buffer_complete()
165 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { in ehci_clear_tt_buffer()
167 struct usb_device *tt = urb->dev->tt->hub; in ehci_clear_tt_buffer()
168 dev_dbg(&tt->dev, in ehci_clear_tt_buffer()
170 urb->dev->ttport, urb->dev->devnum, in ehci_clear_tt_buffer()
171 usb_pipeendpoint(urb->pipe), token); in ehci_clear_tt_buffer()
174 || urb->dev->tt->hub != in ehci_clear_tt_buffer()
175 ehci_to_hcd(ehci)->self.root_hub) { in ehci_clear_tt_buffer()
177 qh->clearing_tt = 1; in ehci_clear_tt_buffer()
180 /* REVISIT ARC-derived cores don't clear the root in ehci_clear_tt_buffer()
194 int status = -EINPROGRESS; in qtd_copy_status()
198 urb->actual_length += length - QTD_LENGTH (token); in qtd_copy_status()
201 if (unlikely(urb->unlinked)) in qtd_copy_status()
206 status = -EREMOTEIO; in qtd_copy_status()
212 status = -EOVERFLOW; in qtd_copy_status()
215 * EHCI Specification, Table 4-13. in qtd_copy_status()
219 status = -EPROTO; in qtd_copy_status()
220 /* CERR nonzero + halt --> stall */ in qtd_copy_status()
222 status = -EPIPE; in qtd_copy_status()
229 /* fs/ls interrupt xfer missed the complete-split */ in qtd_copy_status()
230 status = -EPROTO; in qtd_copy_status()
233 ? -ENOSR /* hc couldn't read data */ in qtd_copy_status()
234 : -ECOMM; /* hc couldn't write data */ in qtd_copy_status()
238 urb->dev->devpath, in qtd_copy_status()
239 usb_pipeendpoint(urb->pipe), in qtd_copy_status()
240 usb_pipein(urb->pipe) ? "in" : "out"); in qtd_copy_status()
241 status = -EPROTO; in qtd_copy_status()
243 status = -EPROTO; in qtd_copy_status()
253 if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { in ehci_urb_done()
254 /* ... update hc-wide periodic stats */ in ehci_urb_done()
255 ehci_to_hcd(ehci)->self.bandwidth_int_reqs--; in ehci_urb_done()
258 if (unlikely(urb->unlinked)) { in ehci_urb_done()
259 INCR(ehci->stats.unlink); in ehci_urb_done()
261 /* report non-error and short read status as zero */ in ehci_urb_done()
262 if (status == -EINPROGRESS || status == -EREMOTEIO) in ehci_urb_done()
264 INCR(ehci->stats.complete); in ehci_urb_done()
270 __func__, urb->dev->devpath, urb, in ehci_urb_done()
271 usb_pipeendpoint (urb->pipe), in ehci_urb_done()
272 usb_pipein (urb->pipe) ? "in" : "out", in ehci_urb_done()
274 urb->actual_length, urb->transfer_buffer_length); in ehci_urb_done()
285 * Chases up to qh->hw_current. Returns nonzero if the caller should
291 struct ehci_qtd *last, *end = qh->dummy; in qh_completions()
296 struct ehci_qh_hw *hw = qh->hw; in qh_completions()
304 * It's a bug for qh->qh_state to be anything other than in qh_completions()
308 state = qh->qh_state; in qh_completions()
309 qh->qh_state = QH_STATE_COMPLETING; in qh_completions()
314 last_status = -EINPROGRESS; in qh_completions()
315 qh->dequeue_during_giveback = 0; in qh_completions()
317 /* remove de-activated QTDs from front of queue. in qh_completions()
322 list_for_each_safe (entry, tmp, &qh->qtd_list) { in qh_completions()
328 urb = qtd->urb; in qh_completions()
332 if (likely (last->urb != urb)) { in qh_completions()
333 ehci_urb_done(ehci, last->urb, last_status); in qh_completions()
334 last_status = -EINPROGRESS; in qh_completions()
346 token = hc32_to_cpu(ehci, qtd->hw_token); in qh_completions()
348 /* always clean up qtds the hc de-activated */ in qh_completions()
352 /* Report Data Buffer Error: non-fatal but useful */ in qh_completions()
357 usb_endpoint_num(&urb->ep->desc), in qh_completions()
358 usb_endpoint_dir_in(&urb->ep->desc) ? "in" : "out", in qh_completions()
359 urb->transfer_buffer_length, in qh_completions()
373 ++qh->xacterrs < QH_XACTERR_MAX && in qh_completions()
374 !urb->unlinked) { in qh_completions()
377 qtd->length - QTD_LENGTH(token), qtd->length, qh->xacterrs); in qh_completions()
387 qtd->hw_token = cpu_to_hc32(ehci, in qh_completions()
390 hw->hw_token = cpu_to_hc32(ehci, in qh_completions()
395 qh->unlink_reason |= QH_UNLINK_HALTED; in qh_completions()
402 * most other single-qtd reads ... the queue stops if in qh_completions()
407 && !(qtd->hw_alt_next in qh_completions()
410 qh->unlink_reason |= QH_UNLINK_SHORT_READ; in qh_completions()
415 && ehci->rh_state >= EHCI_RH_RUNNING)) { in qh_completions()
423 if (ehci->rh_state < EHCI_RH_RUNNING) { in qh_completions()
424 last_status = -ESHUTDOWN; in qh_completions()
425 qh->unlink_reason |= QH_UNLINK_SHUTDOWN; in qh_completions()
431 else if (last_status == -EINPROGRESS && !urb->unlinked) in qh_completions()
443 qh->qtd_list.next == &qtd->qtd_list && in qh_completions()
444 (hw->hw_token & ACTIVE_BIT(ehci))) { in qh_completions()
445 token = hc32_to_cpu(ehci, hw->hw_token); in qh_completions()
446 hw->hw_token &= ~ACTIVE_BIT(ehci); in qh_completions()
447 qh->should_be_inactive = 1; in qh_completions()
464 if (last_status == -EINPROGRESS) { in qh_completions()
466 qtd->length, token); in qh_completions()
467 if (last_status == -EREMOTEIO in qh_completions()
468 && (qtd->hw_alt_next in qh_completions()
470 last_status = -EINPROGRESS; in qh_completions()
472 /* As part of low/full-speed endpoint-halt processing in qh_completions()
475 if (unlikely(last_status != -EINPROGRESS && in qh_completions()
476 last_status != -EREMOTEIO)) { in qh_completions()
481 * state (if you believe Figures 11-48 - 11-51 in qh_completions()
486 if (last_status != -EPIPE) in qh_completions()
495 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { in qh_completions()
496 last = list_entry (qtd->qtd_list.prev, in qh_completions()
498 last->hw_next = qtd->hw_next; in qh_completions()
502 list_del (&qtd->qtd_list); in qh_completions()
506 qh->xacterrs = 0; in qh_completions()
511 ehci_urb_done(ehci, last->urb, last_status); in qh_completions()
516 if (unlikely(qh->dequeue_during_giveback)) { in qh_completions()
525 qh->qh_state = state; in qh_completions()
533 * - HC reads first part of QH; in qh_completions()
534 * - CPU updates that first part and the token; in qh_completions()
535 * - HC reads rest of that QH, including token in qh_completions()
542 if (stopped != 0 || hw->hw_qtd_next == EHCI_LIST_END(ehci)) in qh_completions()
543 qh->unlink_reason |= QH_UNLINK_DUMMY_OVERLAY; in qh_completions()
546 return qh->unlink_reason; in qh_completions()
549 /*-------------------------------------------------------------------------*/
566 list_del (&qtd->qtd_list); in qtd_list_free()
595 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
596 qtd->urb = urb; in qh_urb_transaction()
602 len = urb->transfer_buffer_length; in qh_urb_transaction()
603 is_input = usb_pipein (urb->pipe); in qh_urb_transaction()
604 if (usb_pipecontrol (urb->pipe)) { in qh_urb_transaction()
606 qtd_fill(ehci, qtd, urb->setup_dma, in qh_urb_transaction()
616 qtd->urb = urb; in qh_urb_transaction()
617 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
618 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
628 i = urb->num_mapped_sgs; in qh_urb_transaction()
630 sg = urb->sg; in qh_urb_transaction()
633 /* urb->transfer_buffer_length may be smaller than the in qh_urb_transaction()
639 buf = urb->transfer_dma; in qh_urb_transaction()
647 maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input); in qh_urb_transaction()
659 this_sg_len -= this_qtd_len; in qh_urb_transaction()
660 len -= this_qtd_len; in qh_urb_transaction()
669 qtd->hw_alt_next = ehci->async->hw->hw_alt_next; in qh_urb_transaction()
672 if ((maxpacket & (this_qtd_len + (maxpacket - 1))) == 0) in qh_urb_transaction()
676 if (--i <= 0 || len <= 0) in qh_urb_transaction()
687 qtd->urb = urb; in qh_urb_transaction()
688 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
689 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
697 if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 in qh_urb_transaction()
698 || usb_pipecontrol (urb->pipe))) in qh_urb_transaction()
699 qtd->hw_alt_next = EHCI_LIST_END(ehci); in qh_urb_transaction()
706 if (likely (urb->transfer_buffer_length != 0)) { in qh_urb_transaction()
709 if (usb_pipecontrol (urb->pipe)) { in qh_urb_transaction()
711 token ^= 0x0100; /* "in" <--> "out" */ in qh_urb_transaction()
713 } else if (usb_pipeout(urb->pipe) in qh_urb_transaction()
714 && (urb->transfer_flags & URB_ZERO_PACKET) in qh_urb_transaction()
715 && !(urb->transfer_buffer_length % maxpacket)) { in qh_urb_transaction()
723 qtd->urb = urb; in qh_urb_transaction()
724 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in qh_urb_transaction()
725 list_add_tail (&qtd->qtd_list, head); in qh_urb_transaction()
733 if (likely (!(urb->transfer_flags & URB_NO_INTERRUPT))) in qh_urb_transaction()
734 qtd->hw_token |= cpu_to_hc32(ehci, QTD_IOC); in qh_urb_transaction()
742 /*-------------------------------------------------------------------------*/
756 * just one microframe in the s-mask. For split interrupt transactions
757 * there are additional complications: c-mask, maybe FSTNs.
771 struct usb_tt *tt = urb->dev->tt; in qh_make()
780 info1 |= usb_pipeendpoint (urb->pipe) << 8; in qh_make()
781 info1 |= usb_pipedevice (urb->pipe) << 0; in qh_make()
783 is_input = usb_pipein (urb->pipe); in qh_make()
784 type = usb_pipetype (urb->pipe); in qh_make()
785 ep = usb_pipe_endpoint (urb->dev, urb->pipe); in qh_make()
786 maxp = usb_endpoint_maxp (&ep->desc); in qh_make()
787 mult = usb_endpoint_maxp_mult (&ep->desc); in qh_make()
798 * - allowing for high bandwidth, how many nsec/uframe are used? in qh_make()
799 * - split transactions need a second CSPLIT uframe; same question in qh_make()
800 * - splits also need a schedule gap (for full/low speed I/O) in qh_make()
801 * - qh has a polling interval in qh_make()
808 qh->ps.usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH, in qh_make()
810 qh->ps.phase = NO_FRAME; in qh_make()
812 if (urb->dev->speed == USB_SPEED_HIGH) { in qh_make()
813 qh->ps.c_usecs = 0; in qh_make()
814 qh->gap_uf = 0; in qh_make()
816 if (urb->interval > 1 && urb->interval < 8) { in qh_make()
821 urb->interval = 1; in qh_make()
822 } else if (urb->interval > ehci->periodic_size << 3) { in qh_make()
823 urb->interval = ehci->periodic_size << 3; in qh_make()
825 qh->ps.period = urb->interval >> 3; in qh_make()
829 1 << (urb->ep->desc.bInterval - 1)); in qh_make()
831 /* Allow urb->interval to override */ in qh_make()
832 qh->ps.bw_uperiod = min_t(unsigned, tmp, urb->interval); in qh_make()
833 qh->ps.bw_period = qh->ps.bw_uperiod >> 3; in qh_make()
838 qh->gap_uf = 1 + usb_calc_bus_time (urb->dev->speed, in qh_make()
843 qh->ps.c_usecs = qh->ps.usecs + HS_USECS(0); in qh_make()
844 qh->ps.usecs = HS_USECS(1); in qh_make()
846 qh->ps.usecs += HS_USECS(1); in qh_make()
847 qh->ps.c_usecs = HS_USECS(0); in qh_make()
850 think_time = tt ? tt->think_time : 0; in qh_make()
851 qh->ps.tt_usecs = NS_TO_US(think_time + in qh_make()
852 usb_calc_bus_time (urb->dev->speed, in qh_make()
854 if (urb->interval > ehci->periodic_size) in qh_make()
855 urb->interval = ehci->periodic_size; in qh_make()
856 qh->ps.period = urb->interval; in qh_make()
860 urb->ep->desc.bInterval); in qh_make()
863 /* Allow urb->interval to override */ in qh_make()
864 qh->ps.bw_period = min_t(unsigned, tmp, urb->interval); in qh_make()
865 qh->ps.bw_uperiod = qh->ps.bw_period << 3; in qh_make()
870 qh->ps.udev = urb->dev; in qh_make()
871 qh->ps.ep = urb->ep; in qh_make()
874 switch (urb->dev->speed) { in qh_make()
892 * port number in the queue head was 0..N-1 instead of 1..N. in qh_make()
895 info2 |= (urb->dev->ttport-1) << 23; in qh_make()
897 info2 |= urb->dev->ttport << 23; in qh_make()
902 if (tt && tt->hub != ehci_to_hcd(ehci)->self.root_hub) in qh_make()
903 info2 |= tt->hub->devnum << 16; in qh_make()
905 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */ in qh_make()
918 /* The USB spec says that high speed bulk endpoints in qh_make()
932 ehci_dbg(ehci, "bogus dev %p speed %d\n", urb->dev, in qh_make()
933 urb->dev->speed); in qh_make()
939 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets s-mask } */ in qh_make()
942 qh->qh_state = QH_STATE_IDLE; in qh_make()
943 hw = qh->hw; in qh_make()
944 hw->hw_info1 = cpu_to_hc32(ehci, info1); in qh_make()
945 hw->hw_info2 = cpu_to_hc32(ehci, info2); in qh_make()
946 qh->is_out = !is_input; in qh_make()
947 usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1); in qh_make()
951 /*-------------------------------------------------------------------------*/
955 if (ehci->async_count++) in enable_async()
959 ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_DISABLE_ASYNC); in enable_async()
968 if (--ehci->async_count) in disable_async()
972 WARN_ON(ehci->async->qh_next.qh || !list_empty(&ehci->async_unlink) || in disable_async()
973 !list_empty(&ehci->async_idle)); in disable_async()
983 __hc32 dma = QH_NEXT(ehci, qh->qh_dma); in qh_link_async()
986 /* Don't link a QH if there's a Clear-TT-Buffer pending */ in qh_link_async()
987 if (unlikely(qh->clearing_tt)) in qh_link_async()
990 WARN_ON(qh->qh_state != QH_STATE_IDLE); in qh_link_async()
996 head = ehci->async; in qh_link_async()
997 qh->qh_next = head->qh_next; in qh_link_async()
998 qh->hw->hw_next = head->hw->hw_next; in qh_link_async()
1001 head->qh_next.qh = qh; in qh_link_async()
1002 head->hw->hw_next = dma; in qh_link_async()
1004 qh->qh_state = QH_STATE_LINKED; in qh_link_async()
1005 qh->xacterrs = 0; in qh_link_async()
1006 qh->unlink_reason = 0; in qh_link_async()
1012 /*-------------------------------------------------------------------------*/
1033 /* can't sleep here, we have ehci->lock... */ in qh_append_tds()
1043 qtd = list_entry (qtd_list->next, struct ehci_qtd, in qh_append_tds()
1050 if (usb_pipedevice (urb->pipe) == 0) in qh_append_tds()
1051 qh->hw->hw_info1 &= ~qh_addr_mask; in qh_append_tds()
1067 token = qtd->hw_token; in qh_append_tds()
1068 qtd->hw_token = HALT_BIT(ehci); in qh_append_tds()
1070 dummy = qh->dummy; in qh_append_tds()
1072 dma = dummy->qtd_dma; in qh_append_tds()
1074 dummy->qtd_dma = dma; in qh_append_tds()
1076 list_del (&qtd->qtd_list); in qh_append_tds()
1077 list_add (&dummy->qtd_list, qtd_list); in qh_append_tds()
1078 list_splice_tail(qtd_list, &qh->qtd_list); in qh_append_tds()
1080 ehci_qtd_init(ehci, qtd, qtd->qtd_dma); in qh_append_tds()
1081 qh->dummy = qtd; in qh_append_tds()
1084 dma = qtd->qtd_dma; in qh_append_tds()
1085 qtd = list_entry (qh->qtd_list.prev, in qh_append_tds()
1087 qtd->hw_next = QTD_NEXT(ehci, dma); in qh_append_tds()
1091 dummy->hw_token = token; in qh_append_tds()
1093 urb->hcpriv = qh; in qh_append_tds()
1099 /*-------------------------------------------------------------------------*/
1113 epnum = urb->ep->desc.bEndpointAddress; in submit_async()
1118 qtd = list_entry(qtd_list->next, struct ehci_qtd, qtd_list); in submit_async()
1121 __func__, urb->dev->devpath, urb, in submit_async()
1123 urb->transfer_buffer_length, in submit_async()
1124 qtd, urb->ep->hcpriv); in submit_async()
1128 spin_lock_irqsave (&ehci->lock, flags); in submit_async()
1130 rc = -ESHUTDOWN; in submit_async()
1137 qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); in submit_async()
1140 rc = -ENOMEM; in submit_async()
1147 if (likely (qh->qh_state == QH_STATE_IDLE)) in submit_async()
1150 spin_unlock_irqrestore (&ehci->lock, flags); in submit_async()
1156 /*-------------------------------------------------------------------------*/
1165 * performed; TRUE - SETUP and FALSE - IN+STATUS
1188 return -1; in submit_single_step_set_feature()
1189 list_add_tail(&qtd->qtd_list, head); in submit_single_step_set_feature()
1190 qtd->urb = urb; in submit_single_step_set_feature()
1195 len = urb->transfer_buffer_length; in submit_single_step_set_feature()
1203 qtd_fill(ehci, qtd, urb->setup_dma, in submit_single_step_set_feature()
1215 token ^= QTD_TOGGLE; /*We need to start IN with DATA-1 Pid-sequence*/ in submit_single_step_set_feature()
1216 buf = urb->transfer_dma; in submit_single_step_set_feature()
1220 maxpacket = usb_maxpacket(urb->dev, urb->pipe, 0); in submit_single_step_set_feature()
1228 qtd->hw_alt_next = EHCI_LIST_END(ehci); in submit_single_step_set_feature()
1231 token ^= 0x0100; /* "in" <--> "out" */ in submit_single_step_set_feature()
1238 qtd->urb = urb; in submit_single_step_set_feature()
1239 qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma); in submit_single_step_set_feature()
1240 list_add_tail(&qtd->qtd_list, head); in submit_single_step_set_feature()
1251 return -1; in submit_single_step_set_feature()
1255 /*-------------------------------------------------------------------------*/
1262 qh->qh_state = QH_STATE_UNLINK_WAIT; in single_unlink_async()
1263 list_add_tail(&qh->unlink_node, &ehci->async_unlink); in single_unlink_async()
1266 prev = ehci->async; in single_unlink_async()
1267 while (prev->qh_next.qh != qh) in single_unlink_async()
1268 prev = prev->qh_next.qh; in single_unlink_async()
1270 prev->hw->hw_next = qh->hw->hw_next; in single_unlink_async()
1271 prev->qh_next = qh->qh_next; in single_unlink_async()
1272 if (ehci->qh_scan_next == qh) in single_unlink_async()
1273 ehci->qh_scan_next = qh->qh_next.qh; in single_unlink_async()
1279 if (unlikely(ehci->rh_state < EHCI_RH_RUNNING)) { in start_iaa_cycle()
1283 } else if (ehci->rh_state == EHCI_RH_RUNNING && in start_iaa_cycle()
1284 !ehci->iaa_in_progress) { in start_iaa_cycle()
1289 ehci_writel(ehci, ehci->command | CMD_IAAD, in start_iaa_cycle()
1290 &ehci->regs->command); in start_iaa_cycle()
1291 ehci_readl(ehci, &ehci->regs->command); in start_iaa_cycle()
1292 ehci->iaa_in_progress = true; in start_iaa_cycle()
1299 if (ehci->has_synopsys_hc_bug) in end_iaa_cycle()
1300 ehci_writel(ehci, (u32) ehci->async->qh_dma, in end_iaa_cycle()
1301 &ehci->regs->async_next); in end_iaa_cycle()
1304 ehci->iaa_in_progress = false; in end_iaa_cycle()
1316 if (list_empty(&ehci->async_unlink)) in end_unlink_async()
1318 qh = list_first_entry(&ehci->async_unlink, struct ehci_qh, in end_unlink_async()
1325 early_exit = ehci->async_unlinking; in end_unlink_async()
1328 if (ehci->rh_state < EHCI_RH_RUNNING) in end_unlink_async()
1329 list_splice_tail_init(&ehci->async_unlink, &ehci->async_idle); in end_unlink_async()
1333 * after the IAA interrupt occurs. In self-defense, always go in end_unlink_async()
1336 else if (qh->qh_state == QH_STATE_UNLINK) { in end_unlink_async()
1341 list_move_tail(&qh->unlink_node, &ehci->async_idle); in end_unlink_async()
1358 else if (qh->unlink_reason & (QH_UNLINK_HALTED | in end_unlink_async()
1363 else if ((qh->unlink_reason & QH_UNLINK_QUEUE_EMPTY) && in end_unlink_async()
1364 list_empty(&qh->qtd_list)) in end_unlink_async()
1368 else if (qh->hw->hw_token & cpu_to_hc32(ehci, QTD_STS_HALT)) in end_unlink_async()
1375 qh_current = qh->hw->hw_current; in end_unlink_async()
1376 qh_token = qh->hw->hw_token; in end_unlink_async()
1377 if (qh_current != ehci->old_current || in end_unlink_async()
1378 qh_token != ehci->old_token) { in end_unlink_async()
1379 ehci->old_current = qh_current; in end_unlink_async()
1380 ehci->old_token = qh_token; in end_unlink_async()
1386 qh->qh_state = QH_STATE_UNLINK; in end_unlink_async()
1389 ehci->old_current = ~0; /* Prepare for next QH */ in end_unlink_async()
1392 if (!list_empty(&ehci->async_unlink)) in end_unlink_async()
1403 ehci->async_unlinking = true; in end_unlink_async()
1404 while (!list_empty(&ehci->async_idle)) { in end_unlink_async()
1405 qh = list_first_entry(&ehci->async_idle, struct ehci_qh, in end_unlink_async()
1407 list_del(&qh->unlink_node); in end_unlink_async()
1409 qh->qh_state = QH_STATE_IDLE; in end_unlink_async()
1410 qh->qh_next.qh = NULL; in end_unlink_async()
1412 if (!list_empty(&qh->qtd_list)) in end_unlink_async()
1414 if (!list_empty(&qh->qtd_list) && in end_unlink_async()
1415 ehci->rh_state == EHCI_RH_RUNNING) in end_unlink_async()
1419 ehci->async_unlinking = false; in end_unlink_async()
1431 for (qh = ehci->async->qh_next.qh; qh; qh = qh->qh_next.qh) { in unlink_empty_async()
1432 if (list_empty(&qh->qtd_list) && in unlink_empty_async()
1433 qh->qh_state == QH_STATE_LINKED) { in unlink_empty_async()
1435 if (qh->unlink_cycle != ehci->async_unlink_cycle) in unlink_empty_async()
1441 if (list_empty(&ehci->async_unlink) && qh_to_unlink) { in unlink_empty_async()
1442 qh_to_unlink->unlink_reason |= QH_UNLINK_QUEUE_EMPTY; in unlink_empty_async()
1444 --count; in unlink_empty_async()
1450 ++ehci->async_unlink_cycle; in unlink_empty_async()
1461 while (ehci->async->qh_next.qh) { in unlink_empty_async_suspended()
1462 qh = ehci->async->qh_next.qh; in unlink_empty_async_suspended()
1463 WARN_ON(!list_empty(&qh->qtd_list)); in unlink_empty_async_suspended()
1471 /* caller must own ehci->lock */
1476 if (qh->qh_state != QH_STATE_LINKED) in start_unlink_async()
1483 /*-------------------------------------------------------------------------*/
1490 ehci->qh_scan_next = ehci->async->qh_next.qh; in scan_async()
1491 while (ehci->qh_scan_next) { in scan_async()
1492 qh = ehci->qh_scan_next; in scan_async()
1493 ehci->qh_scan_next = qh->qh_next.qh; in scan_async()
1496 if (!list_empty(&qh->qtd_list)) { in scan_async()
1501 * drops the lock. That's why ehci->qh_scan_next in scan_async()
1503 * gets unlinked then ehci->qh_scan_next is adjusted in scan_async()
1509 } else if (list_empty(&qh->qtd_list) in scan_async()
1510 && qh->qh_state == QH_STATE_LINKED) { in scan_async()
1511 qh->unlink_cycle = ehci->async_unlink_cycle; in scan_async()
1519 * as HCD schedule-scanning costs. Delay for any qh in scan_async()
1520 * we just scanned, there's a not-unusual case that it in scan_async()
1523 if (check_unlinks_later && ehci->rh_state == EHCI_RH_RUNNING && in scan_async()
1524 !(ehci->enabled_hrtimer_events & in scan_async()
1527 ++ehci->async_unlink_cycle; in scan_async()