Lines Matching refs:qh

132 dbg_qh(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
134 struct fotg210_qh_hw *hw = qh->hw;
136 fotg210_dbg(fotg210, "%s qh %p n%08x info %x %x qtd %x\n", label, qh,
354 static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
365 struct fotg210_qh_hw *hw = qh->hw;
371 if (mark == '/') { /* qh_alt_next controls qh advance? */
382 "qh/%p dev%d %cs ep%d %08x %08x(%08x%c %s nak%d)",
383 qh, scratch & 0x007f,
395 list_for_each_entry(td, &qh->qtd_list, qtd_list) {
452 struct fotg210_qh *qh;
466 for (qh = fotg210->async->qh_next.qh; size > 0 && qh;
467 qh = qh->qh_next.qh)
468 qh_lines(fotg210, qh, &next, &size);
474 for (qh = fotg210->async_unlink; size > 0 && qh;
475 qh = qh->unlink_next)
476 qh_lines(fotg210, qh, &next, &size);
485 struct fotg210_qh_hw *hw, struct fotg210_qh *qh, unsigned size)
493 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) {
507 (scratch >> 8) & 0x000f, type, qh->usecs,
508 qh->c_usecs, temp, (scratch >> 16) & 0x7ff);
558 hw = p.qh->hw;
559 temp = scnprintf(next, size, " qh%d-%04x/%p",
560 p.qh->period,
565 p.qh);
568 /* don't repeat what follows this qh */
572 if (p.qh->qh_next.ptr) {
584 p.qh, size);
587 seen[seen_count++].qh = p.qh;
591 p = p.qh->qh_next;
715 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 = dma_pool_zalloc(fotg210->qh_pool, flags, &dma);
1858 if (!qh->hw)
1860 qh->qh_dma = dma;
1861 INIT_LIST_HEAD(&qh->qtd_list);
1864 qh->dummy = fotg210_qtd_alloc(fotg210, flags);
1865 if (qh->dummy == NULL) {
1870 return qh;
1872 dma_pool_free(fotg210->qh_pool, qh->hw, qh->qh_dma);
1874 kfree(qh);
1974 * Control, bulk, and interrupt traffic all use "qh" lists. They list "qtd"
1985 * (b) special fields in qh entries or (c) split iso entries. TTs will
2030 struct fotg210_qh *qh, struct fotg210_qtd *qtd)
2032 struct fotg210_qh_hw *hw = qh->hw;
2035 BUG_ON(qh->qh_state != QH_STATE_IDLE);
2048 is_out = qh->is_out;
2050 if (unlikely(!usb_gettoggle(qh->dev, epnum, is_out))) {
2052 usb_settoggle(qh->dev, epnum, is_out, 1);
2059 /* if it weren't for a common silicon quirk (writing the dummy into the qh
2060 * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
2063 static void qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
2067 if (list_empty(&qh->qtd_list))
2068 qtd = qh->dummy;
2070 qtd = list_entry(qh->qtd_list.next,
2079 if (cpu_to_hc32(fotg210, qtd->qtd_dma) == qh->hw->hw_current) {
2080 qh->hw->hw_qtd_next = qtd->hw_next;
2086 qh_update(fotg210, qh, qtd);
2089 static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
2095 struct fotg210_qh *qh = ep->hcpriv;
2099 qh->clearing_tt = 0;
2100 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list)
2102 qh_link_async(fotg210, qh);
2107 struct fotg210_qh *qh, struct urb *urb, u32 token)
2116 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
2127 qh->clearing_tt = 1;
2197 struct fotg210_qh *qh = (struct fotg210_qh *) urb->hcpriv;
2200 if ((qh->hw->hw_info2 & cpu_to_hc32(fotg210, QH_SMASK)) != 0) {
2233 static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
2235 /* Process and free completed qtds for a qh, returning URBs to drivers.
2236 * Chases up to qh->hw_current. Returns number of completions called,
2240 struct fotg210_qh *qh)
2242 struct fotg210_qtd *last, *end = qh->dummy;
2248 struct fotg210_qh_hw *hw = qh->hw;
2250 if (unlikely(list_empty(&qh->qtd_list)))
2255 * they add urbs to this qh's queue or mark them for unlinking.
2259 * It's a bug for qh->qh_state to be anything other than
2263 state = qh->qh_state;
2264 qh->qh_state = QH_STATE_COMPLETING;
2270 qh->needs_rescan = 0;
2277 list_for_each_entry_safe(qtd, tmp, &qh->qtd_list, qtd_list) {
2299 /* hardware copies qtd out of qh overlay */
2310 "detected DataBufferErr for urb %p ep%d%s len %d, qtd %p [qh %p]\n",
2314 urb->transfer_buffer_length, qtd, qh);
2326 ++qh->xacterrs < QH_XACTERR_MAX &&
2332 qh->xacterrs);
2335 * qh overlay (which still contains
2351 /* magic dummy for some short reads; qh won't advance.
2385 /* qh unlinked; token in overlay may be most current */
2395 fotg210_clear_tt_buffer(fotg210, qh, urb,
2430 fotg210_clear_tt_buffer(fotg210, qh,
2438 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) {
2449 qh->xacterrs = 0;
2460 if (unlikely(qh->needs_rescan)) {
2466 * Our caller will start an unlink if qh->needs_rescan is
2471 qh->needs_rescan = 0;
2475 qh->qh_state = state;
2477 /* be sure the hardware's done with the qh before refreshing
2484 qh_refresh(fotg210, qh);
2500 qh->needs_rescan = 1;
2523 /* create a list of filled qtds for this URB; won't link into qh.
2618 /* qh makes control packets use qtd toggle; maybe switch it */
2689 /* Would be best to create all qh's from config descriptors,
2691 * any previous qh and cancel its urbs first; endpoints are
2707 struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
2716 if (!qh)
2717 return qh;
2735 fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", maxp);
2743 * - qh has a polling interval
2748 qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
2750 qh->start = NO_FRAME;
2753 qh->c_usecs = 0;
2754 qh->gap_uf = 0;
2756 qh->period = urb->interval >> 3;
2757 if (qh->period == 0 && urb->interval != 1) {
2763 } else if (qh->period > fotg210->periodic_size) {
2764 qh->period = fotg210->periodic_size;
2765 urb->interval = qh->period << 3;
2771 qh->gap_uf = 1 + usb_calc_bus_time(urb->dev->speed,
2776 qh->c_usecs = qh->usecs + HS_USECS(0);
2777 qh->usecs = HS_USECS(1);
2779 qh->usecs += HS_USECS(1);
2780 qh->c_usecs = HS_USECS(0);
2784 qh->tt_usecs = NS_TO_US(think_time +
2787 qh->period = urb->interval;
2788 if (qh->period > fotg210->periodic_size) {
2789 qh->period = fotg210->periodic_size;
2790 urb->interval = qh->period;
2796 qh->dev = urb->dev;
2860 qh_destroy(fotg210, qh);
2867 qh->qh_state = QH_STATE_IDLE;
2868 hw = qh->hw;
2871 qh->is_out = !is_input;
2873 qh_refresh(fotg210, qh);
2874 return qh;
2896 WARN_ON(fotg210->async->qh_next.qh || fotg210->async_unlink);
2902 /* move qh (and its qtds) onto async queue; maybe enable queue. */
2904 static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
2906 __hc32 dma = QH_NEXT(fotg210, qh->qh_dma);
2910 if (unlikely(qh->clearing_tt))
2913 WARN_ON(qh->qh_state != QH_STATE_IDLE);
2916 qh_refresh(fotg210, qh);
2920 qh->qh_next = head->qh_next;
2921 qh->hw->hw_next = head->hw->hw_next;
2924 head->qh_next.qh = qh;
2927 qh->xacterrs = 0;
2928 qh->qh_state = QH_STATE_LINKED;
2943 struct fotg210_qh *qh = NULL;
2946 qh = (struct fotg210_qh *) *ptr;
2947 if (unlikely(qh == NULL)) {
2949 qh = qh_make(fotg210, urb, GFP_ATOMIC);
2950 *ptr = qh;
2952 if (likely(qh != NULL)) {
2961 /* control qh may need patching ... */
2965 qh->hw->hw_info1 &= ~qh_addr_mask;
2984 dummy = qh->dummy;
2992 list_splice_tail(qtd_list, &qh->qtd_list);
2995 qh->dummy = qtd;
2999 qtd = list_entry(qh->qtd_list.prev,
3007 urb->hcpriv = qh;
3010 return qh;
3018 struct fotg210_qh *qh = NULL;
3029 "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
3047 qh = qh_append_tds(fotg210, urb, qtd_list, epnum, &urb->ep->hcpriv);
3048 if (unlikely(qh == NULL)) {
3057 if (likely(qh->qh_state == QH_STATE_IDLE))
3058 qh_link_async(fotg210, qh);
3061 if (unlikely(qh == NULL))
3067 struct fotg210_qh *qh)
3072 qh->qh_state = QH_STATE_UNLINK;
3074 fotg210->async_unlink_last->unlink_next = qh;
3076 fotg210->async_unlink = qh;
3077 fotg210->async_unlink_last = qh;
3081 while (prev->qh_next.qh != qh)
3082 prev = prev->qh_next.qh;
3084 prev->hw->hw_next = qh->hw->hw_next;
3085 prev->qh_next = qh->qh_next;
3086 if (fotg210->qh_scan_next == qh)
3087 fotg210->qh_scan_next = qh->qh_next.qh;
3121 /* the async qh for the qtds being unlinked are now gone from the HC */
3125 struct fotg210_qh *qh;
3131 qh = fotg210->async_iaa;
3132 fotg210->async_iaa = qh->unlink_next;
3133 qh->unlink_next = NULL;
3135 qh->qh_state = QH_STATE_IDLE;
3136 qh->qh_next.qh = NULL;
3138 qh_completions(fotg210, qh);
3139 if (!list_empty(&qh->qtd_list) &&
3141 qh_link_async(fotg210, qh);
3156 struct fotg210_qh *qh, *next;
3161 next = fotg210->async->qh_next.qh;
3163 qh = next;
3164 next = qh->qh_next.qh;
3166 if (list_empty(&qh->qtd_list) &&
3167 qh->qh_state == QH_STATE_LINKED) {
3168 if (!stopped && qh->unlink_cycle ==
3172 single_unlink_async(fotg210, qh);
3188 /* makes sure the async qh will become idle */
3192 struct fotg210_qh *qh)
3199 if (qh->qh_state != QH_STATE_LINKED) {
3200 if (qh->qh_state == QH_STATE_COMPLETING)
3201 qh->needs_rescan = 1;
3205 single_unlink_async(fotg210, qh);
3211 struct fotg210_qh *qh;
3214 fotg210->qh_scan_next = fotg210->async->qh_next.qh;
3216 qh = fotg210->qh_scan_next;
3217 fotg210->qh_scan_next = qh->qh_next.qh;
3219 /* clean any finished work for this qh */
3220 if (!list_empty(&qh->qtd_list)) {
3226 * always holds the next qh to scan; if the next qh
3230 temp = qh_completions(fotg210, qh);
3231 if (qh->needs_rescan) {
3232 start_unlink_async(fotg210, qh);
3233 } else if (list_empty(&qh->qtd_list)
3234 && qh->qh_state == QH_STATE_LINKED) {
3235 qh->unlink_cycle = fotg210->async_unlink_cycle;
3244 * as HCD schedule-scanning costs. Delay for any qh
3270 * @periodic: host pointer to qh/itd
3278 return &periodic->qh->qh_next;
3290 /* our fotg210_shadow.qh is actually software part */
3292 return &periodic->qh->hw->hw_next;
3341 hw = q->qh->hw;
3344 usecs += q->qh->usecs;
3348 usecs += q->qh->c_usecs;
3350 q = &q->qh->qh_next;
3417 hw = here.qh->hw;
3418 if (same_tt(dev, here.qh->dev)) {
3429 here = here.qh->qh_next;
3473 * this just links in a qh; caller guarantees uframe masks are set right.
3476 static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
3479 unsigned period = qh->period;
3481 dev_dbg(&qh->dev->dev,
3482 "link qh%d-%04x/%p start %d [%d/%d us]\n", period,
3483 hc32_to_cpup(fotg210, &qh->hw->hw_info2) &
3484 (QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs,
3485 qh->c_usecs);
3491 for (i = qh->start; i < fotg210->periodic_size; i += period) {
3510 while (here.ptr && qh != here.qh) {
3511 if (qh->period > here.qh->period)
3513 prev = &here.qh->qh_next;
3514 hw_p = &here.qh->hw->hw_next;
3517 /* link in this qh, unless some earlier pass did that */
3518 if (qh != here.qh) {
3519 qh->qh_next = here;
3520 if (here.qh)
3521 qh->hw->hw_next = *hw_p;
3523 prev->qh = qh;
3524 *hw_p = QH_NEXT(fotg210, qh->qh_dma);
3527 qh->qh_state = QH_STATE_LINKED;
3528 qh->xacterrs = 0;
3530 /* update per-qh bandwidth for usbfs */
3531 fotg210_to_hcd(fotg210)->self.bandwidth_allocated += qh->period
3532 ? ((qh->usecs + qh->c_usecs) / qh->period)
3533 : (qh->usecs * 8);
3535 list_add(&qh->intr_node, &fotg210->intr_qh_list);
3543 struct fotg210_qh *qh)
3549 * If qh is for a low/full-speed device, simply unlinking it
3564 period = qh->period;
3568 for (i = qh->start; i < fotg210->periodic_size; i += period)
3569 periodic_unlink(fotg210, i, qh);
3571 /* update per-qh bandwidth for usbfs */
3572 fotg210_to_hcd(fotg210)->self.bandwidth_allocated -= qh->period
3573 ? ((qh->usecs + qh->c_usecs) / qh->period)
3574 : (qh->usecs * 8);
3576 dev_dbg(&qh->dev->dev,
3577 "unlink qh%d-%04x/%p start %d [%d/%d us]\n",
3578 qh->period, hc32_to_cpup(fotg210, &qh->hw->hw_info2) &
3579 (QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs,
3580 qh->c_usecs);
3582 /* qh->qh_next still "live" to HC */
3583 qh->qh_state = QH_STATE_UNLINK;
3584 qh->qh_next.ptr = NULL;
3586 if (fotg210->qh_scan_next == qh)
3587 fotg210->qh_scan_next = list_entry(qh->intr_node.next,
3589 list_del(&qh->intr_node);
3593 struct fotg210_qh *qh)
3599 if (qh->qh_state != QH_STATE_LINKED) {
3600 if (qh->qh_state == QH_STATE_COMPLETING)
3601 qh->needs_rescan = 1;
3605 qh_unlink_periodic(fotg210, qh);
3615 qh->unlink_cycle = fotg210->intr_unlink_cycle;
3619 fotg210->intr_unlink_last->unlink_next = qh;
3621 fotg210->intr_unlink = qh;
3622 fotg210->intr_unlink_last = qh;
3628 else if (fotg210->intr_unlink == qh) {
3635 static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
3637 struct fotg210_qh_hw *hw = qh->hw;
3640 qh->qh_state = QH_STATE_IDLE;
3643 qh_completions(fotg210, qh);
3646 if (!list_empty(&qh->qtd_list) &&
3648 rc = qh_schedule(fotg210, qh);
3657 fotg210_err(fotg210, "can't reschedule qh %p, err %d\n",
3658 qh, rc);
3707 unsigned uframe, const struct fotg210_qh *qh, __hc32 *c_maskp)
3712 if (qh->c_usecs && uframe >= 6) /* FSTN territory? */
3715 if (!check_period(fotg210, frame, uframe, qh->period, qh->usecs))
3717 if (!qh->c_usecs) {
3730 mask = 0x03 << (uframe + qh->gap_uf);
3734 if (tt_no_collision(fotg210, qh->period, qh->dev, frame, mask)) {
3735 if (!check_period(fotg210, frame, uframe + qh->gap_uf + 1,
3736 qh->period, qh->c_usecs))
3738 if (!check_period(fotg210, frame, uframe + qh->gap_uf,
3739 qh->period, qh->c_usecs))
3750 static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
3755 unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */
3756 struct fotg210_qh_hw *hw = qh->hw;
3758 qh_refresh(fotg210, qh);
3760 frame = qh->start;
3763 if (frame < qh->period) {
3766 qh, &c_mask);
3778 if (qh->period) {
3781 for (i = qh->period; status && i > 0; --i) {
3782 frame = ++fotg210->random_frame % qh->period;
3785 frame, uframe, qh,
3792 /* qh->period == 0 means every uframe */
3795 status = check_intr_schedule(fotg210, 0, 0, qh,
3800 qh->start = frame;
3804 hw->hw_info2 |= qh->period
3809 fotg210_dbg(fotg210, "reused qh %p schedule\n", qh);
3812 qh_link_periodic(fotg210, qh);
3822 struct fotg210_qh *qh;
3839 /* get qh and force any scheduling errors */
3841 qh = qh_append_tds(fotg210, urb, &empty, epnum, &urb->ep->hcpriv);
3842 if (qh == NULL) {
3846 if (qh->qh_state == QH_STATE_IDLE) {
3847 status = qh_schedule(fotg210, qh);
3852 /* then queue the urb's tds to the qh */
3853 qh = qh_append_tds(fotg210, urb, qtd_list, epnum, &urb->ep->hcpriv);
3854 BUG_ON(qh == NULL);
3872 struct fotg210_qh *qh;
3874 list_for_each_entry_safe(qh, fotg210->qh_scan_next,
3877 /* clean any finished work for this qh */
3878 if (!list_empty(&qh->qtd_list)) {
3884 * always holds the next qh to scan; if the next qh
3888 temp = qh_completions(fotg210, qh);
3889 if (unlikely(qh->needs_rescan ||
3890 (list_empty(&qh->qtd_list) &&
3891 qh->qh_state == QH_STATE_LINKED)))
3892 start_unlink_intr(fotg210, qh);
4953 * dedicate a qh for the async ring head, since we couldn't unlink
4954 * a 'real' qh without stopping the async schedule [4.8]. use it
4956 * its dummy is used in hw_alt_next of many tds, to prevent the qh
4959 fotg210->async->qh_next.qh = NULL;
5159 /* complete the unlinking of some qh [4.15.2.3] */
5297 struct fotg210_qh *qh;
5310 qh = (struct fotg210_qh *) urb->hcpriv;
5311 if (!qh)
5313 switch (qh->qh_state) {
5316 start_unlink_async(fotg210, qh);
5324 qh_completions(fotg210, qh);
5330 qh = (struct fotg210_qh *) urb->hcpriv;
5331 if (!qh)
5333 switch (qh->qh_state) {
5336 start_unlink_intr(fotg210, qh);
5339 qh_completions(fotg210, qh);
5342 fotg210_dbg(fotg210, "bogus qh %p state %d\n",
5343 qh, qh->qh_state);
5360 /* bulk qh holds the data toggle */
5367 struct fotg210_qh *qh, *tmp;
5374 qh = ep->hcpriv;
5375 if (!qh)
5381 if (qh->hw == NULL) {
5393 qh->qh_state = QH_STATE_IDLE;
5394 switch (qh->qh_state) {
5397 for (tmp = fotg210->async->qh_next.qh;
5398 tmp && tmp != qh;
5399 tmp = tmp->qh_next.qh)
5401 /* periodic qh self-unlinks on empty, and a COMPLETING qh
5405 start_unlink_async(fotg210, qh);
5414 if (qh->clearing_tt)
5416 if (list_empty(&qh->qtd_list)) {
5417 qh_destroy(fotg210, qh);
5425 fotg210_err(fotg210, "qh %p (#%02x) state %d%s\n",
5426 qh, ep->desc.bEndpointAddress, qh->qh_state,
5427 list_empty(&qh->qtd_list) ? "" : "(has tds)");
5439 struct fotg210_qh *qh;
5449 qh = ep->hcpriv;
5456 if (qh) {
5457 usb_settoggle(qh->dev, epnum, is_out, 0);
5458 if (!list_empty(&qh->qtd_list)) {
5460 } else if (qh->qh_state == QH_STATE_LINKED ||
5461 qh->qh_state == QH_STATE_COMPLETING) {
5468 start_unlink_async(fotg210, qh);
5470 start_unlink_intr(fotg210, qh);
5702 pr_debug("%s: block sizes: qh %zd qtd %zd itd %zd\n",