Lines Matching defs:qh

176 static void musb_ep_set_qh(struct musb_hw_ep *ep, int is_in, struct musb_qh *qh)
179 ep->in_qh = qh;
181 ep->out_qh = qh;
196 musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh)
200 struct urb *urb = next_urb(qh);
203 struct musb_hw_ep *hw_ep = qh->hw_ep;
206 /* initialize software qh state */
207 qh->offset = 0;
208 qh->segsize = 0;
211 switch (qh->type) {
220 qh->iso_idx = 0;
221 qh->frame = 0;
234 musb_ep_set_qh(hw_ep, is_in, qh);
242 switch (qh->type) {
253 qh->frame = 0;
256 qh->frame = urb->start_frame;
291 * advancing to either the next URB queued to that qh, or else invalidating
292 * that qh and advancing to the next qh scheduled after the current one.
299 struct musb_qh *qh = musb_ep_get_qh(hw_ep, is_in);
300 struct musb_hw_ep *ep = qh->hw_ep;
301 int ready = qh->is_ready;
308 switch (qh->type) {
311 toggle = musb->io.get_toggle(qh, !is_in);
312 usb_settoggle(urb->dev, qh->epnum, !is_in, toggle ? 1 : 0);
320 qh->is_ready = 0;
322 qh->is_ready = ready;
325 * musb->lock had been unlocked in musb_giveback, so qh may
328 qh = musb_ep_get_qh(hw_ep, is_in);
331 * invalidate qh as soon as list_empty(&hep->urb_list)
333 if (qh && list_empty(&qh->hep->urb_list)) {
351 /* Clobber old pointers to this qh */
353 qh->hep->hcpriv = NULL;
355 switch (qh->type) {
360 * should rotate a qh to the end (for fairness).
362 if (qh->mux == 1) {
363 head = qh->ring.prev;
364 list_del(&qh->ring);
365 kfree(qh);
366 qh = first_qh(head);
377 kfree(qh);
378 qh = NULL;
383 if (qh != NULL && qh->is_ready) {
385 hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
386 musb_start_urb(musb, is_in, qh);
423 struct musb_qh *qh = hw_ep->in_qh;
430 urb->transfer_buffer, qh->offset,
443 d = urb->iso_frame_desc + qh->iso_idx;
461 done = (++qh->iso_idx >= urb->number_of_packets);
464 buf = buffer + qh->offset;
465 length = urb->transfer_buffer_length - qh->offset;
474 qh->offset += length;
478 || (rx_count < qh->maxpacket)
514 musb_rx_reinit(struct musb *musb, struct musb_qh *qh, u8 epnum)
553 musb_write_rxfunaddr(musb, epnum, qh->addr_reg);
554 musb_write_rxhubaddr(musb, epnum, qh->h_addr_reg);
555 musb_write_rxhubport(musb, epnum, qh->h_port_reg);
557 musb_writeb(musb->mregs, MUSB_FADDR, qh->addr_reg);
560 musb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg);
561 musb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg);
567 qh->maxpacket | ((qh->hb_mult - 1) << 11));
573 struct musb_qh *qh,
578 u16 pkt_size = qh->maxpacket;
598 if (qh->hb_mult == 1 || (qh->hb_mult > 1 &&
599 can_bulk_split(hw_ep->musb, qh->type)))
626 struct musb_hw_ep *hw_ep, struct musb_qh *qh,
630 u16 pkt_size = qh->maxpacket;
634 musb_tx_dma_set_mode_mentor(hw_ep, qh,
641 qh->segsize = length;
679 struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out);
680 u16 packet_sz = qh->maxpacket;
688 qh->addr_reg, qh->epnum, is_out ? "out" : "in",
689 qh->h_addr_reg, qh->h_port_reg,
758 csr |= musb->io.set_toggle(qh, is_out, urb);
772 musb_write_txfunaddr(musb, epnum, qh->addr_reg);
773 musb_write_txhubaddr(musb, epnum, qh->h_addr_reg);
774 musb_write_txhubport(musb, epnum, qh->h_port_reg);
777 musb_writeb(mbase, MUSB_FADDR, qh->addr_reg);
781 musb_writeb(epio, MUSB_TXTYPE, qh->type_reg);
782 if (can_bulk_split(musb, qh->type)) {
783 qh->hb_mult = hw_ep->max_packet_sz_tx
786 | ((qh->hb_mult) - 1) << 11);
789 qh->maxpacket |
790 ((qh->hb_mult - 1) << 11));
792 musb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg);
794 musb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg);
797 qh->type_reg);
800 if (can_bulk_split(musb, qh->type))
807 hw_ep, qh, urb, offset, len))
812 qh->segsize = load_count;
814 sg_miter_start(&qh->sg_miter, urb->sg, 1,
817 if (!sg_miter_next(&qh->sg_miter)) {
821 sg_miter_stop(&qh->sg_miter);
824 buf = qh->sg_miter.addr + urb->sg->offset +
827 qh->sg_miter.length);
829 qh->sg_miter.consumed = load_count;
830 sg_miter_stop(&qh->sg_miter);
843 musb_rx_reinit(musb, qh, epnum);
844 csr |= musb->io.set_toggle(qh, is_out, urb);
846 if (qh->type == USB_ENDPOINT_XFER_INT)
867 qh->segsize = len;
881 qh->segsize);
896 /* Schedule next QH from musb->in_bulk/out_bulk and move the current qh to
953 /* get the next qh from musb->in_bulk */
956 /* set rx_reinit and schedule the next qh */
962 /* get the next qh from musb->out_bulk */
965 /* set tx_reinit and schedule the next qh */
984 struct musb_qh *qh = hw_ep->in_qh;
998 if (len < qh->maxpacket) {
1024 fifo_count = min_t(size_t, qh->maxpacket,
1062 struct musb_qh *qh = hw_ep->in_qh;
1067 urb = next_urb(qh);
1075 musb_dbg(musb, "<== csr0 %04x, qh %p, count %d, urb %p, stage %d",
1076 csr, qh, len, urb, musb->ep0_stage);
1101 * if (qh->ring.next != &musb->control), then
1204 struct musb_qh *qh = hw_ep->out_qh;
1205 struct urb *urb = next_urb(qh);
1241 if (USB_ENDPOINT_XFER_BULK == qh->type && qh->mux == 1
1252 * if (bulk && qh->ring.next != &musb->out_bulk), then
1362 length = qh->segsize;
1363 qh->offset += length;
1368 d = urb->iso_frame_desc + qh->iso_idx;
1371 if (++qh->iso_idx >= urb->number_of_packets) {
1378 } else if (dma && urb->transfer_buffer_length == qh->offset) {
1382 if (qh->segsize < qh->maxpacket)
1384 else if (qh->offset == urb->transfer_buffer_length
1389 offset = qh->offset;
1408 urb->actual_length = qh->offset;
1412 if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb,
1430 if (length > qh->maxpacket)
1431 length = qh->maxpacket;
1441 if (!sg_miter_next(&qh->sg_miter)) {
1443 sg_miter_stop(&qh->sg_miter);
1447 length = min_t(u32, length, qh->sg_miter.length);
1448 musb_write_fifo(hw_ep, length, qh->sg_miter.addr);
1449 qh->sg_miter.consumed = length;
1450 sg_miter_stop(&qh->sg_miter);
1455 qh->segsize = length;
1466 struct musb_qh *qh,
1476 buf = (void *)urb->iso_frame_desc[qh->iso_idx].offset +
1479 length = urb->iso_frame_desc[qh->iso_idx].length;
1485 return dma->channel_program(channel, qh->maxpacket, 0,
1491 struct musb_qh *qh,
1537 struct musb_qh *qh,
1552 d = urb->iso_frame_desc + qh->iso_idx;
1561 if (++qh->iso_idx >= urb->number_of_packets) {
1566 done = musb_rx_dma_iso_cppi41(dma, hw_ep, qh,
1575 || channel->actual_len < qh->maxpacket
1607 struct musb_qh *qh,
1626 d = urb->iso_frame_desc + qh->iso_idx;
1657 > qh->maxpacket)
1678 if (qh->hb_mult == 1)
1687 done = dma->channel_program(channel, qh->maxpacket,
1707 struct musb_qh *qh,
1716 struct musb_qh *qh,
1735 struct musb_qh *qh = hw_ep->in_qh;
1747 urb = next_urb(qh);
1793 if (USB_ENDPOINT_XFER_ISOC != qh->type) {
1805 && qh->mux == 1
1887 done = musb_rx_dma_inventra_cppi41(c, hw_ep, qh, urb, xfer_len);
1921 qh->offset,
1924 if (musb_rx_dma_in_inventra_cppi41(c, hw_ep, qh, urb,
1942 qh->use_sg = true;
1943 sg_miter_start(&qh->sg_miter, urb->sg, 1,
1947 if (qh->use_sg) {
1948 if (!sg_miter_next(&qh->sg_miter)) {
1950 sg_miter_stop(&qh->sg_miter);
1955 urb->transfer_buffer = qh->sg_miter.addr;
1957 qh->offset = 0x0;
1963 qh->sg_miter.consumed = received_len;
1964 sg_miter_stop(&qh->sg_miter);
1975 qh->offset += xfer_len;
1977 if (qh->use_sg) {
1978 qh->use_sg = false;
1995 struct musb_qh *qh,
2005 struct urb *urb = next_urb(qh);
2008 if (qh->type == USB_ENDPOINT_XFER_CONTROL) {
2017 * We know this qh hasn't been scheduled, so all we need to do
2041 diff -= (qh->maxpacket * qh->hb_mult);
2058 toggle = usb_gettoggle(urb->dev, qh->epnum, !is_in);
2061 if (!is_in && (qh->type == USB_ENDPOINT_XFER_BULK) &&
2070 if (best_end < 0 && qh->type == USB_ENDPOINT_XFER_BULK) {
2084 if (qh->dev)
2085 qh->intv_reg =
2086 (USB_SPEED_HIGH == qh->dev->speed) ? 8 : 4;
2091 musb_ep_xfertype_string(qh->type),
2092 qh->hb_mult, qh->maxpacket);
2097 qh->mux = 0;
2099 musb_dbg(musb, "qh %p periodic slot %d", qh, best_end);
2103 list_add_tail(&qh->ring, head);
2104 qh->mux = 1;
2106 qh->hw_ep = hw_ep;
2107 qh->hep->hcpriv = qh;
2109 musb_start_urb(musb, is_in, qh);
2121 struct musb_qh *qh;
2135 qh = ret ? NULL : hep->hcpriv;
2136 if (qh)
2137 urb->hcpriv = qh;
2142 * scheduled onto a live qh.
2145 * disabled, testing for empty qh->ring and avoiding qh setup costs
2148 if (qh || ret)
2151 /* Allocate and initialize qh, minimizing the work done each time
2154 * REVISIT consider a dedicated qh kmem_cache, so it's harder
2157 qh = kzalloc(sizeof *qh, mem_flags);
2158 if (!qh) {
2165 qh->hep = hep;
2166 qh->dev = urb->dev;
2167 INIT_LIST_HEAD(&qh->ring);
2168 qh->is_ready = 1;
2170 qh->maxpacket = usb_endpoint_maxp(epd);
2171 qh->type = usb_endpoint_type(epd);
2177 qh->hb_mult = usb_endpoint_maxp_mult(epd);
2178 if (qh->hb_mult > 1) {
2179 int ok = (qh->type == USB_ENDPOINT_XFER_ISOC);
2187 musb_ep_xfertype_string(qh->type),
2188 qh->hb_mult, qh->maxpacket & 0x7ff);
2192 qh->maxpacket &= 0x7ff;
2195 qh->epnum = usb_endpoint_num(epd);
2198 qh->addr_reg = (u8) usb_pipedevice(urb->pipe);
2201 type_reg = (qh->type << 4) | qh->epnum;
2212 qh->type_reg = type_reg;
2215 switch (qh->type) {
2232 * transfer scheduling logic to try some other qh, e.g. try
2247 qh->intv_reg = interval;
2254 qh->h_addr_reg = (u8) parent->devnum;
2258 qh->h_port_reg = (u8) urb->dev->ttport;
2260 qh->h_addr_reg =
2263 qh->h_addr_reg |= 0x80;
2268 /* invariant: hep->hcpriv is null OR the qh that's already scheduled.
2273 if (hep->hcpriv || !next_urb(qh)) {
2277 kfree(qh);
2278 qh = NULL;
2281 ret = musb_schedule(musb, qh,
2285 urb->hcpriv = qh;
2297 kfree(qh);
2308 static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
2310 struct musb_hw_ep *ep = qh->hw_ep;
2366 struct musb_qh *qh;
2378 qh = urb->hcpriv;
2379 if (!qh)
2392 * NOTE: qh is invalid unless !list_empty(&hep->urb_list)
2394 if (!qh->is_ready
2395 || urb->urb_list.prev != &qh->hep->urb_list
2396 || musb_ep_get_qh(qh->hw_ep, is_in) != qh) {
2397 int ready = qh->is_ready;
2399 qh->is_ready = 0;
2401 qh->is_ready = ready;
2404 * and its URB list has emptied, recycle this qh.
2406 if (ready && list_empty(&qh->hep->urb_list)) {
2407 musb_ep_set_qh(qh->hw_ep, is_in, NULL);
2408 qh->hep->hcpriv = NULL;
2409 list_del(&qh->ring);
2410 kfree(qh);
2413 ret = musb_cleanup_urb(urb, qh);
2426 struct musb_qh *qh;
2431 qh = hep->hcpriv;
2432 if (qh == NULL)
2435 /* NOTE: qh is invalid unless !list_empty(&hep->urb_list) */
2438 qh->is_ready = 0;
2439 if (musb_ep_get_qh(qh->hw_ep, is_in) == qh) {
2440 urb = next_urb(qh);
2447 musb_cleanup_urb(urb, qh);
2453 urb = next_urb(qh);
2455 musb_advance_schedule(musb, urb, qh->hw_ep, is_in);
2459 * other transfers, and since !qh->is_ready nothing
2463 musb_giveback(musb, next_urb(qh), -ESHUTDOWN);
2466 list_del(&qh->ring);
2467 kfree(qh);