Lines Matching full:ehci
7 /* this file is part of ehci-hcd.c */
12 * EHCI scheduled transaction support: interrupt, iso, split iso
13 * These are called "periodic" transactions in the EHCI spec.
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()
62 /* caller must hold ehci->lock */
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()
343 * See the EHCI spec sec 4.5 and fig 4.7.
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()
501 turn_on_io_watchdog(ehci); in enable_periodic()
504 static void disable_periodic(struct ehci_hcd *ehci) in disable_periodic() argument
506 if (--ehci->periodic_count) in disable_periodic()
510 ehci_poll_PSS(ehci); in disable_periodic()
519 * no FSTN support (yet; ehci 0.96+)
521 static void qh_link_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_link_periodic() argument
528 period, hc32_to_cpup(ehci, &qh->hw->hw_info2) in qh_link_periodic()
536 for (i = qh->ps.phase; i < ehci->periodic_size; i += period) { in qh_link_periodic()
537 union ehci_shadow *prev = &ehci->pshadow[i]; in qh_link_periodic()
538 __hc32 *hw_p = &ehci->periodic[i]; in qh_link_periodic()
544 type = Q_NEXT_TYPE(ehci, *hw_p); in qh_link_periodic()
545 if (type == cpu_to_hc32(ehci, Q_TYPE_QH)) in qh_link_periodic()
547 prev = periodic_next_shadow(ehci, prev, type); in qh_link_periodic()
548 hw_p = shadow_next_periodic(ehci, &here, type); in qh_link_periodic()
569 *hw_p = QH_NEXT(ehci, qh->qh_dma); in qh_link_periodic()
577 ehci_to_hcd(ehci)->self.bandwidth_allocated += qh->ps.bw_period in qh_link_periodic()
581 list_add(&qh->intr_node, &ehci->intr_qh_list); in qh_link_periodic()
584 ++ehci->intr_count; in qh_link_periodic()
585 enable_periodic(ehci); in qh_link_periodic()
588 static void qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_unlink_periodic() argument
597 * waiting at least one frame, as described in EHCI 4.12.2.5. in qh_unlink_periodic()
611 for (i = qh->ps.phase; i < ehci->periodic_size; i += period) in qh_unlink_periodic()
612 periodic_unlink(ehci, i, qh); in qh_unlink_periodic()
615 ehci_to_hcd(ehci)->self.bandwidth_allocated -= qh->ps.bw_period in qh_unlink_periodic()
622 hc32_to_cpup(ehci, &qh->hw->hw_info2) & (QH_CMASK | QH_SMASK), in qh_unlink_periodic()
629 if (ehci->qh_scan_next == qh) in qh_unlink_periodic()
630 ehci->qh_scan_next = list_entry(qh->intr_node.next, in qh_unlink_periodic()
635 static void cancel_unlink_wait_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in cancel_unlink_wait_intr() argument
649 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in start_unlink_intr() argument
656 cancel_unlink_wait_intr(ehci, qh); in start_unlink_intr()
658 qh_unlink_periodic(ehci, qh); in start_unlink_intr()
664 * The EHCI spec doesn't say how long it takes the controller to in start_unlink_intr()
668 qh->unlink_cycle = ehci->intr_unlink_cycle; in start_unlink_intr()
671 list_add_tail(&qh->unlink_node, &ehci->intr_unlink); in start_unlink_intr()
673 if (ehci->intr_unlinking) in start_unlink_intr()
675 else if (ehci->rh_state < EHCI_RH_RUNNING) in start_unlink_intr()
676 ehci_handle_intr_unlinks(ehci); in start_unlink_intr()
677 else if (ehci->intr_unlink.next == &qh->unlink_node) { in start_unlink_intr()
678 ehci_enable_event(ehci, EHCI_HRTIMER_UNLINK_INTR, true); in start_unlink_intr()
679 ++ehci->intr_unlink_cycle; in start_unlink_intr()
688 static void start_unlink_intr_wait(struct ehci_hcd *ehci, in start_unlink_intr_wait() argument
691 qh->unlink_cycle = ehci->intr_unlink_wait_cycle; in start_unlink_intr_wait()
694 list_add_tail(&qh->unlink_node, &ehci->intr_unlink_wait); in start_unlink_intr_wait()
696 if (ehci->rh_state < EHCI_RH_RUNNING) in start_unlink_intr_wait()
697 ehci_handle_start_intr_unlinks(ehci); in start_unlink_intr_wait()
698 else if (ehci->intr_unlink_wait.next == &qh->unlink_node) { in start_unlink_intr_wait()
699 ehci_enable_event(ehci, EHCI_HRTIMER_START_UNLINK_INTR, true); in start_unlink_intr_wait()
700 ++ehci->intr_unlink_wait_cycle; in start_unlink_intr_wait()
704 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in end_unlink_intr() argument
710 hw->hw_next = EHCI_LIST_END(ehci); in end_unlink_intr()
713 qh_completions(ehci, qh); in end_unlink_intr()
716 if (!list_empty(&qh->qtd_list) && ehci->rh_state == EHCI_RH_RUNNING) { in end_unlink_intr()
717 rc = qh_schedule(ehci, qh); in end_unlink_intr()
719 qh_refresh(ehci, qh); in end_unlink_intr()
720 qh_link_periodic(ehci, qh); in end_unlink_intr()
730 ehci_err(ehci, "can't reschedule qh %p, err %d\n", in end_unlink_intr()
736 --ehci->intr_count; in end_unlink_intr()
737 disable_periodic(ehci); in end_unlink_intr()
743 struct ehci_hcd *ehci, in check_period() argument
756 usecs = ehci->uframe_periodic_max - usecs; in check_period()
760 if (ehci->bandwidth[uframe] > usecs) in check_period()
769 struct ehci_hcd *ehci, in check_intr_schedule() argument
783 if (!check_period(ehci, frame, uframe, qh->ps.bw_uperiod, qh->ps.usecs)) in check_intr_schedule()
792 if (tt_available(ehci, &qh->ps, tt, frame, uframe)) { in check_intr_schedule()
797 if (!check_period(ehci, frame, i, in check_intr_schedule()
819 if (tt_no_collision(ehci, qh->ps.bw_period, qh->ps.udev, frame, mask)) { in check_intr_schedule()
820 if (!check_period(ehci, frame, uframe + qh->gap_uf + 1, in check_intr_schedule()
823 if (!check_period(ehci, frame, uframe + qh->gap_uf, in check_intr_schedule()
836 static int qh_schedule(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_schedule() argument
844 hw->hw_next = EHCI_LIST_END(ehci); in qh_schedule()
848 ehci_dbg(ehci, "reused qh %p schedule\n", qh); in qh_schedule()
859 compute_tt_budget(ehci->tt_budget, tt); in qh_schedule()
870 frame = ++ehci->random_frame & (qh->ps.bw_period - 1); in qh_schedule()
872 status = check_intr_schedule(ehci, in qh_schedule()
881 status = check_intr_schedule(ehci, 0, 0, qh, &c_mask, tt); in qh_schedule()
887 qh->ps.phase = (qh->ps.period ? ehci->random_frame & in qh_schedule()
896 hw->hw_info2 &= cpu_to_hc32(ehci, ~(QH_CMASK | QH_SMASK)); in qh_schedule()
897 hw->hw_info2 |= cpu_to_hc32(ehci, qh->ps.cs_mask); in qh_schedule()
898 reserve_release_intr_bandwidth(ehci, qh, 1); in qh_schedule()
905 struct ehci_hcd *ehci, in intr_submit() argument
919 spin_lock_irqsave(&ehci->lock, flags); in intr_submit()
921 if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { in intr_submit()
925 status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); in intr_submit()
931 qh = qh_append_tds(ehci, urb, &empty, epnum, &urb->ep->hcpriv); in intr_submit()
937 status = qh_schedule(ehci, qh); in intr_submit()
943 qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); in intr_submit()
948 qh_refresh(ehci, qh); in intr_submit()
949 qh_link_periodic(ehci, qh); in intr_submit()
952 cancel_unlink_wait_intr(ehci, qh); in intr_submit()
956 ehci_to_hcd(ehci)->self.bandwidth_int_reqs++; in intr_submit()
960 usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); in intr_submit()
962 spin_unlock_irqrestore(&ehci->lock, flags); in intr_submit()
964 qtd_list_free(ehci, urb, qtd_list); in intr_submit()
969 static void scan_intr(struct ehci_hcd *ehci) in scan_intr() argument
973 list_for_each_entry_safe(qh, ehci->qh_scan_next, &ehci->intr_qh_list, in scan_intr()
982 * drops the lock. That's why ehci->qh_scan_next in scan_intr()
984 * gets unlinked then ehci->qh_scan_next is adjusted in scan_intr()
987 temp = qh_completions(ehci, qh); in scan_intr()
989 start_unlink_intr(ehci, qh); in scan_intr()
992 start_unlink_intr_wait(ehci, qh); in scan_intr()
1018 struct ehci_hcd *ehci, in iso_stream_init() argument
1049 stream->buf0 = cpu_to_hc32(ehci, (epnum << 8) | dev->devnum); in iso_stream_init()
1050 stream->buf1 = cpu_to_hc32(ehci, buf1); in iso_stream_init()
1051 stream->buf2 = cpu_to_hc32(ehci, multi); in iso_stream_init()
1076 if (!ehci_is_TDI(ehci) in iso_stream_init()
1078 ehci_to_hcd(ehci)->self.root_hub)) in iso_stream_init()
1115 stream->address = cpu_to_hc32(ehci, addr); in iso_stream_init()
1126 iso_stream_find(struct ehci_hcd *ehci, struct urb *urb) in iso_stream_find() argument
1139 spin_lock_irqsave(&ehci->lock, flags); in iso_stream_find()
1146 iso_stream_init(ehci, stream, urb); in iso_stream_find()
1151 ehci_dbg(ehci, "dev %s ep%d%s, not iso??\n", in iso_stream_find()
1157 spin_unlock_irqrestore(&ehci->lock, flags); in iso_stream_find()
1179 struct ehci_hcd *ehci, in itd_sched_init() argument
1209 uframe->transaction = cpu_to_hc32(ehci, trans); in itd_sched_init()
1227 /* caller must hold ehci->lock! */ in iso_sched_free()
1235 struct ehci_hcd *ehci, in itd_urb_transaction() argument
1251 itd_sched_init(ehci, sched, stream, urb); in itd_urb_transaction()
1259 spin_lock_irqsave(&ehci->lock, flags); in itd_urb_transaction()
1269 if (itd->frame == ehci->now_frame) in itd_urb_transaction()
1275 spin_unlock_irqrestore(&ehci->lock, flags); in itd_urb_transaction()
1276 itd = dma_pool_alloc(ehci->itd_pool, mem_flags, in itd_urb_transaction()
1278 spin_lock_irqsave(&ehci->lock, flags); in itd_urb_transaction()
1281 spin_unlock_irqrestore(&ehci->lock, flags); in itd_urb_transaction()
1291 spin_unlock_irqrestore(&ehci->lock, flags); in itd_urb_transaction()
1301 static void reserve_release_iso_bandwidth(struct ehci_hcd *ehci, in reserve_release_iso_bandwidth() argument
1316 bandwidth_dbg(ehci, sign, "iso", &stream->ps); in reserve_release_iso_bandwidth()
1327 ehci->bandwidth[i] += usecs; in reserve_release_iso_bandwidth()
1339 ehci->bandwidth[i+j] += usecs; in reserve_release_iso_bandwidth()
1341 ehci->bandwidth[i+j] += c_usecs; in reserve_release_iso_bandwidth()
1365 struct ehci_hcd *ehci, in itd_slot_ok() argument
1373 usecs = ehci->uframe_periodic_max - stream->ps.usecs; in itd_slot_ok()
1377 if (ehci->bandwidth[uframe] > usecs) in itd_slot_ok()
1385 struct ehci_hcd *ehci, in sitd_slot_ok() argument
1414 if (!tt_available(ehci, &stream->ps, tt, frame, uf)) in sitd_slot_ok()
1420 if (!tt_no_collision(ehci, stream->ps.bw_period, in sitd_slot_ok()
1431 max_used = ehci->uframe_periodic_max - stream->ps.usecs; in sitd_slot_ok()
1433 if (ehci->bandwidth[uf] > max_used) in sitd_slot_ok()
1439 max_used = ehci->uframe_periodic_max - in sitd_slot_ok()
1446 if (ehci->bandwidth[uf+i] > max_used) in sitd_slot_ok()
1455 stream->splits = cpu_to_hc32(ehci, stream->ps.cs_mask); in sitd_slot_ok()
1464 * Also avoid queue depths of less than ehci's worst irq latency (affected
1472 struct ehci_hcd *ehci, in iso_stream_schedule() argument
1480 unsigned mod = ehci->periodic_size << 3; in iso_stream_schedule()
1492 ehci_to_hcd(ehci), urb->ep))) { in iso_stream_schedule()
1503 compute_tt_budget(ehci->tt_budget, tt); in iso_stream_schedule()
1505 start = ((-(++ehci->random_frame)) << 3) & (period - 1); in iso_stream_schedule()
1518 if (itd_slot_ok(ehci, stream, start)) in iso_stream_schedule()
1523 if (sitd_slot_ok(ehci, stream, start, in iso_stream_schedule()
1531 ehci_dbg(ehci, "iso sched full %p", urb); in iso_stream_schedule()
1540 reserve_release_iso_bandwidth(ehci, stream, 1); in iso_stream_schedule()
1552 now = ehci_read_frame_index(ehci) & (mod - 1); in iso_stream_schedule()
1555 if (ehci->i_thresh) in iso_stream_schedule()
1556 next = now + ehci->i_thresh; /* uframe cache */ in iso_stream_schedule()
1561 if (ehci->isoc_count == 0) in iso_stream_schedule()
1562 ehci->last_iso_frame = now >> 3; in iso_stream_schedule()
1565 * Use ehci->last_iso_frame as the base. There can't be any in iso_stream_schedule()
1568 base = ehci->last_iso_frame << 3; in iso_stream_schedule()
1585 ehci_dbg(ehci, "request %p would overflow (%u-%u < %u mod %u)\n", in iso_stream_schedule()
1614 ehci_dbg(ehci, "iso underrun %p (%u+%u < %u) [%u]\n", in iso_stream_schedule()
1641 ehci_dbg(ehci, "request %p would overflow (%u+%u >= %u)\n", in iso_stream_schedule()
1665 itd_init(struct ehci_hcd *ehci, struct ehci_iso_stream *stream, in itd_init() argument
1671 itd->hw_next = EHCI_LIST_END(ehci); in itd_init()
1684 struct ehci_hcd *ehci, in itd_patch() argument
1700 itd->hw_transaction[uframe] |= cpu_to_hc32(ehci, pg << 12); in itd_patch()
1701 itd->hw_bufp[pg] |= cpu_to_hc32(ehci, uf->bufp & ~(u32)0); in itd_patch()
1702 itd->hw_bufp_hi[pg] |= cpu_to_hc32(ehci, (u32)(uf->bufp >> 32)); in itd_patch()
1709 itd->hw_bufp[pg] |= cpu_to_hc32(ehci, bufp & ~(u32)0); in itd_patch()
1710 itd->hw_bufp_hi[pg] |= cpu_to_hc32(ehci, (u32)(bufp >> 32)); in itd_patch()
1715 itd_link(struct ehci_hcd *ehci, unsigned frame, struct ehci_itd *itd) in itd_link() argument
1717 union ehci_shadow *prev = &ehci->pshadow[frame]; in itd_link()
1718 __hc32 *hw_p = &ehci->periodic[frame]; in itd_link()
1724 type = Q_NEXT_TYPE(ehci, *hw_p); in itd_link()
1725 if (type == cpu_to_hc32(ehci, Q_TYPE_QH)) in itd_link()
1727 prev = periodic_next_shadow(ehci, prev, type); in itd_link()
1728 hw_p = shadow_next_periodic(ehci, &here, type); in itd_link()
1737 *hw_p = cpu_to_hc32(ehci, itd->itd_dma | Q_TYPE_ITD); in itd_link()
1742 struct ehci_hcd *ehci, in itd_link_urb() argument
1756 ehci_to_hcd(ehci)->self.bandwidth_allocated in itd_link_urb()
1759 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) { in itd_link_urb()
1760 if (ehci->amd_pll_fix == 1) in itd_link_urb()
1764 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; in itd_link_urb()
1780 itd_init(ehci, stream, itd); in itd_link_urb()
1786 itd_patch(ehci, itd, iso_sched, packet, uframe); in itd_link_urb()
1795 itd_link(ehci, frame & (ehci->periodic_size - 1), itd); in itd_link_urb()
1805 ++ehci->isoc_count; in itd_link_urb()
1806 enable_periodic(ehci); in itd_link_urb()
1821 static bool itd_complete(struct ehci_hcd *ehci, struct ehci_itd *itd) in itd_complete() argument
1838 t = hc32_to_cpup(ehci, &itd->hw_transaction[uframe]); in itd_complete()
1879 ehci_urb_done(ehci, urb, 0); in itd_complete()
1883 --ehci->isoc_count; in itd_complete()
1884 disable_periodic(ehci); in itd_complete()
1886 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; in itd_complete()
1887 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) { in itd_complete()
1888 if (ehci->amd_pll_fix == 1) in itd_complete()
1893 ehci_to_hcd(ehci)->self.bandwidth_allocated in itd_complete()
1905 &ehci->cached_itd_list); in itd_complete()
1906 start_free_itds(ehci); in itd_complete()
1914 static int itd_submit(struct ehci_hcd *ehci, struct urb *urb, in itd_submit() argument
1922 stream = iso_stream_find(ehci, urb); in itd_submit()
1924 ehci_dbg(ehci, "can't get iso stream\n"); in itd_submit()
1928 ehci_dbg(ehci, "can't change iso interval %d --> %d\n", in itd_submit()
1934 ehci_dbg(ehci, in itd_submit()
1945 status = itd_urb_transaction(stream, ehci, urb, mem_flags); in itd_submit()
1947 ehci_dbg(ehci, "can't init itds\n"); in itd_submit()
1952 spin_lock_irqsave(&ehci->lock, flags); in itd_submit()
1953 if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { in itd_submit()
1957 status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); in itd_submit()
1960 status = iso_stream_schedule(ehci, urb, stream); in itd_submit()
1962 itd_link_urb(ehci, urb, ehci->periodic_size << 3, stream); in itd_submit()
1965 ehci_urb_done(ehci, urb, 0); in itd_submit()
1967 usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); in itd_submit()
1970 spin_unlock_irqrestore(&ehci->lock, flags); in itd_submit()
1984 struct ehci_hcd *ehci, in sitd_sched_init() argument
2013 packet->transaction = cpu_to_hc32(ehci, trans); in sitd_sched_init()
2034 struct ehci_hcd *ehci, in sitd_urb_transaction() argument
2049 sitd_sched_init(ehci, iso_sched, stream, urb); in sitd_urb_transaction()
2052 spin_lock_irqsave(&ehci->lock, flags); in sitd_urb_transaction()
2067 if (sitd->frame == ehci->now_frame) in sitd_urb_transaction()
2073 spin_unlock_irqrestore(&ehci->lock, flags); in sitd_urb_transaction()
2074 sitd = dma_pool_alloc(ehci->sitd_pool, mem_flags, in sitd_urb_transaction()
2076 spin_lock_irqsave(&ehci->lock, flags); in sitd_urb_transaction()
2079 spin_unlock_irqrestore(&ehci->lock, flags); in sitd_urb_transaction()
2094 spin_unlock_irqrestore(&ehci->lock, flags); in sitd_urb_transaction()
2102 struct ehci_hcd *ehci, in sitd_patch() argument
2112 sitd->hw_next = EHCI_LIST_END(ehci); in sitd_patch()
2116 sitd->hw_backpointer = EHCI_LIST_END(ehci); in sitd_patch()
2119 sitd->hw_buf[0] = cpu_to_hc32(ehci, bufp); in sitd_patch()
2120 sitd->hw_buf_hi[0] = cpu_to_hc32(ehci, bufp >> 32); in sitd_patch()
2122 sitd->hw_buf[1] = cpu_to_hc32(ehci, uf->buf1); in sitd_patch()
2125 sitd->hw_buf_hi[1] = cpu_to_hc32(ehci, bufp >> 32); in sitd_patch()
2130 sitd_link(struct ehci_hcd *ehci, unsigned frame, struct ehci_sitd *sitd) in sitd_link() argument
2133 sitd->sitd_next = ehci->pshadow[frame]; in sitd_link()
2134 sitd->hw_next = ehci->periodic[frame]; in sitd_link()
2135 ehci->pshadow[frame].sitd = sitd; in sitd_link()
2138 ehci->periodic[frame] = cpu_to_hc32(ehci, sitd->sitd_dma | Q_TYPE_SITD); in sitd_link()
2143 struct ehci_hcd *ehci, in sitd_link_urb() argument
2158 ehci_to_hcd(ehci)->self.bandwidth_allocated in sitd_link_urb()
2161 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) { in sitd_link_urb()
2162 if (ehci->amd_pll_fix == 1) in sitd_link_urb()
2166 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; in sitd_link_urb()
2184 sitd_patch(ehci, stream, sitd, sched, packet); in sitd_link_urb()
2185 sitd_link(ehci, (next_uframe >> 3) & (ehci->periodic_size - 1), in sitd_link_urb()
2196 ++ehci->isoc_count; in sitd_link_urb()
2197 enable_periodic(ehci); in sitd_link_urb()
2215 static bool sitd_complete(struct ehci_hcd *ehci, struct ehci_sitd *sitd) in sitd_complete() argument
2226 t = hc32_to_cpup(ehci, &sitd->hw_results); in sitd_complete()
2259 ehci_urb_done(ehci, urb, 0); in sitd_complete()
2263 --ehci->isoc_count; in sitd_complete()
2264 disable_periodic(ehci); in sitd_complete()
2266 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; in sitd_complete()
2267 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) { in sitd_complete()
2268 if (ehci->amd_pll_fix == 1) in sitd_complete()
2273 ehci_to_hcd(ehci)->self.bandwidth_allocated in sitd_complete()
2285 &ehci->cached_sitd_list); in sitd_complete()
2286 start_free_itds(ehci); in sitd_complete()
2293 static int sitd_submit(struct ehci_hcd *ehci, struct urb *urb, in sitd_submit() argument
2301 stream = iso_stream_find(ehci, urb); in sitd_submit()
2303 ehci_dbg(ehci, "can't get iso stream\n"); in sitd_submit()
2307 ehci_dbg(ehci, "can't change iso interval %d --> %d\n", in sitd_submit()
2313 ehci_dbg(ehci, in sitd_submit()
2322 status = sitd_urb_transaction(stream, ehci, urb, mem_flags); in sitd_submit()
2324 ehci_dbg(ehci, "can't init sitds\n"); in sitd_submit()
2329 spin_lock_irqsave(&ehci->lock, flags); in sitd_submit()
2330 if (unlikely(!HCD_HW_ACCESSIBLE(ehci_to_hcd(ehci)))) { in sitd_submit()
2334 status = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb); in sitd_submit()
2337 status = iso_stream_schedule(ehci, urb, stream); in sitd_submit()
2339 sitd_link_urb(ehci, urb, ehci->periodic_size << 3, stream); in sitd_submit()
2342 ehci_urb_done(ehci, urb, 0); in sitd_submit()
2344 usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); in sitd_submit()
2347 spin_unlock_irqrestore(&ehci->lock, flags); in sitd_submit()
2354 static void scan_isoc(struct ehci_hcd *ehci) in scan_isoc() argument
2357 unsigned fmask = ehci->periodic_size - 1; in scan_isoc()
2367 if (ehci->rh_state >= EHCI_RH_RUNNING) { in scan_isoc()
2368 uf = ehci_read_frame_index(ehci); in scan_isoc()
2372 now_frame = (ehci->last_iso_frame - 1) & fmask; in scan_isoc()
2375 ehci->now_frame = now_frame; in scan_isoc()
2377 frame = ehci->last_iso_frame; in scan_isoc()
2381 q_p = &ehci->pshadow[frame]; in scan_isoc()
2382 hw_p = &ehci->periodic[frame]; in scan_isoc()
2384 type = Q_NEXT_TYPE(ehci, *hw_p); in scan_isoc()
2388 switch (hc32_to_cpu(ehci, type)) { in scan_isoc()
2400 ITD_ACTIVE(ehci)) in scan_isoc()
2406 type = Q_NEXT_TYPE(ehci, in scan_isoc()
2420 if (!ehci->use_dummy_qh || in scan_isoc()
2421 q.itd->hw_next != EHCI_LIST_END(ehci)) in scan_isoc()
2424 *hw_p = cpu_to_hc32(ehci, ehci->dummy->qh_dma); in scan_isoc()
2425 type = Q_NEXT_TYPE(ehci, q.itd->hw_next); in scan_isoc()
2427 modified = itd_complete(ehci, q.itd); in scan_isoc()
2440 && (q.sitd->hw_results & SITD_ACTIVE(ehci))) { in scan_isoc()
2444 type = Q_NEXT_TYPE(ehci, q.sitd->hw_next); in scan_isoc()
2455 if (!ehci->use_dummy_qh || in scan_isoc()
2456 q.sitd->hw_next != EHCI_LIST_END(ehci)) in scan_isoc()
2459 *hw_p = cpu_to_hc32(ehci, ehci->dummy->qh_dma); in scan_isoc()
2460 type = Q_NEXT_TYPE(ehci, q.sitd->hw_next); in scan_isoc()
2462 modified = sitd_complete(ehci, q.sitd); in scan_isoc()
2466 ehci_dbg(ehci, "corrupt type %d frame %d shadow %p\n", in scan_isoc()
2478 if (unlikely(modified && ehci->isoc_count > 0)) in scan_isoc()
2487 ehci->last_iso_frame = frame; in scan_isoc()