Lines Matching refs:qh
13 * Control, bulk, and interrupt traffic all use "qh" lists. They list "qtd"
24 * (b) special fields in qh entries or (c) split iso entries. TTs will
80 qh_update (struct ehci_hcd *ehci, struct ehci_qh *qh, struct ehci_qtd *qtd)
82 struct ehci_qh_hw *hw = qh->hw;
85 WARN_ON(qh->qh_state != QH_STATE_IDLE);
98 is_out = qh->is_out;
100 if (unlikely(!usb_gettoggle(qh->ps.udev, epnum, is_out))) {
102 usb_settoggle(qh->ps.udev, epnum, is_out, 1);
109 /* if it weren't for a common silicon quirk (writing the dummy into the qh
110 * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
114 qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
118 qtd = list_entry(qh->qtd_list.next, struct ehci_qtd, qtd_list);
127 if (qh->hw->hw_token & ACTIVE_BIT(ehci)) {
128 qh->hw->hw_qtd_next = qtd->hw_next;
129 if (qh->should_be_inactive)
130 ehci_warn(ehci, "qh %p should be inactive!\n", qh);
132 qh_update(ehci, qh, qtd);
134 qh->should_be_inactive = 0;
139 static void qh_link_async(struct ehci_hcd *ehci, struct ehci_qh *qh);
145 struct ehci_qh *qh = ep->hcpriv;
149 qh->clearing_tt = 0;
150 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list)
152 qh_link_async(ehci, qh);
156 static void ehci_clear_tt_buffer(struct ehci_hcd *ehci, struct ehci_qh *qh,
166 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
178 qh->clearing_tt = 1;
282 static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh);
285 * Process and free completed qtds for a qh, returning URBs to drivers.
286 * Chases up to qh->hw_current. Returns nonzero if the caller should
287 * unlink qh.
290 qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
292 struct ehci_qtd *last, *end = qh->dummy;
297 struct ehci_qh_hw *hw = qh->hw;
301 * they add urbs to this qh's queue or mark them for unlinking.
305 * It's a bug for qh->qh_state to be anything other than
309 state = qh->qh_state;
310 qh->qh_state = QH_STATE_COMPLETING;
316 qh->dequeue_during_giveback = 0;
323 list_for_each_safe (entry, tmp, &qh->qtd_list) {
345 /* hardware copies qtd out of qh overlay */
356 "detected DataBufferErr for urb %p ep%d%s len %d, qtd %p [qh %p]\n",
362 qh);
374 ++qh->xacterrs < QH_XACTERR_MAX &&
378 qtd->length - QTD_LENGTH(token), qtd->length, qh->xacterrs);
381 * qh overlay (which still contains
396 qh->unlink_reason |= QH_UNLINK_HALTED;
398 /* magic dummy for some short reads; qh won't advance.
411 qh->unlink_reason |= QH_UNLINK_SHORT_READ;
426 qh->unlink_reason |= QH_UNLINK_SHUTDOWN;
436 * If this was the active qtd when the qh was unlinked
444 qh->qtd_list.next == &qtd->qtd_list &&
448 qh->should_be_inactive = 1;
454 ehci_clear_tt_buffer(ehci, qh, urb, token);
488 ehci_clear_tt_buffer(ehci, qh, urb,
496 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) {
507 qh->xacterrs = 0;
517 if (unlikely(qh->dequeue_during_giveback)) {
526 qh->qh_state = state;
528 /* be sure the hardware's done with the qh before refreshing
544 qh->unlink_reason |= QH_UNLINK_DUMMY_OVERLAY;
547 return qh->unlink_reason;
573 * create a list of filled qtds for this URB; won't link into qh.
672 /* qh makes control packets use qtd toggle; maybe switch it */
745 // Would be best to create all qh's from config descriptors,
747 // any previous qh and cancel its urbs first; endpoints are
766 struct ehci_qh *qh = ehci_qh_alloc (ehci, flags);
775 if (!qh)
776 return qh;
794 ehci_dbg(ehci, "bogus qh maxpacket %d\n", maxp);
802 * - qh has a polling interval
809 qh->ps.usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
811 qh->ps.phase = NO_FRAME;
814 qh->ps.c_usecs = 0;
815 qh->gap_uf = 0;
826 qh->ps.period = urb->interval >> 3;
833 qh->ps.bw_uperiod = min_t(unsigned, tmp, urb->interval);
834 qh->ps.bw_period = qh->ps.bw_uperiod >> 3;
839 qh->gap_uf = 1 + usb_calc_bus_time (urb->dev->speed,
844 qh->ps.c_usecs = qh->ps.usecs + HS_USECS(0);
845 qh->ps.usecs = HS_USECS(1);
847 qh->ps.usecs += HS_USECS(1);
848 qh->ps.c_usecs = HS_USECS(0);
852 qh->ps.tt_usecs = NS_TO_US(think_time +
857 qh->ps.period = urb->interval;
865 qh->ps.bw_period = min_t(unsigned, tmp, urb->interval);
866 qh->ps.bw_uperiod = qh->ps.bw_period << 3;
871 qh->ps.udev = urb->dev;
872 qh->ps.ep = urb->ep;
936 qh_destroy(ehci, qh);
943 qh->qh_state = QH_STATE_IDLE;
944 hw = qh->hw;
947 qh->is_out = !is_input;
949 return qh;
973 WARN_ON(ehci->async->qh_next.qh || !list_empty(&ehci->async_unlink) ||
980 /* move qh (and its qtds) onto async queue; maybe enable queue. */
982 static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
984 __hc32 dma = QH_NEXT(ehci, qh->qh_dma);
988 if (unlikely(qh->clearing_tt))
991 WARN_ON(qh->qh_state != QH_STATE_IDLE);
994 qh_refresh(ehci, qh);
998 qh->qh_next = head->qh_next;
999 qh->hw->hw_next = head->hw->hw_next;
1002 head->qh_next.qh = qh;
1005 qh->qh_state = QH_STATE_LINKED;
1006 qh->xacterrs = 0;
1007 qh->unlink_reason = 0;
1029 struct ehci_qh *qh = NULL;
1032 qh = (struct ehci_qh *) *ptr;
1033 if (unlikely (qh == NULL)) {
1035 qh = qh_make (ehci, urb, GFP_ATOMIC);
1036 *ptr = qh;
1038 if (likely (qh != NULL)) {
1047 /* control qh may need patching ... */
1052 qh->hw->hw_info1 &= ~qh_addr_mask;
1071 dummy = qh->dummy;
1079 list_splice_tail(qtd_list, &qh->qtd_list);
1082 qh->dummy = qtd;
1086 qtd = list_entry (qh->qtd_list.prev,
1094 urb->hcpriv = qh;
1097 return qh;
1111 struct ehci_qh *qh = NULL;
1121 "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
1138 qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv);
1139 if (unlikely(qh == NULL)) {
1148 if (likely (qh->qh_state == QH_STATE_IDLE))
1149 qh_link_async(ehci, qh);
1152 if (unlikely (qh == NULL))
1258 static void single_unlink_async(struct ehci_hcd *ehci, struct ehci_qh *qh)
1263 qh->qh_state = QH_STATE_UNLINK_WAIT;
1264 list_add_tail(&qh->unlink_node, &ehci->async_unlink);
1268 while (prev->qh_next.qh != qh)
1269 prev = prev->qh_next.qh;
1271 prev->hw->hw_next = qh->hw->hw_next;
1272 prev->qh_next = qh->qh_next;
1273 if (ehci->qh_scan_next == qh)
1274 ehci->qh_scan_next = qh->qh_next.qh;
1310 /* See if the async qh for the qtds being unlinked are now gone from the HC */
1314 struct ehci_qh *qh;
1319 qh = list_first_entry(&ehci->async_unlink, struct ehci_qh,
1337 else if (qh->qh_state == QH_STATE_UNLINK) {
1342 list_move_tail(&qh->unlink_node, &ehci->async_idle);
1359 else if (qh->unlink_reason & (QH_UNLINK_HALTED |
1364 else if ((qh->unlink_reason & QH_UNLINK_QUEUE_EMPTY) &&
1365 list_empty(&qh->qtd_list))
1369 else if (qh->hw->hw_token & cpu_to_hc32(ehci, QTD_STS_HALT))
1376 qh_current = qh->hw->hw_current;
1377 qh_token = qh->hw->hw_token;
1387 qh->qh_state = QH_STATE_UNLINK;
1406 qh = list_first_entry(&ehci->async_idle, struct ehci_qh,
1408 list_del(&qh->unlink_node);
1410 qh->qh_state = QH_STATE_IDLE;
1411 qh->qh_next.qh = NULL;
1413 if (!list_empty(&qh->qtd_list))
1414 qh_completions(ehci, qh);
1415 if (!list_empty(&qh->qtd_list) &&
1417 qh_link_async(ehci, qh);
1423 static void start_unlink_async(struct ehci_hcd *ehci, struct ehci_qh *qh);
1427 struct ehci_qh *qh;
1432 for (qh = ehci->async->qh_next.qh; qh; qh = qh->qh_next.qh) {
1433 if (list_empty(&qh->qtd_list) &&
1434 qh->qh_state == QH_STATE_LINKED) {
1436 if (qh->unlink_cycle != ehci->async_unlink_cycle)
1437 qh_to_unlink = qh;
1460 struct ehci_qh *qh;
1462 while (ehci->async->qh_next.qh) {
1463 qh = ehci->async->qh_next.qh;
1464 WARN_ON(!list_empty(&qh->qtd_list));
1465 single_unlink_async(ehci, qh);
1471 /* makes sure the async qh will become idle */
1474 static void start_unlink_async(struct ehci_hcd *ehci, struct ehci_qh *qh)
1477 if (qh->qh_state != QH_STATE_LINKED)
1480 single_unlink_async(ehci, qh);
1488 struct ehci_qh *qh;
1491 ehci->qh_scan_next = ehci->async->qh_next.qh;
1493 qh = ehci->qh_scan_next;
1494 ehci->qh_scan_next = qh->qh_next.qh;
1496 /* clean any finished work for this qh */
1497 if (!list_empty(&qh->qtd_list)) {
1503 * always holds the next qh to scan; if the next qh
1507 temp = qh_completions(ehci, qh);
1509 start_unlink_async(ehci, qh);
1510 } else if (list_empty(&qh->qtd_list)
1511 && qh->qh_state == QH_STATE_LINKED) {
1512 qh->unlink_cycle = ehci->async_unlink_cycle;
1520 * as HCD schedule-scanning costs. Delay for any qh