Lines Matching refs:qh
37 return &periodic->qh->qh_next; in periodic_next_shadow()
55 return &periodic->qh->hw->hw_next; in shadow_next_periodic()
207 struct ehci_qh *qh, int sign) in reserve_release_intr_bandwidth() argument
211 int usecs = qh->ps.usecs; in reserve_release_intr_bandwidth()
212 int c_usecs = qh->ps.c_usecs; in reserve_release_intr_bandwidth()
213 int tt_usecs = qh->ps.tt_usecs; in reserve_release_intr_bandwidth()
216 if (qh->ps.phase == NO_FRAME) /* Bandwidth wasn't reserved */ in reserve_release_intr_bandwidth()
218 start_uf = qh->ps.bw_phase << 3; in reserve_release_intr_bandwidth()
220 bandwidth_dbg(ehci, sign, "intr", &qh->ps); in reserve_release_intr_bandwidth()
229 for (i = start_uf + qh->ps.phase_uf; i < EHCI_BANDWIDTH_SIZE; in reserve_release_intr_bandwidth()
230 i += qh->ps.bw_uperiod) in reserve_release_intr_bandwidth()
234 if (qh->ps.c_usecs) { in reserve_release_intr_bandwidth()
237 i += qh->ps.bw_uperiod) { in reserve_release_intr_bandwidth()
239 if (qh->ps.cs_mask & m) in reserve_release_intr_bandwidth()
253 tt = find_tt(qh->ps.udev); in reserve_release_intr_bandwidth()
255 list_add_tail(&qh->ps.ps_list, &tt->ps_list); in reserve_release_intr_bandwidth()
257 list_del(&qh->ps.ps_list); in reserve_release_intr_bandwidth()
260 i += qh->ps.bw_period) in reserve_release_intr_bandwidth()
442 hw = here.qh->hw; in tt_no_collision()
443 if (same_tt(dev, here.qh->ps.udev)) { in tt_no_collision()
454 here = here.qh->qh_next; in tt_no_collision()
520 static void qh_link_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_link_periodic() argument
523 unsigned period = qh->ps.period; in qh_link_periodic()
525 dev_dbg(&qh->ps.udev->dev, in qh_link_periodic()
527 period, hc32_to_cpup(ehci, &qh->hw->hw_info2) in qh_link_periodic()
529 qh, qh->ps.phase, qh->ps.usecs, qh->ps.c_usecs); in qh_link_periodic()
535 for (i = qh->ps.phase; i < ehci->periodic_size; i += period) { in qh_link_periodic()
554 while (here.ptr && qh != here.qh) { in qh_link_periodic()
555 if (qh->ps.period > here.qh->ps.period) in qh_link_periodic()
557 prev = &here.qh->qh_next; in qh_link_periodic()
558 hw_p = &here.qh->hw->hw_next; in qh_link_periodic()
562 if (qh != here.qh) { in qh_link_periodic()
563 qh->qh_next = here; in qh_link_periodic()
564 if (here.qh) in qh_link_periodic()
565 qh->hw->hw_next = *hw_p; in qh_link_periodic()
567 prev->qh = qh; in qh_link_periodic()
568 *hw_p = QH_NEXT(ehci, qh->qh_dma); in qh_link_periodic()
571 qh->qh_state = QH_STATE_LINKED; in qh_link_periodic()
572 qh->xacterrs = 0; in qh_link_periodic()
573 qh->unlink_reason = 0; in qh_link_periodic()
576 ehci_to_hcd(ehci)->self.bandwidth_allocated += qh->ps.bw_period in qh_link_periodic()
577 ? ((qh->ps.usecs + qh->ps.c_usecs) / qh->ps.bw_period) in qh_link_periodic()
578 : (qh->ps.usecs * 8); in qh_link_periodic()
580 list_add(&qh->intr_node, &ehci->intr_qh_list); in qh_link_periodic()
587 static void qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_unlink_periodic() argument
608 period = qh->ps.period ? : 1; in qh_unlink_periodic()
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()
615 ? ((qh->ps.usecs + qh->ps.c_usecs) / qh->ps.bw_period) in qh_unlink_periodic()
616 : (qh->ps.usecs * 8); in qh_unlink_periodic()
618 dev_dbg(&qh->ps.udev->dev, in qh_unlink_periodic()
620 qh->ps.period, in qh_unlink_periodic()
621 hc32_to_cpup(ehci, &qh->hw->hw_info2) & (QH_CMASK | QH_SMASK), in qh_unlink_periodic()
622 qh, qh->ps.phase, qh->ps.usecs, qh->ps.c_usecs); in qh_unlink_periodic()
625 qh->qh_state = QH_STATE_UNLINK; in qh_unlink_periodic()
626 qh->qh_next.ptr = NULL; 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()
631 list_del(&qh->intr_node); 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
636 if (qh->qh_state != QH_STATE_LINKED || in cancel_unlink_wait_intr()
637 list_empty(&qh->unlink_node)) in cancel_unlink_wait_intr()
640 list_del_init(&qh->unlink_node); in cancel_unlink_wait_intr()
648 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in start_unlink_intr() argument
651 if (qh->qh_state != QH_STATE_LINKED) in start_unlink_intr()
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()
676 else if (ehci->intr_unlink.next == &qh->unlink_node) { in start_unlink_intr()
688 struct ehci_qh *qh) 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()
697 else if (ehci->intr_unlink_wait.next == &qh->unlink_node) { in start_unlink_intr_wait()
703 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in end_unlink_intr() argument
705 struct ehci_qh_hw *hw = qh->hw; in end_unlink_intr()
708 qh->qh_state = QH_STATE_IDLE; in end_unlink_intr()
711 if (!list_empty(&qh->qtd_list)) 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()
730 qh, rc); in end_unlink_intr()
771 struct ehci_qh *qh, in check_intr_schedule() argument
779 if (qh->ps.c_usecs && uframe >= 6) /* FSTN territory? */ in check_intr_schedule()
782 if (!check_period(ehci, frame, uframe, qh->ps.bw_uperiod, qh->ps.usecs)) in check_intr_schedule()
784 if (!qh->ps.c_usecs) { in check_intr_schedule()
791 if (tt_available(ehci, &qh->ps, tt, frame, uframe)) { in check_intr_schedule()
797 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
814 mask = 0x03 << (uframe + qh->gap_uf); 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()
820 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
822 if (!check_period(ehci, frame, uframe + qh->gap_uf, in check_intr_schedule()
823 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
835 static int qh_schedule(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_schedule() argument
840 struct ehci_qh_hw *hw = qh->hw; in qh_schedule()
846 if (qh->ps.phase != NO_FRAME) { in qh_schedule()
847 ehci_dbg(ehci, "reused qh %p schedule\n", qh); in qh_schedule()
853 tt = find_tt(qh->ps.udev); in qh_schedule()
864 if (qh->ps.bw_period) { in qh_schedule()
868 for (i = qh->ps.bw_period; i > 0; --i) { in qh_schedule()
869 frame = ++ehci->random_frame & (qh->ps.bw_period - 1); in qh_schedule()
872 frame, uframe, qh, &c_mask, tt); 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()
887 (qh->ps.period - 1) : 0); in qh_schedule()
888 qh->ps.bw_phase = qh->ps.phase & (qh->ps.bw_period - 1); in qh_schedule()
889 qh->ps.phase_uf = uframe; in qh_schedule()
890 qh->ps.cs_mask = qh->ps.period ? 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()
911 struct ehci_qh *qh; in intr_submit() local
930 qh = qh_append_tds(ehci, urb, &empty, epnum, &urb->ep->hcpriv); in intr_submit()
931 if (qh == NULL) { in intr_submit()
935 if (qh->qh_state == QH_STATE_IDLE) { 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()
943 BUG_ON(qh == NULL); in intr_submit()
946 if (qh->qh_state == QH_STATE_IDLE) { 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()
970 struct ehci_qh *qh; in scan_intr() local
972 list_for_each_entry_safe(qh, ehci->qh_scan_next, &ehci->intr_qh_list, in scan_intr()
976 if (!list_empty(&qh->qtd_list)) { in scan_intr()
986 temp = qh_completions(ehci, qh); in scan_intr()
988 start_unlink_intr(ehci, qh); in scan_intr()
989 else if (unlikely(list_empty(&qh->qtd_list) && in scan_intr()
990 qh->qh_state == QH_STATE_LINKED)) in scan_intr()
991 start_unlink_intr_wait(ehci, qh); in scan_intr()