Lines Matching refs:ehci

32 periodic_next_shadow(struct ehci_hcd *ehci, union ehci_shadow *periodic,  in periodic_next_shadow()  argument
35 switch (hc32_to_cpu(ehci, tag)) { in periodic_next_shadow()
49 shadow_next_periodic(struct ehci_hcd *ehci, union ehci_shadow *periodic, in shadow_next_periodic() argument
52 switch (hc32_to_cpu(ehci, tag)) { in shadow_next_periodic()
63 static void periodic_unlink(struct ehci_hcd *ehci, unsigned frame, void *ptr) in periodic_unlink() argument
65 union ehci_shadow *prev_p = &ehci->pshadow[frame]; in periodic_unlink()
66 __hc32 *hw_p = &ehci->periodic[frame]; in periodic_unlink()
71 prev_p = periodic_next_shadow(ehci, prev_p, in periodic_unlink()
72 Q_NEXT_TYPE(ehci, *hw_p)); in periodic_unlink()
73 hw_p = shadow_next_periodic(ehci, &here, in periodic_unlink()
74 Q_NEXT_TYPE(ehci, *hw_p)); in periodic_unlink()
84 *prev_p = *periodic_next_shadow(ehci, &here, in periodic_unlink()
85 Q_NEXT_TYPE(ehci, *hw_p)); in periodic_unlink()
87 if (!ehci->use_dummy_qh || in periodic_unlink()
88 *shadow_next_periodic(ehci, &here, Q_NEXT_TYPE(ehci, *hw_p)) in periodic_unlink()
89 != EHCI_LIST_END(ehci)) in periodic_unlink()
90 *hw_p = *shadow_next_periodic(ehci, &here, in periodic_unlink()
91 Q_NEXT_TYPE(ehci, *hw_p)); in periodic_unlink()
93 *hw_p = cpu_to_hc32(ehci, ehci->dummy->qh_dma); in periodic_unlink()
137 struct ehci_hcd *ehci = in find_tt() local
148 list_add_tail(&tt->tt_list, &ehci->tt_list); in find_tt()
194 static void bandwidth_dbg(struct ehci_hcd *ehci, int sign, char *type, in bandwidth_dbg() argument
206 static void reserve_release_intr_bandwidth(struct ehci_hcd *ehci, in reserve_release_intr_bandwidth() argument
220 bandwidth_dbg(ehci, sign, "intr", &qh->ps); in reserve_release_intr_bandwidth()
231 ehci->bandwidth[i] += usecs; in reserve_release_intr_bandwidth()
240 ehci->bandwidth[i+j] += c_usecs; in reserve_release_intr_bandwidth()
354 struct ehci_hcd *ehci, in tt_available() argument
377 tt_usecs[i] = ehci->tt_budget[uf]; in tt_available()
414 struct ehci_hcd *ehci, in tt_no_collision() argument
428 for (; frame < ehci->periodic_size; frame += period) { in tt_no_collision()
433 here = ehci->pshadow[frame]; in tt_no_collision()
434 type = Q_NEXT_TYPE(ehci, ehci->periodic[frame]); in tt_no_collision()
436 switch (hc32_to_cpu(ehci, type)) { in tt_no_collision()
438 type = Q_NEXT_TYPE(ehci, here.itd->hw_next); in tt_no_collision()
446 mask = hc32_to_cpu(ehci, in tt_no_collision()
453 type = Q_NEXT_TYPE(ehci, hw->hw_next); in tt_no_collision()
460 mask = hc32_to_cpu(ehci, here.sitd in tt_no_collision()
467 type = Q_NEXT_TYPE(ehci, here.sitd->hw_next); in tt_no_collision()
472 ehci_dbg(ehci, in tt_no_collision()
490 static void enable_periodic(struct ehci_hcd *ehci) in enable_periodic() argument
492 if (ehci->periodic_count++) in enable_periodic()
496 ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_DISABLE_PERIODIC); in enable_periodic()
499 ehci_poll_PSS(ehci); in enable_periodic()
500 turn_on_io_watchdog(ehci); in enable_periodic()
503 static void disable_periodic(struct ehci_hcd *ehci) in disable_periodic() argument
505 if (--ehci->periodic_count) in disable_periodic()
509 ehci_poll_PSS(ehci); in disable_periodic()
520 static void qh_link_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_link_periodic() argument
527 period, hc32_to_cpup(ehci, &qh->hw->hw_info2) in qh_link_periodic()
535 for (i = qh->ps.phase; i < ehci->periodic_size; i += period) { in qh_link_periodic()
536 union ehci_shadow *prev = &ehci->pshadow[i]; in qh_link_periodic()
537 __hc32 *hw_p = &ehci->periodic[i]; in qh_link_periodic()
543 type = Q_NEXT_TYPE(ehci, *hw_p); in qh_link_periodic()
544 if (type == cpu_to_hc32(ehci, Q_TYPE_QH)) in qh_link_periodic()
546 prev = periodic_next_shadow(ehci, prev, type); in qh_link_periodic()
547 hw_p = shadow_next_periodic(ehci, &here, type); in qh_link_periodic()
568 *hw_p = QH_NEXT(ehci, qh->qh_dma); in qh_link_periodic()
576 ehci_to_hcd(ehci)->self.bandwidth_allocated += qh->ps.bw_period in qh_link_periodic()
580 list_add(&qh->intr_node, &ehci->intr_qh_list); in qh_link_periodic()
583 ++ehci->intr_count; in qh_link_periodic()
584 enable_periodic(ehci); in qh_link_periodic()
587 static void qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_unlink_periodic() argument
610 for (i = qh->ps.phase; i < ehci->periodic_size; i += period) in qh_unlink_periodic()
611 periodic_unlink(ehci, i, qh); in qh_unlink_periodic()
614 ehci_to_hcd(ehci)->self.bandwidth_allocated -= qh->ps.bw_period in qh_unlink_periodic()
621 hc32_to_cpup(ehci, &qh->hw->hw_info2) & (QH_CMASK | QH_SMASK), in qh_unlink_periodic()
628 if (ehci->qh_scan_next == qh) in qh_unlink_periodic()
629 ehci->qh_scan_next = list_entry(qh->intr_node.next, in qh_unlink_periodic()
634 static void cancel_unlink_wait_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in cancel_unlink_wait_intr() argument
648 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in start_unlink_intr() argument
655 cancel_unlink_wait_intr(ehci, qh); in start_unlink_intr()
657 qh_unlink_periodic(ehci, qh); in start_unlink_intr()
667 qh->unlink_cycle = ehci->intr_unlink_cycle; in start_unlink_intr()
670 list_add_tail(&qh->unlink_node, &ehci->intr_unlink); in start_unlink_intr()
672 if (ehci->intr_unlinking) in start_unlink_intr()
674 else if (ehci->rh_state < EHCI_RH_RUNNING) in start_unlink_intr()
675 ehci_handle_intr_unlinks(ehci); in start_unlink_intr()
676 else if (ehci->intr_unlink.next == &qh->unlink_node) { in start_unlink_intr()
677 ehci_enable_event(ehci, EHCI_HRTIMER_UNLINK_INTR, true); in start_unlink_intr()
678 ++ehci->intr_unlink_cycle; in start_unlink_intr()
687 static void start_unlink_intr_wait(struct ehci_hcd *ehci, in start_unlink_intr_wait() argument
690 qh->unlink_cycle = ehci->intr_unlink_wait_cycle; in start_unlink_intr_wait()
693 list_add_tail(&qh->unlink_node, &ehci->intr_unlink_wait); in start_unlink_intr_wait()
695 if (ehci->rh_state < EHCI_RH_RUNNING) in start_unlink_intr_wait()
696 ehci_handle_start_intr_unlinks(ehci); in start_unlink_intr_wait()
697 else if (ehci->intr_unlink_wait.next == &qh->unlink_node) { in start_unlink_intr_wait()
698 ehci_enable_event(ehci, EHCI_HRTIMER_START_UNLINK_INTR, true); in start_unlink_intr_wait()
699 ++ehci->intr_unlink_wait_cycle; in start_unlink_intr_wait()
703 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in end_unlink_intr() argument
709 hw->hw_next = EHCI_LIST_END(ehci); in end_unlink_intr()
712 qh_completions(ehci, qh); in end_unlink_intr()
715 if (!list_empty(&qh->qtd_list) && ehci->rh_state == EHCI_RH_RUNNING) { in end_unlink_intr()
716 rc = qh_schedule(ehci, qh); in end_unlink_intr()
718 qh_refresh(ehci, qh); in end_unlink_intr()
719 qh_link_periodic(ehci, qh); in end_unlink_intr()
729 ehci_err(ehci, "can't reschedule qh %p, err %d\n", in end_unlink_intr()
735 --ehci->intr_count; in end_unlink_intr()
736 disable_periodic(ehci); in end_unlink_intr()
742 struct ehci_hcd *ehci, in check_period() argument
755 usecs = ehci->uframe_periodic_max - usecs; in check_period()
759 if (ehci->bandwidth[uframe] > usecs) in check_period()
768 struct ehci_hcd *ehci, in check_intr_schedule() argument
782 if (!check_period(ehci, frame, uframe, qh->ps.bw_uperiod, qh->ps.usecs)) in check_intr_schedule()
791 if (tt_available(ehci, &qh->ps, tt, frame, uframe)) { in check_intr_schedule()
796 if (!check_period(ehci, frame, i, in check_intr_schedule()
818 if (tt_no_collision(ehci, qh->ps.bw_period, qh->ps.udev, frame, mask)) { in check_intr_schedule()
819 if (!check_period(ehci, frame, uframe + qh->gap_uf + 1, in check_intr_schedule()
822 if (!check_period(ehci, frame, uframe + qh->gap_uf, in check_intr_schedule()
835 static int qh_schedule(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_schedule() argument
843 hw->hw_next = EHCI_LIST_END(ehci); in qh_schedule()
847 ehci_dbg(ehci, "reused qh %p schedule\n", qh); in qh_schedule()
858 compute_tt_budget(ehci->tt_budget, tt); in qh_schedule()
869 frame = ++ehci->random_frame & (qh->ps.bw_period - 1); in qh_schedule()
871 status = check_intr_schedule(ehci, in qh_schedule()
880 status = check_intr_schedule(ehci, 0, 0, qh, &c_mask, tt); in qh_schedule()
886 qh->ps.phase = (qh->ps.period ? ehci->random_frame & in qh_schedule()
895 hw->hw_info2 &= cpu_to_hc32(ehci, ~(QH_CMASK | QH_SMASK)); in qh_schedule()
896 hw->hw_info2 |= cpu_to_hc32(ehci, qh->ps.cs_mask); in qh_schedule()
897 reserve_release_intr_bandwidth(ehci, qh, 1); in qh_schedule()
904 struct ehci_hcd *ehci, in intr_submit() argument
918 spin_lock_irqsave(&ehci->lock, flags); in intr_submit()
920 if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { in intr_submit()
924 status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); in intr_submit()
930 qh = qh_append_tds(ehci, urb, &empty, epnum, &urb->ep->hcpriv); in intr_submit()
936 status = qh_schedule(ehci, qh); in intr_submit()
942 qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); in intr_submit()
947 qh_refresh(ehci, qh); in intr_submit()
948 qh_link_periodic(ehci, qh); in intr_submit()
951 cancel_unlink_wait_intr(ehci, qh); in intr_submit()
955 ehci_to_hcd(ehci)->self.bandwidth_int_reqs++; in intr_submit()
959 usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); in intr_submit()
961 spin_unlock_irqrestore(&ehci->lock, flags); in intr_submit()
963 qtd_list_free(ehci, urb, qtd_list); in intr_submit()
968 static void scan_intr(struct ehci_hcd *ehci) in scan_intr() argument
972 list_for_each_entry_safe(qh, ehci->qh_scan_next, &ehci->intr_qh_list, in scan_intr()
986 temp = qh_completions(ehci, qh); in scan_intr()
988 start_unlink_intr(ehci, qh); in scan_intr()
991 start_unlink_intr_wait(ehci, qh); in scan_intr()
1017 struct ehci_hcd *ehci, in iso_stream_init() argument
1048 stream->buf0 = cpu_to_hc32(ehci, (epnum << 8) | dev->devnum); in iso_stream_init()
1049 stream->buf1 = cpu_to_hc32(ehci, buf1); in iso_stream_init()
1050 stream->buf2 = cpu_to_hc32(ehci, multi); in iso_stream_init()
1075 if (!ehci_is_TDI(ehci) in iso_stream_init()
1077 ehci_to_hcd(ehci)->self.root_hub)) in iso_stream_init()
1114 stream->address = cpu_to_hc32(ehci, addr); in iso_stream_init()
1125 iso_stream_find(struct ehci_hcd *ehci, struct urb *urb) in iso_stream_find() argument
1138 spin_lock_irqsave(&ehci->lock, flags); in iso_stream_find()
1145 iso_stream_init(ehci, stream, urb); in iso_stream_find()
1150 ehci_dbg(ehci, "dev %s ep%d%s, not iso??\n", in iso_stream_find()
1156 spin_unlock_irqrestore(&ehci->lock, flags); in iso_stream_find()
1178 struct ehci_hcd *ehci, in itd_sched_init() argument
1208 uframe->transaction = cpu_to_hc32(ehci, trans); in itd_sched_init()
1234 struct ehci_hcd *ehci, in itd_urb_transaction() argument
1250 itd_sched_init(ehci, sched, stream, urb); in itd_urb_transaction()
1258 spin_lock_irqsave(&ehci->lock, flags); in itd_urb_transaction()
1268 if (itd->frame == ehci->now_frame) in itd_urb_transaction()
1274 spin_unlock_irqrestore(&ehci->lock, flags); in itd_urb_transaction()
1275 itd = dma_pool_alloc(ehci->itd_pool, mem_flags, in itd_urb_transaction()
1277 spin_lock_irqsave(&ehci->lock, flags); in itd_urb_transaction()
1280 spin_unlock_irqrestore(&ehci->lock, flags); in itd_urb_transaction()
1290 spin_unlock_irqrestore(&ehci->lock, flags); in itd_urb_transaction()
1300 static void reserve_release_iso_bandwidth(struct ehci_hcd *ehci, in reserve_release_iso_bandwidth() argument
1315 bandwidth_dbg(ehci, sign, "iso", &stream->ps); in reserve_release_iso_bandwidth()
1326 ehci->bandwidth[i] += usecs; in reserve_release_iso_bandwidth()
1338 ehci->bandwidth[i+j] += usecs; in reserve_release_iso_bandwidth()
1340 ehci->bandwidth[i+j] += c_usecs; in reserve_release_iso_bandwidth()
1364 struct ehci_hcd *ehci, in itd_slot_ok() argument
1372 usecs = ehci->uframe_periodic_max - stream->ps.usecs; in itd_slot_ok()
1376 if (ehci->bandwidth[uframe] > usecs) in itd_slot_ok()
1384 struct ehci_hcd *ehci, in sitd_slot_ok() argument
1413 if (!tt_available(ehci, &stream->ps, tt, frame, uf)) in sitd_slot_ok()
1419 if (!tt_no_collision(ehci, stream->ps.bw_period, in sitd_slot_ok()
1430 max_used = ehci->uframe_periodic_max - stream->ps.usecs; in sitd_slot_ok()
1432 if (ehci->bandwidth[uf] > max_used) in sitd_slot_ok()
1438 max_used = ehci->uframe_periodic_max - in sitd_slot_ok()
1445 if (ehci->bandwidth[uf+i] > max_used) in sitd_slot_ok()
1454 stream->splits = cpu_to_hc32(ehci, stream->ps.cs_mask); in sitd_slot_ok()
1471 struct ehci_hcd *ehci, in iso_stream_schedule() argument
1479 unsigned mod = ehci->periodic_size << 3; in iso_stream_schedule()
1491 ehci_to_hcd(ehci), urb->ep))) { in iso_stream_schedule()
1502 compute_tt_budget(ehci->tt_budget, tt); in iso_stream_schedule()
1504 start = ((-(++ehci->random_frame)) << 3) & (period - 1); in iso_stream_schedule()
1517 if (itd_slot_ok(ehci, stream, start)) in iso_stream_schedule()
1522 if (sitd_slot_ok(ehci, stream, start, in iso_stream_schedule()
1530 ehci_dbg(ehci, "iso sched full %p", urb); in iso_stream_schedule()
1539 reserve_release_iso_bandwidth(ehci, stream, 1); in iso_stream_schedule()
1551 now = ehci_read_frame_index(ehci) & (mod - 1); in iso_stream_schedule()
1554 if (ehci->i_thresh) in iso_stream_schedule()
1555 next = now + ehci->i_thresh; /* uframe cache */ in iso_stream_schedule()
1560 if (ehci->isoc_count == 0) in iso_stream_schedule()
1561 ehci->last_iso_frame = now >> 3; in iso_stream_schedule()
1567 base = ehci->last_iso_frame << 3; in iso_stream_schedule()
1584 ehci_dbg(ehci, "request %p would overflow (%u-%u < %u mod %u)\n", in iso_stream_schedule()
1613 ehci_dbg(ehci, "iso underrun %p (%u+%u < %u) [%u]\n", in iso_stream_schedule()
1640 ehci_dbg(ehci, "request %p would overflow (%u+%u >= %u)\n", in iso_stream_schedule()
1664 itd_init(struct ehci_hcd *ehci, struct ehci_iso_stream *stream, in itd_init() argument
1670 itd->hw_next = EHCI_LIST_END(ehci); in itd_init()
1683 struct ehci_hcd *ehci, in itd_patch() argument
1699 itd->hw_transaction[uframe] |= cpu_to_hc32(ehci, pg << 12); in itd_patch()
1700 itd->hw_bufp[pg] |= cpu_to_hc32(ehci, uf->bufp & ~(u32)0); in itd_patch()
1701 itd->hw_bufp_hi[pg] |= cpu_to_hc32(ehci, (u32)(uf->bufp >> 32)); in itd_patch()
1708 itd->hw_bufp[pg] |= cpu_to_hc32(ehci, bufp & ~(u32)0); in itd_patch()
1709 itd->hw_bufp_hi[pg] |= cpu_to_hc32(ehci, (u32)(bufp >> 32)); in itd_patch()
1714 itd_link(struct ehci_hcd *ehci, unsigned frame, struct ehci_itd *itd) in itd_link() argument
1716 union ehci_shadow *prev = &ehci->pshadow[frame]; in itd_link()
1717 __hc32 *hw_p = &ehci->periodic[frame]; in itd_link()
1723 type = Q_NEXT_TYPE(ehci, *hw_p); in itd_link()
1724 if (type == cpu_to_hc32(ehci, Q_TYPE_QH)) in itd_link()
1726 prev = periodic_next_shadow(ehci, prev, type); in itd_link()
1727 hw_p = shadow_next_periodic(ehci, &here, type); in itd_link()
1736 *hw_p = cpu_to_hc32(ehci, itd->itd_dma | Q_TYPE_ITD); in itd_link()
1741 struct ehci_hcd *ehci, in itd_link_urb() argument
1755 ehci_to_hcd(ehci)->self.bandwidth_allocated in itd_link_urb()
1758 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) { in itd_link_urb()
1759 if (ehci->amd_pll_fix == 1) in itd_link_urb()
1763 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; in itd_link_urb()
1779 itd_init(ehci, stream, itd); in itd_link_urb()
1785 itd_patch(ehci, itd, iso_sched, packet, uframe); in itd_link_urb()
1794 itd_link(ehci, frame & (ehci->periodic_size - 1), itd); in itd_link_urb()
1804 ++ehci->isoc_count; in itd_link_urb()
1805 enable_periodic(ehci); in itd_link_urb()
1820 static bool itd_complete(struct ehci_hcd *ehci, struct ehci_itd *itd) in itd_complete() argument
1837 t = hc32_to_cpup(ehci, &itd->hw_transaction[uframe]); in itd_complete()
1878 ehci_urb_done(ehci, urb, 0); in itd_complete()
1882 --ehci->isoc_count; in itd_complete()
1883 disable_periodic(ehci); in itd_complete()
1885 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; in itd_complete()
1886 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) { in itd_complete()
1887 if (ehci->amd_pll_fix == 1) in itd_complete()
1892 ehci_to_hcd(ehci)->self.bandwidth_allocated in itd_complete()
1904 &ehci->cached_itd_list); in itd_complete()
1905 start_free_itds(ehci); in itd_complete()
1913 static int itd_submit(struct ehci_hcd *ehci, struct urb *urb, in itd_submit() argument
1921 stream = iso_stream_find(ehci, urb); in itd_submit()
1923 ehci_dbg(ehci, "can't get iso stream\n"); in itd_submit()
1927 ehci_dbg(ehci, "can't change iso interval %d --> %d\n", in itd_submit()
1933 ehci_dbg(ehci, in itd_submit()
1944 status = itd_urb_transaction(stream, ehci, urb, mem_flags); in itd_submit()
1946 ehci_dbg(ehci, "can't init itds\n"); in itd_submit()
1951 spin_lock_irqsave(&ehci->lock, flags); in itd_submit()
1952 if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { in itd_submit()
1956 status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); in itd_submit()
1959 status = iso_stream_schedule(ehci, urb, stream); in itd_submit()
1961 itd_link_urb(ehci, urb, ehci->periodic_size << 3, stream); in itd_submit()
1964 ehci_urb_done(ehci, urb, 0); in itd_submit()
1966 usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); in itd_submit()
1969 spin_unlock_irqrestore(&ehci->lock, flags); in itd_submit()
1983 struct ehci_hcd *ehci, in sitd_sched_init() argument
2012 packet->transaction = cpu_to_hc32(ehci, trans); in sitd_sched_init()
2033 struct ehci_hcd *ehci, in sitd_urb_transaction() argument
2048 sitd_sched_init(ehci, iso_sched, stream, urb); in sitd_urb_transaction()
2051 spin_lock_irqsave(&ehci->lock, flags); in sitd_urb_transaction()
2066 if (sitd->frame == ehci->now_frame) in sitd_urb_transaction()
2072 spin_unlock_irqrestore(&ehci->lock, flags); in sitd_urb_transaction()
2073 sitd = dma_pool_alloc(ehci->sitd_pool, mem_flags, in sitd_urb_transaction()
2075 spin_lock_irqsave(&ehci->lock, flags); in sitd_urb_transaction()
2078 spin_unlock_irqrestore(&ehci->lock, flags); in sitd_urb_transaction()
2093 spin_unlock_irqrestore(&ehci->lock, flags); in sitd_urb_transaction()
2101 struct ehci_hcd *ehci, in sitd_patch() argument
2111 sitd->hw_next = EHCI_LIST_END(ehci); in sitd_patch()
2115 sitd->hw_backpointer = EHCI_LIST_END(ehci); in sitd_patch()
2118 sitd->hw_buf[0] = cpu_to_hc32(ehci, bufp); in sitd_patch()
2119 sitd->hw_buf_hi[0] = cpu_to_hc32(ehci, bufp >> 32); in sitd_patch()
2121 sitd->hw_buf[1] = cpu_to_hc32(ehci, uf->buf1); in sitd_patch()
2124 sitd->hw_buf_hi[1] = cpu_to_hc32(ehci, bufp >> 32); in sitd_patch()
2129 sitd_link(struct ehci_hcd *ehci, unsigned frame, struct ehci_sitd *sitd) in sitd_link() argument
2132 sitd->sitd_next = ehci->pshadow[frame]; in sitd_link()
2133 sitd->hw_next = ehci->periodic[frame]; in sitd_link()
2134 ehci->pshadow[frame].sitd = sitd; in sitd_link()
2137 ehci->periodic[frame] = cpu_to_hc32(ehci, sitd->sitd_dma | Q_TYPE_SITD); in sitd_link()
2142 struct ehci_hcd *ehci, in sitd_link_urb() argument
2157 ehci_to_hcd(ehci)->self.bandwidth_allocated in sitd_link_urb()
2160 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) { in sitd_link_urb()
2161 if (ehci->amd_pll_fix == 1) in sitd_link_urb()
2165 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; in sitd_link_urb()
2183 sitd_patch(ehci, stream, sitd, sched, packet); in sitd_link_urb()
2184 sitd_link(ehci, (next_uframe >> 3) & (ehci->periodic_size - 1), in sitd_link_urb()
2195 ++ehci->isoc_count; in sitd_link_urb()
2196 enable_periodic(ehci); in sitd_link_urb()
2214 static bool sitd_complete(struct ehci_hcd *ehci, struct ehci_sitd *sitd) in sitd_complete() argument
2225 t = hc32_to_cpup(ehci, &sitd->hw_results); in sitd_complete()
2258 ehci_urb_done(ehci, urb, 0); in sitd_complete()
2262 --ehci->isoc_count; in sitd_complete()
2263 disable_periodic(ehci); in sitd_complete()
2265 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; in sitd_complete()
2266 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) { in sitd_complete()
2267 if (ehci->amd_pll_fix == 1) in sitd_complete()
2272 ehci_to_hcd(ehci)->self.bandwidth_allocated in sitd_complete()
2284 &ehci->cached_sitd_list); in sitd_complete()
2285 start_free_itds(ehci); in sitd_complete()
2292 static int sitd_submit(struct ehci_hcd *ehci, struct urb *urb, in sitd_submit() argument
2300 stream = iso_stream_find(ehci, urb); in sitd_submit()
2302 ehci_dbg(ehci, "can't get iso stream\n"); in sitd_submit()
2306 ehci_dbg(ehci, "can't change iso interval %d --> %d\n", in sitd_submit()
2312 ehci_dbg(ehci, in sitd_submit()
2321 status = sitd_urb_transaction(stream, ehci, urb, mem_flags); in sitd_submit()
2323 ehci_dbg(ehci, "can't init sitds\n"); in sitd_submit()
2328 spin_lock_irqsave(&ehci->lock, flags); in sitd_submit()
2329 if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { in sitd_submit()
2333 status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); in sitd_submit()
2336 status = iso_stream_schedule(ehci, urb, stream); in sitd_submit()
2338 sitd_link_urb(ehci, urb, ehci->periodic_size << 3, stream); in sitd_submit()
2341 ehci_urb_done(ehci, urb, 0); in sitd_submit()
2343 usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); in sitd_submit()
2346 spin_unlock_irqrestore(&ehci->lock, flags); in sitd_submit()
2353 static void scan_isoc(struct ehci_hcd *ehci) in scan_isoc() argument
2356 unsigned fmask = ehci->periodic_size - 1; in scan_isoc()
2366 if (ehci->rh_state >= EHCI_RH_RUNNING) { in scan_isoc()
2367 uf = ehci_read_frame_index(ehci); in scan_isoc()
2371 now_frame = (ehci->last_iso_frame - 1) & fmask; in scan_isoc()
2374 ehci->now_frame = now_frame; in scan_isoc()
2376 frame = ehci->last_iso_frame; in scan_isoc()
2380 q_p = &ehci->pshadow[frame]; in scan_isoc()
2381 hw_p = &ehci->periodic[frame]; in scan_isoc()
2383 type = Q_NEXT_TYPE(ehci, *hw_p); in scan_isoc()
2387 switch (hc32_to_cpu(ehci, type)) { in scan_isoc()
2399 ITD_ACTIVE(ehci)) in scan_isoc()
2405 type = Q_NEXT_TYPE(ehci, in scan_isoc()
2419 if (!ehci->use_dummy_qh || in scan_isoc()
2420 q.itd->hw_next != EHCI_LIST_END(ehci)) in scan_isoc()
2423 *hw_p = cpu_to_hc32(ehci, ehci->dummy->qh_dma); in scan_isoc()
2424 type = Q_NEXT_TYPE(ehci, q.itd->hw_next); in scan_isoc()
2426 modified = itd_complete(ehci, q.itd); in scan_isoc()
2439 && (q.sitd->hw_results & SITD_ACTIVE(ehci))) { in scan_isoc()
2443 type = Q_NEXT_TYPE(ehci, q.sitd->hw_next); in scan_isoc()
2454 if (!ehci->use_dummy_qh || in scan_isoc()
2455 q.sitd->hw_next != EHCI_LIST_END(ehci)) in scan_isoc()
2458 *hw_p = cpu_to_hc32(ehci, ehci->dummy->qh_dma); in scan_isoc()
2459 type = Q_NEXT_TYPE(ehci, q.sitd->hw_next); in scan_isoc()
2461 modified = sitd_complete(ehci, q.sitd); in scan_isoc()
2465 ehci_dbg(ehci, "corrupt type %d frame %d shadow %p\n", in scan_isoc()
2477 if (unlikely(modified && ehci->isoc_count > 0)) in scan_isoc()
2486 ehci->last_iso_frame = frame; in scan_isoc()