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()
521 static void qh_link_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_link_periodic() argument
524 unsigned period = qh->ps.period; in qh_link_periodic()
526 dev_dbg(&qh->ps.udev->dev, in qh_link_periodic()
528 period, hc32_to_cpup(ehci, &qh->hw->hw_info2) in qh_link_periodic()
530 qh, qh->ps.phase, qh->ps.usecs, qh->ps.c_usecs); in qh_link_periodic()
536 for (i = qh->ps.phase; i < ehci->periodic_size; i += period) { in qh_link_periodic()
555 while (here.ptr && qh != here.qh) { in qh_link_periodic()
556 if (qh->ps.period > here.qh->ps.period) in qh_link_periodic()
558 prev = &here.qh->qh_next; in qh_link_periodic()
559 hw_p = &here.qh->hw->hw_next; in qh_link_periodic()
563 if (qh != here.qh) { in qh_link_periodic()
564 qh->qh_next = here; in qh_link_periodic()
565 if (here.qh) in qh_link_periodic()
566 qh->hw->hw_next = *hw_p; in qh_link_periodic()
568 prev->qh = qh; in qh_link_periodic()
569 *hw_p = QH_NEXT(ehci, qh->qh_dma); in qh_link_periodic()
572 qh->qh_state = QH_STATE_LINKED; in qh_link_periodic()
573 qh->xacterrs = 0; in qh_link_periodic()
574 qh->unlink_reason = 0; in qh_link_periodic()
577 ehci_to_hcd(ehci)->self.bandwidth_allocated += qh->ps.bw_period in qh_link_periodic()
578 ? ((qh->ps.usecs + qh->ps.c_usecs) / qh->ps.bw_period) in qh_link_periodic()
579 : (qh->ps.usecs * 8); in qh_link_periodic()
581 list_add(&qh->intr_node, &ehci->intr_qh_list); in qh_link_periodic()
588 static void qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_unlink_periodic() argument
609 period = qh->ps.period ? : 1; 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()
616 ? ((qh->ps.usecs + qh->ps.c_usecs) / qh->ps.bw_period) in qh_unlink_periodic()
617 : (qh->ps.usecs * 8); in qh_unlink_periodic()
619 dev_dbg(&qh->ps.udev->dev, in qh_unlink_periodic()
621 qh->ps.period, in qh_unlink_periodic()
622 hc32_to_cpup(ehci, &qh->hw->hw_info2) & (QH_CMASK | QH_SMASK), in qh_unlink_periodic()
623 qh, qh->ps.phase, qh->ps.usecs, qh->ps.c_usecs); in qh_unlink_periodic()
626 qh->qh_state = QH_STATE_UNLINK; in qh_unlink_periodic()
627 qh->qh_next.ptr = NULL; 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()
632 list_del(&qh->intr_node); 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
637 if (qh->qh_state != QH_STATE_LINKED || in cancel_unlink_wait_intr()
638 list_empty(&qh->unlink_node)) in cancel_unlink_wait_intr()
641 list_del_init(&qh->unlink_node); in cancel_unlink_wait_intr()
649 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in start_unlink_intr() argument
652 if (qh->qh_state != QH_STATE_LINKED) in start_unlink_intr()
656 cancel_unlink_wait_intr(ehci, qh); in start_unlink_intr()
658 qh_unlink_periodic(ehci, qh); 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()
677 else if (ehci->intr_unlink.next == &qh->unlink_node) { in start_unlink_intr()
689 struct ehci_qh *qh) 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()
698 else if (ehci->intr_unlink_wait.next == &qh->unlink_node) { in start_unlink_intr_wait()
704 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in end_unlink_intr() argument
706 struct ehci_qh_hw *hw = qh->hw; in end_unlink_intr()
709 qh->qh_state = QH_STATE_IDLE; in end_unlink_intr()
712 if (!list_empty(&qh->qtd_list)) 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()
731 qh, rc); in end_unlink_intr()
772 struct ehci_qh *qh, in check_intr_schedule() argument
780 if (qh->ps.c_usecs && uframe >= 6) /* FSTN territory? */ in check_intr_schedule()
783 if (!check_period(ehci, frame, uframe, qh->ps.bw_uperiod, qh->ps.usecs)) in check_intr_schedule()
785 if (!qh->ps.c_usecs) { in check_intr_schedule()
792 if (tt_available(ehci, &qh->ps, tt, frame, uframe)) { in check_intr_schedule()
798 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
815 mask = 0x03 << (uframe + qh->gap_uf); 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()
821 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
823 if (!check_period(ehci, frame, uframe + qh->gap_uf, in check_intr_schedule()
824 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
836 static int qh_schedule(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_schedule() argument
841 struct ehci_qh_hw *hw = qh->hw; in qh_schedule()
847 if (qh->ps.phase != NO_FRAME) { in qh_schedule()
848 ehci_dbg(ehci, "reused qh %p schedule\n", qh); in qh_schedule()
854 tt = find_tt(qh->ps.udev); in qh_schedule()
865 if (qh->ps.bw_period) { in qh_schedule()
869 for (i = qh->ps.bw_period; i > 0; --i) { in qh_schedule()
870 frame = ++ehci->random_frame & (qh->ps.bw_period - 1); in qh_schedule()
873 frame, uframe, qh, &c_mask, tt); 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()
888 (qh->ps.period - 1) : 0); in qh_schedule()
889 qh->ps.bw_phase = qh->ps.phase & (qh->ps.bw_period - 1); in qh_schedule()
890 qh->ps.phase_uf = uframe; in qh_schedule()
891 qh->ps.cs_mask = qh->ps.period ? 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()
912 struct ehci_qh *qh; in intr_submit() local
931 qh = qh_append_tds(ehci, urb, &empty, epnum, &urb->ep->hcpriv); in intr_submit()
932 if (qh == NULL) { in intr_submit()
936 if (qh->qh_state == QH_STATE_IDLE) { 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()
944 BUG_ON(qh == NULL); in intr_submit()
947 if (qh->qh_state == QH_STATE_IDLE) { 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()
971 struct ehci_qh *qh; in scan_intr() local
973 list_for_each_entry_safe(qh, ehci->qh_scan_next, &ehci->intr_qh_list, in scan_intr()
977 if (!list_empty(&qh->qtd_list)) { in scan_intr()
987 temp = qh_completions(ehci, qh); in scan_intr()
989 start_unlink_intr(ehci, qh); in scan_intr()
990 else if (unlikely(list_empty(&qh->qtd_list) && in scan_intr()
991 qh->qh_state == QH_STATE_LINKED)) in scan_intr()
992 start_unlink_intr_wait(ehci, qh); in scan_intr()