Lines Matching refs:qh
131 dbg_qh(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
133 struct fotg210_qh_hw *hw = qh->hw;
135 fotg210_dbg(fotg210, "%s qh %p n%08x info %x %x qtd %x\n", label, qh,
353 static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
364 struct fotg210_qh_hw *hw = qh->hw;
370 if (mark == '/') { /* qh_alt_next controls qh advance? */
381 "qh/%p dev%d %cs ep%d %08x %08x(%08x%c %s nak%d)",
382 qh, scratch & 0x007f,
394 list_for_each_entry(td, &qh->qtd_list, qtd_list) {
451 struct fotg210_qh *qh;
465 for (qh = fotg210->async->qh_next.qh; size > 0 && qh;
466 qh = qh->qh_next.qh)
467 qh_lines(fotg210, qh, &next, &size);
473 for (qh = fotg210->async_unlink; size > 0 && qh;
474 qh = qh->unlink_next)
475 qh_lines(fotg210, qh, &next, &size);
484 struct fotg210_qh_hw *hw, struct fotg210_qh *qh, unsigned size)
492 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) {
506 (scratch >> 8) & 0x000f, type, qh->usecs,
507 qh->c_usecs, temp, (scratch >> 16) & 0x7ff);
557 hw = p.qh->hw;
558 temp = scnprintf(next, size, " qh%d-%04x/%p",
559 p.qh->period,
564 p.qh);
567 /* don't repeat what follows this qh */
571 if (p.qh->qh_next.ptr) {
583 p.qh, size);
586 seen[seen_count++].qh = p.qh;
590 p = p.qh->qh_next;
714 temp = scnprintf(next, size, "async unlink qh %p\n",
986 struct fotg210_qh *qh);
987 static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
1202 struct fotg210_qh *qh = fotg210->intr_unlink;
1204 if (!stopped && qh->unlink_cycle == fotg210->intr_unlink_cycle)
1206 fotg210->intr_unlink = qh->unlink_next;
1207 qh->unlink_next = NULL;
1208 end_unlink_intr(fotg210, qh);
1835 static void qh_destroy(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
1838 if (!list_empty(&qh->qtd_list) || qh->qh_next.ptr) {
1839 fotg210_dbg(fotg210, "unused qh not empty!\n");
1842 if (qh->dummy)
1843 fotg210_qtd_free(fotg210, qh->dummy);
1844 dma_pool_free(fotg210->qh_pool, qh->hw, qh->qh_dma);
1845 kfree(qh);
1851 struct fotg210_qh *qh;
1854 qh = kzalloc(sizeof(*qh), GFP_ATOMIC);
1855 if (!qh)
1857 qh->hw = (struct fotg210_qh_hw *)
1859 if (!qh->hw)
1861 qh->qh_dma = dma;
1862 INIT_LIST_HEAD(&qh->qtd_list);
1865 qh->dummy = fotg210_qtd_alloc(fotg210, flags);
1866 if (qh->dummy == NULL) {
1871 return qh;
1873 dma_pool_free(fotg210->qh_pool, qh->hw, qh->qh_dma);
1875 kfree(qh);
1975 * Control, bulk, and interrupt traffic all use "qh" lists. They list "qtd"
1986 * (b) special fields in qh entries or (c) split iso entries. TTs will
2031 struct fotg210_qh *qh, struct fotg210_qtd *qtd)
2033 struct fotg210_qh_hw *hw = qh->hw;
2036 BUG_ON(qh->qh_state != QH_STATE_IDLE);
2049 is_out = qh->is_out;
2051 if (unlikely(!usb_gettoggle(qh->dev, epnum, is_out))) {
2053 usb_settoggle(qh->dev, epnum, is_out, 1);
2060 /* if it weren't for a common silicon quirk (writing the dummy into the qh
2061 * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
2064 static void qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
2068 if (list_empty(&qh->qtd_list))
2069 qtd = qh->dummy;
2071 qtd = list_entry(qh->qtd_list.next,
2080 if (cpu_to_hc32(fotg210, qtd->qtd_dma) == qh->hw->hw_current) {
2081 qh->hw->hw_qtd_next = qtd->hw_next;
2087 qh_update(fotg210, qh, qtd);
2090 static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
2096 struct fotg210_qh *qh = ep->hcpriv;
2100 qh->clearing_tt = 0;
2101 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list)
2103 qh_link_async(fotg210, qh);
2108 struct fotg210_qh *qh, struct urb *urb, u32 token)
2117 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
2128 qh->clearing_tt = 1;
2198 struct fotg210_qh *qh = (struct fotg210_qh *) urb->hcpriv;
2201 if ((qh->hw->hw_info2 & cpu_to_hc32(fotg210, QH_SMASK)) != 0) {
2234 static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
2236 /* Process and free completed qtds for a qh, returning URBs to drivers.
2237 * Chases up to qh->hw_current. Returns number of completions called,
2241 struct fotg210_qh *qh)
2243 struct fotg210_qtd *last, *end = qh->dummy;
2249 struct fotg210_qh_hw *hw = qh->hw;
2251 if (unlikely(list_empty(&qh->qtd_list)))
2256 * they add urbs to this qh's queue or mark them for unlinking.
2260 * It's a bug for qh->qh_state to be anything other than
2264 state = qh->qh_state;
2265 qh->qh_state = QH_STATE_COMPLETING;
2271 qh->needs_rescan = 0;
2278 list_for_each_entry_safe(qtd, tmp, &qh->qtd_list, qtd_list) {
2300 /* hardware copies qtd out of qh overlay */
2311 "detected DataBufferErr for urb %p ep%d%s len %d, qtd %p [qh %p]\n",
2315 urb->transfer_buffer_length, qtd, qh);
2327 ++qh->xacterrs < QH_XACTERR_MAX &&
2333 qh->xacterrs);
2336 * qh overlay (which still contains
2352 /* magic dummy for some short reads; qh won't advance.
2386 /* qh unlinked; token in overlay may be most current */
2396 fotg210_clear_tt_buffer(fotg210, qh, urb,
2431 fotg210_clear_tt_buffer(fotg210, qh,
2439 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) {
2450 qh->xacterrs = 0;
2461 if (unlikely(qh->needs_rescan)) {
2467 * Our caller will start an unlink if qh->needs_rescan is
2472 qh->needs_rescan = 0;
2476 qh->qh_state = state;
2478 /* be sure the hardware's done with the qh before refreshing
2485 qh_refresh(fotg210, qh);
2501 qh->needs_rescan = 1;
2524 /* create a list of filled qtds for this URB; won't link into qh.
2619 /* qh makes control packets use qtd toggle; maybe switch it */
2690 /* Would be best to create all qh's from config descriptors,
2692 * any previous qh and cancel its urbs first; endpoints are
2708 struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
2717 if (!qh)
2718 return qh;
2736 fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", maxp);
2744 * - qh has a polling interval
2749 qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
2751 qh->start = NO_FRAME;
2754 qh->c_usecs = 0;
2755 qh->gap_uf = 0;
2757 qh->period = urb->interval >> 3;
2758 if (qh->period == 0 && urb->interval != 1) {
2764 } else if (qh->period > fotg210->periodic_size) {
2765 qh->period = fotg210->periodic_size;
2766 urb->interval = qh->period << 3;
2772 qh->gap_uf = 1 + usb_calc_bus_time(urb->dev->speed,
2777 qh->c_usecs = qh->usecs + HS_USECS(0);
2778 qh->usecs = HS_USECS(1);
2780 qh->usecs += HS_USECS(1);
2781 qh->c_usecs = HS_USECS(0);
2785 qh->tt_usecs = NS_TO_US(think_time +
2788 qh->period = urb->interval;
2789 if (qh->period > fotg210->periodic_size) {
2790 qh->period = fotg210->periodic_size;
2791 urb->interval = qh->period;
2797 qh->dev = urb->dev;
2861 qh_destroy(fotg210, qh);
2868 qh->qh_state = QH_STATE_IDLE;
2869 hw = qh->hw;
2872 qh->is_out = !is_input;
2874 qh_refresh(fotg210, qh);
2875 return qh;
2897 WARN_ON(fotg210->async->qh_next.qh || fotg210->async_unlink);
2903 /* move qh (and its qtds) onto async queue; maybe enable queue. */
2905 static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
2907 __hc32 dma = QH_NEXT(fotg210, qh->qh_dma);
2911 if (unlikely(qh->clearing_tt))
2914 WARN_ON(qh->qh_state != QH_STATE_IDLE);
2917 qh_refresh(fotg210, qh);
2921 qh->qh_next = head->qh_next;
2922 qh->hw->hw_next = head->hw->hw_next;
2925 head->qh_next.qh = qh;
2928 qh->xacterrs = 0;
2929 qh->qh_state = QH_STATE_LINKED;
2944 struct fotg210_qh *qh = NULL;
2947 qh = (struct fotg210_qh *) *ptr;
2948 if (unlikely(qh == NULL)) {
2950 qh = qh_make(fotg210, urb, GFP_ATOMIC);
2951 *ptr = qh;
2953 if (likely(qh != NULL)) {
2962 /* control qh may need patching ... */
2966 qh->hw->hw_info1 &= ~qh_addr_mask;
2985 dummy = qh->dummy;
2993 list_splice_tail(qtd_list, &qh->qtd_list);
2996 qh->dummy = qtd;
3000 qtd = list_entry(qh->qtd_list.prev,
3008 urb->hcpriv = qh;
3011 return qh;
3019 struct fotg210_qh *qh = NULL;
3030 "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
3048 qh = qh_append_tds(fotg210, urb, qtd_list, epnum, &urb->ep->hcpriv);
3049 if (unlikely(qh == NULL)) {
3058 if (likely(qh->qh_state == QH_STATE_IDLE))
3059 qh_link_async(fotg210, qh);
3062 if (unlikely(qh == NULL))
3068 struct fotg210_qh *qh)
3073 qh->qh_state = QH_STATE_UNLINK;
3075 fotg210->async_unlink_last->unlink_next = qh;
3077 fotg210->async_unlink = qh;
3078 fotg210->async_unlink_last = qh;
3082 while (prev->qh_next.qh != qh)
3083 prev = prev->qh_next.qh;
3085 prev->hw->hw_next = qh->hw->hw_next;
3086 prev->qh_next = qh->qh_next;
3087 if (fotg210->qh_scan_next == qh)
3088 fotg210->qh_scan_next = qh->qh_next.qh;
3122 /* the async qh for the qtds being unlinked are now gone from the HC */
3126 struct fotg210_qh *qh;
3132 qh = fotg210->async_iaa;
3133 fotg210->async_iaa = qh->unlink_next;
3134 qh->unlink_next = NULL;
3136 qh->qh_state = QH_STATE_IDLE;
3137 qh->qh_next.qh = NULL;
3139 qh_completions(fotg210, qh);
3140 if (!list_empty(&qh->qtd_list) &&
3142 qh_link_async(fotg210, qh);
3157 struct fotg210_qh *qh, *next;
3162 next = fotg210->async->qh_next.qh;
3164 qh = next;
3165 next = qh->qh_next.qh;
3167 if (list_empty(&qh->qtd_list) &&
3168 qh->qh_state == QH_STATE_LINKED) {
3169 if (!stopped && qh->unlink_cycle ==
3173 single_unlink_async(fotg210, qh);
3189 /* makes sure the async qh will become idle */
3193 struct fotg210_qh *qh)
3200 if (qh->qh_state != QH_STATE_LINKED) {
3201 if (qh->qh_state == QH_STATE_COMPLETING)
3202 qh->needs_rescan = 1;
3206 single_unlink_async(fotg210, qh);
3212 struct fotg210_qh *qh;
3215 fotg210->qh_scan_next = fotg210->async->qh_next.qh;
3217 qh = fotg210->qh_scan_next;
3218 fotg210->qh_scan_next = qh->qh_next.qh;
3220 /* clean any finished work for this qh */
3221 if (!list_empty(&qh->qtd_list)) {
3227 * always holds the next qh to scan; if the next qh
3231 temp = qh_completions(fotg210, qh);
3232 if (qh->needs_rescan) {
3233 start_unlink_async(fotg210, qh);
3234 } else if (list_empty(&qh->qtd_list)
3235 && qh->qh_state == QH_STATE_LINKED) {
3236 qh->unlink_cycle = fotg210->async_unlink_cycle;
3245 * as HCD schedule-scanning costs. Delay for any qh
3271 * @periodic: host pointer to qh/itd
3279 return &periodic->qh->qh_next;
3291 /* our fotg210_shadow.qh is actually software part */
3293 return &periodic->qh->hw->hw_next;
3342 hw = q->qh->hw;
3345 usecs += q->qh->usecs;
3349 usecs += q->qh->c_usecs;
3351 q = &q->qh->qh_next;
3418 hw = here.qh->hw;
3419 if (same_tt(dev, here.qh->dev)) {
3430 here = here.qh->qh_next;
3474 * this just links in a qh; caller guarantees uframe masks are set right.
3477 static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
3480 unsigned period = qh->period;
3482 dev_dbg(&qh->dev->dev,
3483 "link qh%d-%04x/%p start %d [%d/%d us]\n", period,
3484 hc32_to_cpup(fotg210, &qh->hw->hw_info2) &
3485 (QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs,
3486 qh->c_usecs);
3492 for (i = qh->start; i < fotg210->periodic_size; i += period) {
3511 while (here.ptr && qh != here.qh) {
3512 if (qh->period > here.qh->period)
3514 prev = &here.qh->qh_next;
3515 hw_p = &here.qh->hw->hw_next;
3518 /* link in this qh, unless some earlier pass did that */
3519 if (qh != here.qh) {
3520 qh->qh_next = here;
3521 if (here.qh)
3522 qh->hw->hw_next = *hw_p;
3524 prev->qh = qh;
3525 *hw_p = QH_NEXT(fotg210, qh->qh_dma);
3528 qh->qh_state = QH_STATE_LINKED;
3529 qh->xacterrs = 0;
3531 /* update per-qh bandwidth for usbfs */
3532 fotg210_to_hcd(fotg210)->self.bandwidth_allocated += qh->period
3533 ? ((qh->usecs + qh->c_usecs) / qh->period)
3534 : (qh->usecs * 8);
3536 list_add(&qh->intr_node, &fotg210->intr_qh_list);
3544 struct fotg210_qh *qh)
3550 * If qh is for a low/full-speed device, simply unlinking it
3565 period = qh->period;
3569 for (i = qh->start; i < fotg210->periodic_size; i += period)
3570 periodic_unlink(fotg210, i, qh);
3572 /* update per-qh bandwidth for usbfs */
3573 fotg210_to_hcd(fotg210)->self.bandwidth_allocated -= qh->period
3574 ? ((qh->usecs + qh->c_usecs) / qh->period)
3575 : (qh->usecs * 8);
3577 dev_dbg(&qh->dev->dev,
3578 "unlink qh%d-%04x/%p start %d [%d/%d us]\n",
3579 qh->period, hc32_to_cpup(fotg210, &qh->hw->hw_info2) &
3580 (QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs,
3581 qh->c_usecs);
3583 /* qh->qh_next still "live" to HC */
3584 qh->qh_state = QH_STATE_UNLINK;
3585 qh->qh_next.ptr = NULL;
3587 if (fotg210->qh_scan_next == qh)
3588 fotg210->qh_scan_next = list_entry(qh->intr_node.next,
3590 list_del(&qh->intr_node);
3594 struct fotg210_qh *qh)
3600 if (qh->qh_state != QH_STATE_LINKED) {
3601 if (qh->qh_state == QH_STATE_COMPLETING)
3602 qh->needs_rescan = 1;
3606 qh_unlink_periodic(fotg210, qh);
3616 qh->unlink_cycle = fotg210->intr_unlink_cycle;
3620 fotg210->intr_unlink_last->unlink_next = qh;
3622 fotg210->intr_unlink = qh;
3623 fotg210->intr_unlink_last = qh;
3629 else if (fotg210->intr_unlink == qh) {
3636 static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
3638 struct fotg210_qh_hw *hw = qh->hw;
3641 qh->qh_state = QH_STATE_IDLE;
3644 qh_completions(fotg210, qh);
3647 if (!list_empty(&qh->qtd_list) &&
3649 rc = qh_schedule(fotg210, qh);
3658 fotg210_err(fotg210, "can't reschedule qh %p, err %d\n",
3659 qh, rc);
3708 unsigned uframe, const struct fotg210_qh *qh, __hc32 *c_maskp)
3713 if (qh->c_usecs && uframe >= 6) /* FSTN territory? */
3716 if (!check_period(fotg210, frame, uframe, qh->period, qh->usecs))
3718 if (!qh->c_usecs) {
3731 mask = 0x03 << (uframe + qh->gap_uf);
3735 if (tt_no_collision(fotg210, qh->period, qh->dev, frame, mask)) {
3736 if (!check_period(fotg210, frame, uframe + qh->gap_uf + 1,
3737 qh->period, qh->c_usecs))
3739 if (!check_period(fotg210, frame, uframe + qh->gap_uf,
3740 qh->period, qh->c_usecs))
3751 static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
3756 unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */
3757 struct fotg210_qh_hw *hw = qh->hw;
3759 qh_refresh(fotg210, qh);
3761 frame = qh->start;
3764 if (frame < qh->period) {
3767 qh, &c_mask);
3779 if (qh->period) {
3782 for (i = qh->period; status && i > 0; --i) {
3783 frame = ++fotg210->random_frame % qh->period;
3786 frame, uframe, qh,
3793 /* qh->period == 0 means every uframe */
3796 status = check_intr_schedule(fotg210, 0, 0, qh,
3801 qh->start = frame;
3805 hw->hw_info2 |= qh->period
3810 fotg210_dbg(fotg210, "reused qh %p schedule\n", qh);
3813 qh_link_periodic(fotg210, qh);
3823 struct fotg210_qh *qh;
3840 /* get qh and force any scheduling errors */
3842 qh = qh_append_tds(fotg210, urb, &empty, epnum, &urb->ep->hcpriv);
3843 if (qh == NULL) {
3847 if (qh->qh_state == QH_STATE_IDLE) {
3848 status = qh_schedule(fotg210, qh);
3853 /* then queue the urb's tds to the qh */
3854 qh = qh_append_tds(fotg210, urb, qtd_list, epnum, &urb->ep->hcpriv);
3855 BUG_ON(qh == NULL);
3873 struct fotg210_qh *qh;
3875 list_for_each_entry_safe(qh, fotg210->qh_scan_next,
3878 /* clean any finished work for this qh */
3879 if (!list_empty(&qh->qtd_list)) {
3885 * always holds the next qh to scan; if the next qh
3889 temp = qh_completions(fotg210, qh);
3890 if (unlikely(qh->needs_rescan ||
3891 (list_empty(&qh->qtd_list) &&
3892 qh->qh_state == QH_STATE_LINKED)))
3893 start_unlink_intr(fotg210, qh);
4952 * dedicate a qh for the async ring head, since we couldn't unlink
4953 * a 'real' qh without stopping the async schedule [4.8]. use it
4955 * its dummy is used in hw_alt_next of many tds, to prevent the qh
4958 fotg210->async->qh_next.qh = NULL;
5158 /* complete the unlinking of some qh [4.15.2.3] */
5296 struct fotg210_qh *qh;
5309 qh = (struct fotg210_qh *) urb->hcpriv;
5310 if (!qh)
5312 switch (qh->qh_state) {
5315 start_unlink_async(fotg210, qh);
5323 qh_completions(fotg210, qh);
5329 qh = (struct fotg210_qh *) urb->hcpriv;
5330 if (!qh)
5332 switch (qh->qh_state) {
5335 start_unlink_intr(fotg210, qh);
5338 qh_completions(fotg210, qh);
5341 fotg210_dbg(fotg210, "bogus qh %p state %d\n",
5342 qh, qh->qh_state);
5359 /* bulk qh holds the data toggle */
5366 struct fotg210_qh *qh, *tmp;
5373 qh = ep->hcpriv;
5374 if (!qh)
5380 if (qh->hw == NULL) {
5392 qh->qh_state = QH_STATE_IDLE;
5393 switch (qh->qh_state) {
5396 for (tmp = fotg210->async->qh_next.qh;
5397 tmp && tmp != qh;
5398 tmp = tmp->qh_next.qh)
5400 /* periodic qh self-unlinks on empty, and a COMPLETING qh
5404 start_unlink_async(fotg210, qh);
5413 if (qh->clearing_tt)
5415 if (list_empty(&qh->qtd_list)) {
5416 qh_destroy(fotg210, qh);
5424 fotg210_err(fotg210, "qh %p (#%02x) state %d%s\n",
5425 qh, ep->desc.bEndpointAddress, qh->qh_state,
5426 list_empty(&qh->qtd_list) ? "" : "(has tds)");
5438 struct fotg210_qh *qh;
5448 qh = ep->hcpriv;
5455 if (qh) {
5456 usb_settoggle(qh->dev, epnum, is_out, 0);
5457 if (!list_empty(&qh->qtd_list)) {
5459 } else if (qh->qh_state == QH_STATE_LINKED ||
5460 qh->qh_state == QH_STATE_COMPLETING) {
5467 start_unlink_async(fotg210, qh);
5469 start_unlink_intr(fotg210, qh);
5638 pr_debug("%s: block sizes: qh %zd qtd %zd itd %zd\n",