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()
247 tt = find_tt(qh->ps.udev); in reserve_release_intr_bandwidth()
249 list_add_tail(&qh->ps.ps_list, &tt->ps_list); in reserve_release_intr_bandwidth()
251 list_del(&qh->ps.ps_list); in reserve_release_intr_bandwidth()
254 i += qh->ps.bw_period) in reserve_release_intr_bandwidth()
436 hw = here.qh->hw; in tt_no_collision()
437 if (same_tt(dev, here.qh->ps.udev)) { in tt_no_collision()
448 here = here.qh->qh_next; in tt_no_collision()
514 static void qh_link_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_link_periodic() argument
517 unsigned period = qh->ps.period; in qh_link_periodic()
519 dev_dbg(&qh->ps.udev->dev, in qh_link_periodic()
521 period, hc32_to_cpup(ehci, &qh->hw->hw_info2) in qh_link_periodic()
523 qh, qh->ps.phase, qh->ps.usecs, qh->ps.c_usecs); in qh_link_periodic()
529 for (i = qh->ps.phase; i < ehci->periodic_size; i += period) { in qh_link_periodic()
548 while (here.ptr && qh != here.qh) { in qh_link_periodic()
549 if (qh->ps.period > here.qh->ps.period) in qh_link_periodic()
551 prev = &here.qh->qh_next; in qh_link_periodic()
552 hw_p = &here.qh->hw->hw_next; in qh_link_periodic()
556 if (qh != here.qh) { in qh_link_periodic()
557 qh->qh_next = here; in qh_link_periodic()
558 if (here.qh) in qh_link_periodic()
559 qh->hw->hw_next = *hw_p; in qh_link_periodic()
561 prev->qh = qh; in qh_link_periodic()
562 *hw_p = QH_NEXT(ehci, qh->qh_dma); in qh_link_periodic()
565 qh->qh_state = QH_STATE_LINKED; in qh_link_periodic()
566 qh->xacterrs = 0; in qh_link_periodic()
567 qh->unlink_reason = 0; in qh_link_periodic()
570 ehci_to_hcd(ehci)->self.bandwidth_allocated += qh->ps.bw_period in qh_link_periodic()
571 ? ((qh->ps.usecs + qh->ps.c_usecs) / qh->ps.bw_period) in qh_link_periodic()
572 : (qh->ps.usecs * 8); in qh_link_periodic()
574 list_add(&qh->intr_node, &ehci->intr_qh_list); in qh_link_periodic()
581 static void qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_unlink_periodic() argument
602 period = qh->ps.period ? : 1; in qh_unlink_periodic()
604 for (i = qh->ps.phase; i < ehci->periodic_size; i += period) in qh_unlink_periodic()
605 periodic_unlink(ehci, i, qh); in qh_unlink_periodic()
608 ehci_to_hcd(ehci)->self.bandwidth_allocated -= qh->ps.bw_period in qh_unlink_periodic()
609 ? ((qh->ps.usecs + qh->ps.c_usecs) / qh->ps.bw_period) in qh_unlink_periodic()
610 : (qh->ps.usecs * 8); in qh_unlink_periodic()
612 dev_dbg(&qh->ps.udev->dev, in qh_unlink_periodic()
614 qh->ps.period, in qh_unlink_periodic()
615 hc32_to_cpup(ehci, &qh->hw->hw_info2) & (QH_CMASK | QH_SMASK), in qh_unlink_periodic()
616 qh, qh->ps.phase, qh->ps.usecs, qh->ps.c_usecs); in qh_unlink_periodic()
619 qh->qh_state = QH_STATE_UNLINK; in qh_unlink_periodic()
620 qh->qh_next.ptr = NULL; in qh_unlink_periodic()
622 if (ehci->qh_scan_next == qh) in qh_unlink_periodic()
623 ehci->qh_scan_next = list_entry(qh->intr_node.next, in qh_unlink_periodic()
625 list_del(&qh->intr_node); in qh_unlink_periodic()
628 static void cancel_unlink_wait_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in cancel_unlink_wait_intr() argument
630 if (qh->qh_state != QH_STATE_LINKED || in cancel_unlink_wait_intr()
631 list_empty(&qh->unlink_node)) in cancel_unlink_wait_intr()
634 list_del_init(&qh->unlink_node); in cancel_unlink_wait_intr()
642 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in start_unlink_intr() argument
645 if (qh->qh_state != QH_STATE_LINKED) in start_unlink_intr()
649 cancel_unlink_wait_intr(ehci, qh); in start_unlink_intr()
651 qh_unlink_periodic(ehci, qh); in start_unlink_intr()
661 qh->unlink_cycle = ehci->intr_unlink_cycle; in start_unlink_intr()
664 list_add_tail(&qh->unlink_node, &ehci->intr_unlink); in start_unlink_intr()
670 else if (ehci->intr_unlink.next == &qh->unlink_node) { in start_unlink_intr()
682 struct ehci_qh *qh) in start_unlink_intr_wait() argument
684 qh->unlink_cycle = ehci->intr_unlink_wait_cycle; in start_unlink_intr_wait()
687 list_add_tail(&qh->unlink_node, &ehci->intr_unlink_wait); in start_unlink_intr_wait()
691 else if (ehci->intr_unlink_wait.next == &qh->unlink_node) { in start_unlink_intr_wait()
697 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh) in end_unlink_intr() argument
699 struct ehci_qh_hw *hw = qh->hw; in end_unlink_intr()
702 qh->qh_state = QH_STATE_IDLE; in end_unlink_intr()
705 if (!list_empty(&qh->qtd_list)) in end_unlink_intr()
706 qh_completions(ehci, qh); in end_unlink_intr()
709 if (!list_empty(&qh->qtd_list) && ehci->rh_state == EHCI_RH_RUNNING) { in end_unlink_intr()
710 rc = qh_schedule(ehci, qh); in end_unlink_intr()
712 qh_refresh(ehci, qh); in end_unlink_intr()
713 qh_link_periodic(ehci, qh); in end_unlink_intr()
724 qh, rc); in end_unlink_intr()
765 struct ehci_qh *qh, in check_intr_schedule() argument
773 if (qh->ps.c_usecs && uframe >= 6) /* FSTN territory? */ in check_intr_schedule()
776 if (!check_period(ehci, frame, uframe, qh->ps.bw_uperiod, qh->ps.usecs)) in check_intr_schedule()
778 if (!qh->ps.c_usecs) { in check_intr_schedule()
785 if (tt_available(ehci, &qh->ps, tt, frame, uframe)) { in check_intr_schedule()
791 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
808 mask = 0x03 << (uframe + qh->gap_uf); in check_intr_schedule()
812 if (tt_no_collision(ehci, qh->ps.bw_period, qh->ps.udev, frame, mask)) { in check_intr_schedule()
813 if (!check_period(ehci, frame, uframe + qh->gap_uf + 1, in check_intr_schedule()
814 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
816 if (!check_period(ehci, frame, uframe + qh->gap_uf, in check_intr_schedule()
817 qh->ps.bw_uperiod, qh->ps.c_usecs)) in check_intr_schedule()
829 static int qh_schedule(struct ehci_hcd *ehci, struct ehci_qh *qh) in qh_schedule() argument
834 struct ehci_qh_hw *hw = qh->hw; in qh_schedule()
840 if (qh->ps.phase != NO_FRAME) { in qh_schedule()
841 ehci_dbg(ehci, "reused qh %p schedule\n", qh); in qh_schedule()
847 tt = find_tt(qh->ps.udev); in qh_schedule()
858 if (qh->ps.bw_period) { in qh_schedule()
862 for (i = qh->ps.bw_period; i > 0; --i) { in qh_schedule()
863 frame = ++ehci->random_frame & (qh->ps.bw_period - 1); in qh_schedule()
866 frame, uframe, qh, &c_mask, tt); in qh_schedule()
874 status = check_intr_schedule(ehci, 0, 0, qh, &c_mask, tt); in qh_schedule()
880 qh->ps.phase = (qh->ps.period ? ehci->random_frame & in qh_schedule()
881 (qh->ps.period - 1) : 0); in qh_schedule()
882 qh->ps.bw_phase = qh->ps.phase & (qh->ps.bw_period - 1); in qh_schedule()
883 qh->ps.phase_uf = uframe; in qh_schedule()
884 qh->ps.cs_mask = qh->ps.period ? in qh_schedule()
890 hw->hw_info2 |= cpu_to_hc32(ehci, qh->ps.cs_mask); in qh_schedule()
891 reserve_release_intr_bandwidth(ehci, qh, 1); in qh_schedule()
905 struct ehci_qh *qh; in intr_submit() local
924 qh = qh_append_tds(ehci, urb, &empty, epnum, &urb->ep->hcpriv); in intr_submit()
925 if (qh == NULL) { in intr_submit()
929 if (qh->qh_state == QH_STATE_IDLE) { in intr_submit()
930 status = qh_schedule(ehci, qh); in intr_submit()
936 qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv); in intr_submit()
937 BUG_ON(qh == NULL); in intr_submit()
940 if (qh->qh_state == QH_STATE_IDLE) { in intr_submit()
941 qh_refresh(ehci, qh); in intr_submit()
942 qh_link_periodic(ehci, qh); in intr_submit()
945 cancel_unlink_wait_intr(ehci, qh); in intr_submit()
964 struct ehci_qh *qh; in scan_intr() local
966 list_for_each_entry_safe(qh, ehci->qh_scan_next, &ehci->intr_qh_list, in scan_intr()
970 if (!list_empty(&qh->qtd_list)) { in scan_intr()
980 temp = qh_completions(ehci, qh); in scan_intr()
982 start_unlink_intr(ehci, qh); in scan_intr()
983 else if (unlikely(list_empty(&qh->qtd_list) && in scan_intr()
984 qh->qh_state == QH_STATE_LINKED)) in scan_intr()
985 start_unlink_intr_wait(ehci, qh); in scan_intr()