Lines Matching refs:qh

294 	struct ehci_qh		*qh;		/* Q_TYPE_QH */  member
1030 static void oxu_qh_free(struct oxu_hcd *oxu, struct ehci_qh *qh) in oxu_qh_free() argument
1036 index = qh - &oxu->mem->qh_pool[0]; in oxu_qh_free()
1044 struct ehci_qh *qh = container_of(kref, struct ehci_qh, kref); in qh_destroy() local
1045 struct oxu_hcd *oxu = qh->oxu; in qh_destroy()
1048 if (!list_empty(&qh->qtd_list) || qh->qh_next.ptr) { in qh_destroy()
1052 if (qh->dummy) in qh_destroy()
1053 oxu_qtd_free(oxu, qh->dummy); in qh_destroy()
1054 oxu_qh_free(oxu, qh); in qh_destroy()
1060 struct ehci_qh *qh = NULL; in oxu_qh_alloc() local
1069 qh = (struct ehci_qh *) &oxu->mem->qh_pool[i]; in oxu_qh_alloc()
1070 memset(qh, 0, sizeof *qh); in oxu_qh_alloc()
1072 kref_init(&qh->kref); in oxu_qh_alloc()
1073 qh->oxu = oxu; in oxu_qh_alloc()
1074 qh->qh_dma = virt_to_phys(qh); in oxu_qh_alloc()
1075 INIT_LIST_HEAD(&qh->qtd_list); in oxu_qh_alloc()
1078 qh->dummy = ehci_qtd_alloc(oxu); in oxu_qh_alloc()
1079 if (qh->dummy == NULL) { in oxu_qh_alloc()
1082 qh = NULL; in oxu_qh_alloc()
1091 return qh; in oxu_qh_alloc()
1095 static inline struct ehci_qh *qh_get(struct ehci_qh *qh) in qh_get() argument
1097 kref_get(&qh->kref); in qh_get()
1098 return qh; in qh_get()
1101 static inline void qh_put(struct ehci_qh *qh) in qh_put() argument
1103 kref_put(&qh->kref, qh_destroy); in qh_put()
1245 struct ehci_qh *qh, struct ehci_qtd *qtd) in qh_update() argument
1248 BUG_ON(qh->qh_state != QH_STATE_IDLE); in qh_update()
1250 qh->hw_qtd_next = QTD_NEXT(qtd->qtd_dma); in qh_update()
1251 qh->hw_alt_next = EHCI_LIST_END; in qh_update()
1258 if (!(qh->hw_info1 & cpu_to_le32(1 << 14))) { in qh_update()
1262 epnum = (le32_to_cpup(&qh->hw_info1) >> 8) & 0x0f; in qh_update()
1263 if (unlikely(!usb_gettoggle(qh->dev, epnum, is_out))) { in qh_update()
1264 qh->hw_token &= ~cpu_to_le32(QTD_TOGGLE); in qh_update()
1265 usb_settoggle(qh->dev, epnum, is_out, 1); in qh_update()
1271 qh->hw_token &= cpu_to_le32(QTD_TOGGLE | QTD_STS_PING); in qh_update()
1278 static void qh_refresh(struct oxu_hcd *oxu, struct ehci_qh *qh) in qh_refresh() argument
1282 if (list_empty(&qh->qtd_list)) in qh_refresh()
1283 qtd = qh->dummy; in qh_refresh()
1285 qtd = list_entry(qh->qtd_list.next, in qh_refresh()
1288 if (cpu_to_le32(qtd->qtd_dma) == qh->hw_current) in qh_refresh()
1293 qh_update(oxu, qh, qtd); in qh_refresh()
1353 struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv; in ehci_urb_done() local
1356 if ((qh->hw_info2 & cpu_to_le32(QH_SMASK)) != 0) { in ehci_urb_done()
1361 qh_put(qh); in ehci_urb_done()
1394 static void start_unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh);
1395 static void unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh);
1397 static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
1398 static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
1406 static unsigned qh_completions(struct oxu_hcd *oxu, struct ehci_qh *qh) in qh_completions() argument
1408 struct ehci_qtd *last = NULL, *end = qh->dummy; in qh_completions()
1416 if (unlikely(list_empty(&qh->qtd_list))) in qh_completions()
1425 state = qh->qh_state; in qh_completions()
1426 qh->qh_state = QH_STATE_COMPLETING; in qh_completions()
1434 list_for_each_entry_safe(qtd, tmp, &qh->qtd_list, qtd_list) { in qh_completions()
1511 == qh->hw_current) in qh_completions()
1512 token = le32_to_cpu(qh->hw_token); in qh_completions()
1518 if ((HALT_BIT & qh->hw_token) == 0) { in qh_completions()
1520 qh->hw_token |= HALT_BIT; in qh_completions()
1535 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) { in qh_completions()
1562 qh->qh_state = state; in qh_completions()
1568 if (stopped != 0 || qh->hw_qtd_next == EHCI_LIST_END) { in qh_completions()
1571 qh_refresh(oxu, qh); in qh_completions()
1578 & qh->hw_info2) != 0) { in qh_completions()
1579 intr_deschedule(oxu, qh); in qh_completions()
1580 (void) qh_schedule(oxu, qh); in qh_completions()
1582 unlink_async(oxu, qh); in qh_completions()
1782 struct ehci_qh *qh = oxu_qh_alloc(oxu); in qh_make() local
1787 if (!qh) in qh_make()
1788 return qh; in qh_make()
1809 qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH, in qh_make()
1812 qh->start = NO_FRAME; in qh_make()
1815 qh->c_usecs = 0; in qh_make()
1816 qh->gap_uf = 0; in qh_make()
1818 qh->period = urb->interval >> 3; in qh_make()
1819 if (qh->period == 0 && urb->interval != 1) { in qh_make()
1833 qh->gap_uf = 1 + usb_calc_bus_time(urb->dev->speed, in qh_make()
1838 qh->c_usecs = qh->usecs + HS_USECS(0); in qh_make()
1839 qh->usecs = HS_USECS(1); in qh_make()
1841 qh->usecs += HS_USECS(1); in qh_make()
1842 qh->c_usecs = HS_USECS(0); in qh_make()
1846 qh->tt_usecs = NS_TO_US(think_time + in qh_make()
1849 qh->period = urb->interval; in qh_make()
1854 qh->dev = urb->dev; in qh_make()
1898 qh_put(qh); in qh_make()
1905 qh->qh_state = QH_STATE_IDLE; in qh_make()
1906 qh->hw_info1 = cpu_to_le32(info1); in qh_make()
1907 qh->hw_info2 = cpu_to_le32(info2); in qh_make()
1909 qh_refresh(oxu, qh); in qh_make()
1910 return qh; in qh_make()
1915 static void qh_link_async(struct oxu_hcd *oxu, struct ehci_qh *qh) in qh_link_async() argument
1917 __le32 dma = QH_NEXT(qh->qh_dma); in qh_link_async()
1923 if (!head->qh_next.qh) { in qh_link_async()
1938 if (qh->qh_state == QH_STATE_IDLE) in qh_link_async()
1939 qh_refresh(oxu, qh); in qh_link_async()
1942 qh->qh_next = head->qh_next; in qh_link_async()
1943 qh->hw_next = head->hw_next; in qh_link_async()
1946 head->qh_next.qh = qh; in qh_link_async()
1949 qh->qh_state = QH_STATE_LINKED; in qh_link_async()
1965 struct ehci_qh *qh = NULL; in qh_append_tds() local
1967 qh = (struct ehci_qh *) *ptr; in qh_append_tds()
1968 if (unlikely(qh == NULL)) { in qh_append_tds()
1970 qh = qh_make(oxu, urb, GFP_ATOMIC); in qh_append_tds()
1971 *ptr = qh; in qh_append_tds()
1973 if (likely(qh != NULL)) { in qh_append_tds()
1987 qh->hw_info1 &= ~QH_ADDR_MASK; in qh_append_tds()
2006 dummy = qh->dummy; in qh_append_tds()
2014 list_splice(qtd_list, qh->qtd_list.prev); in qh_append_tds()
2017 qh->dummy = qtd; in qh_append_tds()
2021 qtd = list_entry(qh->qtd_list.prev, in qh_append_tds()
2030 urb->hcpriv = qh_get(qh); in qh_append_tds()
2033 return qh; in qh_append_tds()
2041 struct ehci_qh *qh = NULL; in submit_async() local
2061 qh = qh_append_tds(oxu, urb, qtd_list, epnum, &urb->ep->hcpriv); in submit_async()
2062 if (unlikely(qh == NULL)) { in submit_async()
2070 if (likely(qh->qh_state == QH_STATE_IDLE)) in submit_async()
2071 qh_link_async(oxu, qh_get(qh)); in submit_async()
2074 if (unlikely(qh == NULL)) in submit_async()
2083 struct ehci_qh *qh = oxu->reclaim; in end_unlink_async() local
2088 qh->qh_state = QH_STATE_IDLE; in end_unlink_async()
2089 qh->qh_next.qh = NULL; in end_unlink_async()
2090 qh_put(qh); /* refcount from reclaim */ in end_unlink_async()
2093 next = qh->reclaim; in end_unlink_async()
2096 qh->reclaim = NULL; in end_unlink_async()
2098 qh_completions(oxu, qh); in end_unlink_async()
2100 if (!list_empty(&qh->qtd_list) in end_unlink_async()
2102 qh_link_async(oxu, qh); in end_unlink_async()
2104 qh_put(qh); /* refcount from async list */ in end_unlink_async()
2110 && oxu->async->qh_next.qh == NULL) in end_unlink_async()
2123 static void start_unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh) in start_unlink_async() argument
2130 BUG_ON(oxu->reclaim || (qh->qh_state != QH_STATE_LINKED in start_unlink_async()
2131 && qh->qh_state != QH_STATE_UNLINK_WAIT)); in start_unlink_async()
2135 if (unlikely(qh == oxu->async)) { in start_unlink_async()
2148 qh->qh_state = QH_STATE_UNLINK; in start_unlink_async()
2149 oxu->reclaim = qh = qh_get(qh); in start_unlink_async()
2152 while (prev->qh_next.qh != qh) in start_unlink_async()
2153 prev = prev->qh_next.qh; in start_unlink_async()
2155 prev->hw_next = qh->hw_next; in start_unlink_async()
2156 prev->qh_next = qh->qh_next; in start_unlink_async()
2176 struct ehci_qh *qh; in scan_async() local
2183 qh = oxu->async->qh_next.qh; in scan_async()
2184 if (likely(qh != NULL)) { in scan_async()
2187 if (!list_empty(&qh->qtd_list) in scan_async()
2188 && qh->stamp != oxu->stamp) { in scan_async()
2196 qh = qh_get(qh); in scan_async()
2197 qh->stamp = oxu->stamp; in scan_async()
2198 temp = qh_completions(oxu, qh); in scan_async()
2199 qh_put(qh); in scan_async()
2210 if (list_empty(&qh->qtd_list)) { in scan_async()
2211 if (qh->stamp == oxu->stamp) in scan_async()
2214 && qh->qh_state == QH_STATE_LINKED) in scan_async()
2215 start_unlink_async(oxu, qh); in scan_async()
2218 qh = qh->qh_next.qh; in scan_async()
2219 } while (qh); in scan_async()
2236 return &periodic->qh->qh_next; in periodic_next_shadow()
2277 if (q->qh->hw_info2 & cpu_to_le32(1 << uframe)) in periodic_usecs()
2278 usecs += q->qh->usecs; in periodic_usecs()
2280 if (q->qh->hw_info2 & cpu_to_le32(1 << (8 + uframe))) in periodic_usecs()
2281 usecs += q->qh->c_usecs; in periodic_usecs()
2282 hw_p = &q->qh->hw_next; in periodic_usecs()
2283 q = &q->qh->qh_next; in periodic_usecs()
2350 static int qh_link_periodic(struct oxu_hcd *oxu, struct ehci_qh *qh) in qh_link_periodic() argument
2353 unsigned period = qh->period; in qh_link_periodic()
2355 dev_dbg(&qh->dev->dev, in qh_link_periodic()
2357 period, le32_to_cpup(&qh->hw_info2) & (QH_CMASK | QH_SMASK), in qh_link_periodic()
2358 qh, qh->start, qh->usecs, qh->c_usecs); in qh_link_periodic()
2364 for (i = qh->start; i < oxu->periodic_size; i += period) { in qh_link_periodic()
2376 hw_p = &here.qh->hw_next; in qh_link_periodic()
2383 while (here.ptr && qh != here.qh) { in qh_link_periodic()
2384 if (qh->period > here.qh->period) in qh_link_periodic()
2386 prev = &here.qh->qh_next; in qh_link_periodic()
2387 hw_p = &here.qh->hw_next; in qh_link_periodic()
2391 if (qh != here.qh) { in qh_link_periodic()
2392 qh->qh_next = here; in qh_link_periodic()
2393 if (here.qh) in qh_link_periodic()
2394 qh->hw_next = *hw_p; in qh_link_periodic()
2396 prev->qh = qh; in qh_link_periodic()
2397 *hw_p = QH_NEXT(qh->qh_dma); in qh_link_periodic()
2400 qh->qh_state = QH_STATE_LINKED; in qh_link_periodic()
2401 qh_get(qh); in qh_link_periodic()
2404 oxu_to_hcd(oxu)->self.bandwidth_allocated += qh->period in qh_link_periodic()
2405 ? ((qh->usecs + qh->c_usecs) / qh->period) in qh_link_periodic()
2406 : (qh->usecs * 8); in qh_link_periodic()
2415 static void qh_unlink_periodic(struct oxu_hcd *oxu, struct ehci_qh *qh) in qh_unlink_periodic() argument
2429 period = qh->period; in qh_unlink_periodic()
2433 for (i = qh->start; i < oxu->periodic_size; i += period) in qh_unlink_periodic()
2434 periodic_unlink(oxu, i, qh); in qh_unlink_periodic()
2437 oxu_to_hcd(oxu)->self.bandwidth_allocated -= qh->period in qh_unlink_periodic()
2438 ? ((qh->usecs + qh->c_usecs) / qh->period) in qh_unlink_periodic()
2439 : (qh->usecs * 8); in qh_unlink_periodic()
2441 dev_dbg(&qh->dev->dev, in qh_unlink_periodic()
2443 qh->period, in qh_unlink_periodic()
2444 le32_to_cpup(&qh->hw_info2) & (QH_CMASK | QH_SMASK), in qh_unlink_periodic()
2445 qh, qh->start, qh->usecs, qh->c_usecs); in qh_unlink_periodic()
2448 qh->qh_state = QH_STATE_UNLINK; in qh_unlink_periodic()
2449 qh->qh_next.ptr = NULL; in qh_unlink_periodic()
2450 qh_put(qh); in qh_unlink_periodic()
2458 static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh) in intr_deschedule() argument
2462 qh_unlink_periodic(oxu, qh); in intr_deschedule()
2469 if (list_empty(&qh->qtd_list) in intr_deschedule()
2470 || (cpu_to_le32(QH_CMASK) & qh->hw_info2) != 0) in intr_deschedule()
2476 qh->qh_state = QH_STATE_IDLE; in intr_deschedule()
2477 qh->hw_next = EHCI_LIST_END; in intr_deschedule()
2525 const struct ehci_qh *qh, __le32 *c_maskp) in check_intr_schedule() argument
2529 if (qh->c_usecs && uframe >= 6) /* FSTN territory? */ in check_intr_schedule()
2532 if (!check_period(oxu, frame, uframe, qh->period, qh->usecs)) in check_intr_schedule()
2534 if (!qh->c_usecs) { in check_intr_schedule()
2547 static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh) in qh_schedule() argument
2554 qh_refresh(oxu, qh); in qh_schedule()
2555 qh->hw_next = EHCI_LIST_END; in qh_schedule()
2556 frame = qh->start; in qh_schedule()
2559 if (frame < qh->period) { in qh_schedule()
2560 uframe = ffs(le32_to_cpup(&qh->hw_info2) & QH_SMASK); in qh_schedule()
2562 qh, &c_mask); in qh_schedule()
2574 if (qh->period) { in qh_schedule()
2575 frame = qh->period - 1; in qh_schedule()
2579 frame, uframe, qh, in qh_schedule()
2589 status = check_intr_schedule(oxu, 0, 0, qh, &c_mask); in qh_schedule()
2593 qh->start = frame; in qh_schedule()
2596 qh->hw_info2 &= cpu_to_le32(~(QH_CMASK | QH_SMASK)); in qh_schedule()
2597 qh->hw_info2 |= qh->period in qh_schedule()
2600 qh->hw_info2 |= c_mask; in qh_schedule()
2602 oxu_dbg(oxu, "reused qh %p schedule\n", qh); in qh_schedule()
2605 status = qh_link_periodic(oxu, qh); in qh_schedule()
2615 struct ehci_qh *qh; in intr_submit() local
2631 qh = qh_append_tds(oxu, urb, &empty, epnum, &urb->ep->hcpriv); in intr_submit()
2632 if (qh == NULL) { in intr_submit()
2636 if (qh->qh_state == QH_STATE_IDLE) { in intr_submit()
2637 status = qh_schedule(oxu, qh); in intr_submit()
2643 qh = qh_append_tds(oxu, urb, qtd_list, epnum, &urb->ep->hcpriv); in intr_submit()
2644 BUG_ON(qh == NULL); in intr_submit()
2715 temp.qh = qh_get(q.qh); in scan_periodic()
2716 type = Q_NEXT_TYPE(q.qh->hw_next); in scan_periodic()
2717 q = q.qh->qh_next; in scan_periodic()
2718 modified = qh_completions(oxu, temp.qh); in scan_periodic()
2719 if (unlikely(list_empty(&temp.qh->qtd_list))) in scan_periodic()
2720 intr_deschedule(oxu, temp.qh); in scan_periodic()
2721 qh_put(temp.qh); in scan_periodic()
2827 static void unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh) in unlink_async() argument
2830 if (qh->qh_state == QH_STATE_LINKED in unlink_async()
2839 qh->qh_state = QH_STATE_UNLINK_WAIT; in unlink_async()
2840 last->reclaim = qh; in unlink_async()
2847 if (qh->qh_state == QH_STATE_LINKED) in unlink_async()
2848 start_unlink_async(oxu, qh); in unlink_async()
3046 oxu->async->qh_next.qh = NULL; in oxu_hcd_init()
3358 struct ehci_qh *qh; in oxu_urb_dequeue() local
3366 qh = (struct ehci_qh *) urb->hcpriv; in oxu_urb_dequeue()
3367 if (!qh) in oxu_urb_dequeue()
3369 unlink_async(oxu, qh); in oxu_urb_dequeue()
3373 qh = (struct ehci_qh *) urb->hcpriv; in oxu_urb_dequeue()
3374 if (!qh) in oxu_urb_dequeue()
3376 switch (qh->qh_state) { in oxu_urb_dequeue()
3378 intr_deschedule(oxu, qh); in oxu_urb_dequeue()
3381 qh_completions(oxu, qh); in oxu_urb_dequeue()
3385 qh, qh->qh_state); in oxu_urb_dequeue()
3390 if (!list_empty(&qh->qtd_list) in oxu_urb_dequeue()
3394 status = qh_schedule(oxu, qh); in oxu_urb_dequeue()
3402 "can't reschedule qh %p, err %d\n", qh, in oxu_urb_dequeue()
3420 struct ehci_qh *qh, *tmp; in oxu_endpoint_disable() local
3427 qh = ep->hcpriv; in oxu_endpoint_disable()
3428 if (!qh) in oxu_endpoint_disable()
3434 if (qh->hw_info1 == 0) { in oxu_endpoint_disable()
3440 qh->qh_state = QH_STATE_IDLE; in oxu_endpoint_disable()
3441 switch (qh->qh_state) { in oxu_endpoint_disable()
3443 for (tmp = oxu->async->qh_next.qh; in oxu_endpoint_disable()
3444 tmp && tmp != qh; in oxu_endpoint_disable()
3445 tmp = tmp->qh_next.qh) in oxu_endpoint_disable()
3450 unlink_async(oxu, qh); in oxu_endpoint_disable()
3458 if (list_empty(&qh->qtd_list)) { in oxu_endpoint_disable()
3459 qh_put(qh); in oxu_endpoint_disable()
3469 qh, ep->desc.bEndpointAddress, qh->qh_state, in oxu_endpoint_disable()
3470 list_empty(&qh->qtd_list) ? "" : "(has tds)"); in oxu_endpoint_disable()
3991 if (oxu->async->qh_next.qh) in oxu_bus_resume()