Lines Matching refs:qtd
38 struct isp1760_qtd *qtd);
335 static void alloc_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd) in alloc_mem() argument
340 WARN_ON(qtd->payload_addr); in alloc_mem()
342 if (!qtd->length) in alloc_mem()
346 if (priv->memory_pool[i].size >= qtd->length && in alloc_mem()
349 qtd->payload_addr = priv->memory_pool[i].start; in alloc_mem()
355 static void free_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd) in free_mem() argument
360 if (!qtd->payload_addr) in free_mem()
364 if (priv->memory_pool[i].start == qtd->payload_addr) { in free_mem()
367 qtd->payload_addr = 0; in free_mem()
373 __func__, qtd->payload_addr); in free_mem()
375 qtd->payload_addr = 0; in free_mem()
516 static int last_qtd_of_urb(struct isp1760_qtd *qtd, struct isp1760_qh *qh) in last_qtd_of_urb() argument
520 if (list_is_last(&qtd->qtd_list, &qh->qtd_list)) in last_qtd_of_urb()
523 urb = qtd->urb; in last_qtd_of_urb()
524 qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list); in last_qtd_of_urb()
525 return (qtd->urb != urb); in last_qtd_of_urb()
537 struct isp1760_qtd *qtd, struct ptd *ptd) in create_ptd_atl() argument
547 maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe, in create_ptd_atl()
548 usb_pipeout(qtd->urb->pipe)); in create_ptd_atl()
554 ptd->dw0 |= TO_DW0_LENGTH(qtd->length); in create_ptd_atl()
556 ptd->dw0 |= TO_DW0_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe)); in create_ptd_atl()
559 ptd->dw1 = usb_pipeendpoint(qtd->urb->pipe) >> 1; in create_ptd_atl()
560 ptd->dw1 |= TO_DW1_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe)); in create_ptd_atl()
561 ptd->dw1 |= TO_DW1_PID_TOKEN(qtd->packet_type); in create_ptd_atl()
563 if (usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
565 else if (usb_pipeint(qtd->urb->pipe)) in create_ptd_atl()
568 if (qtd->urb->dev->speed != USB_SPEED_HIGH) { in create_ptd_atl()
572 if (qtd->urb->dev->speed == USB_SPEED_LOW) in create_ptd_atl()
575 ptd->dw1 |= TO_DW1_PORT_NUM(qtd->urb->dev->ttport); in create_ptd_atl()
576 ptd->dw1 |= TO_DW1_HUB_NUM(qtd->urb->dev->tt->hub->devnum); in create_ptd_atl()
579 if (usb_pipeint(qtd->urb->pipe) && in create_ptd_atl()
580 (qtd->urb->dev->speed == USB_SPEED_LOW)) in create_ptd_atl()
587 if (usb_pipecontrol(qtd->urb->pipe) || in create_ptd_atl()
588 usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
593 ptd->dw2 |= TO_DW2_DATA_START_ADDR(base_to_chip(qtd->payload_addr)); in create_ptd_atl()
599 if (usb_pipecontrol(qtd->urb->pipe)) { in create_ptd_atl()
600 if (qtd->data_buffer == qtd->urb->setup_packet) in create_ptd_atl()
602 else if (last_qtd_of_urb(qtd, qh)) in create_ptd_atl()
612 struct isp1760_qtd *qtd, struct ptd *ptd) in transform_add_int() argument
626 if (qtd->urb->dev->speed == USB_SPEED_HIGH) { in transform_add_int()
628 period = qtd->urb->interval >> 3; in transform_add_int()
630 if (qtd->urb->interval > 4) in transform_add_int()
633 else if (qtd->urb->interval > 2) in transform_add_int()
635 else if (qtd->urb->interval > 1) in transform_add_int()
641 period = qtd->urb->interval; in transform_add_int()
664 struct isp1760_qtd *qtd, struct ptd *ptd) in create_ptd_int() argument
666 create_ptd_atl(qh, qtd, ptd); in create_ptd_int()
667 transform_add_int(qh, qtd, ptd); in create_ptd_int()
699 struct isp1760_qtd *qtd; in qtd_alloc() local
701 qtd = kmem_cache_zalloc(qtd_cachep, flags); in qtd_alloc()
702 if (!qtd) in qtd_alloc()
705 INIT_LIST_HEAD(&qtd->qtd_list); in qtd_alloc()
706 qtd->urb = urb; in qtd_alloc()
707 qtd->packet_type = packet_type; in qtd_alloc()
708 qtd->status = QTD_ENQUEUED; in qtd_alloc()
709 qtd->actual_length = 0; in qtd_alloc()
711 return qtd; in qtd_alloc()
714 static void qtd_free(struct isp1760_qtd *qtd) in qtd_free() argument
716 WARN_ON(qtd->payload_addr); in qtd_free()
717 kmem_cache_free(qtd_cachep, qtd); in qtd_free()
722 struct isp1760_qtd *qtd, struct isp1760_qh *qh, in start_bus_transfer() argument
729 WARN_ON(qtd->length && !qtd->payload_addr); in start_bus_transfer()
730 WARN_ON(slots[slot].qtd); in start_bus_transfer()
732 WARN_ON(qtd->status != QTD_PAYLOAD_ALLOC); in start_bus_transfer()
746 qtd->status = QTD_XFER_STARTED; in start_bus_transfer()
748 slots[slot].qtd = qtd; in start_bus_transfer()
763 static int is_short_bulk(struct isp1760_qtd *qtd) in is_short_bulk() argument
765 return (usb_pipebulk(qtd->urb->pipe) && in is_short_bulk()
766 (qtd->actual_length < qtd->length)); in is_short_bulk()
773 struct isp1760_qtd *qtd, *qtd_next; in collect_qtds() local
776 list_for_each_entry_safe(qtd, qtd_next, &qh->qtd_list, qtd_list) { in collect_qtds()
777 if (qtd->status < QTD_XFER_COMPLETE) in collect_qtds()
780 last_qtd = last_qtd_of_urb(qtd, qh); in collect_qtds()
782 if ((!last_qtd) && (qtd->status == QTD_RETIRE)) in collect_qtds()
785 if (qtd->status == QTD_XFER_COMPLETE) { in collect_qtds()
786 if (qtd->actual_length) { in collect_qtds()
787 switch (qtd->packet_type) { in collect_qtds()
789 mem_reads8(hcd->regs, qtd->payload_addr, in collect_qtds()
790 qtd->data_buffer, in collect_qtds()
791 qtd->actual_length); in collect_qtds()
794 qtd->urb->actual_length += in collect_qtds()
795 qtd->actual_length; in collect_qtds()
802 if (is_short_bulk(qtd)) { in collect_qtds()
803 if (qtd->urb->transfer_flags & URB_SHORT_NOT_OK) in collect_qtds()
804 qtd->urb->status = -EREMOTEIO; in collect_qtds()
810 if (qtd->payload_addr) in collect_qtds()
811 free_mem(hcd, qtd); in collect_qtds()
814 if ((qtd->status == QTD_RETIRE) && in collect_qtds()
815 (qtd->urb->status == -EINPROGRESS)) in collect_qtds()
816 qtd->urb->status = -EPIPE; in collect_qtds()
822 urb_listitem->urb = qtd->urb; in collect_qtds()
826 list_del(&qtd->qtd_list); in collect_qtds()
827 qtd_free(qtd); in collect_qtds()
840 struct isp1760_qtd *qtd; in enqueue_qtds() local
862 if ((free_slot == -1) && (slots[curr_slot].qtd == NULL)) in enqueue_qtds()
869 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) { in enqueue_qtds()
870 if (qtd->status == QTD_ENQUEUED) { in enqueue_qtds()
871 WARN_ON(qtd->payload_addr); in enqueue_qtds()
872 alloc_mem(hcd, qtd); in enqueue_qtds()
873 if ((qtd->length) && (!qtd->payload_addr)) in enqueue_qtds()
876 if ((qtd->length) && in enqueue_qtds()
877 ((qtd->packet_type == SETUP_PID) || in enqueue_qtds()
878 (qtd->packet_type == OUT_PID))) { in enqueue_qtds()
879 mem_writes8(hcd->regs, qtd->payload_addr, in enqueue_qtds()
880 qtd->data_buffer, qtd->length); in enqueue_qtds()
883 qtd->status = QTD_PAYLOAD_ALLOC; in enqueue_qtds()
886 if (qtd->status == QTD_PAYLOAD_ALLOC) { in enqueue_qtds()
894 if (usb_pipeint(qtd->urb->pipe)) in enqueue_qtds()
895 create_ptd_int(qh, qtd, &ptd); in enqueue_qtds()
897 create_ptd_atl(qh, qtd, &ptd); in enqueue_qtds()
900 slots, qtd, qh, &ptd); in enqueue_qtds()
1078 struct isp1760_qtd *qtd; in handle_done_ptds() local
1104 slots[slot].qtd->urb); in handle_done_ptds()
1119 slots[slot].qtd->urb); in handle_done_ptds()
1122 qtd = slots[slot].qtd; in handle_done_ptds()
1123 slots[slot].qtd = NULL; in handle_done_ptds()
1128 WARN_ON(qtd->status != QTD_XFER_STARTED); in handle_done_ptds()
1132 if ((usb_pipeint(qtd->urb->pipe)) && in handle_done_ptds()
1133 (qtd->urb->dev->speed != USB_SPEED_HIGH)) in handle_done_ptds()
1134 qtd->actual_length = in handle_done_ptds()
1137 qtd->actual_length = in handle_done_ptds()
1140 qtd->status = QTD_XFER_COMPLETE; in handle_done_ptds()
1141 if (list_is_last(&qtd->qtd_list, &qh->qtd_list) || in handle_done_ptds()
1142 is_short_bulk(qtd)) in handle_done_ptds()
1143 qtd = NULL; in handle_done_ptds()
1145 qtd = list_entry(qtd->qtd_list.next, in handle_done_ptds()
1146 typeof(*qtd), qtd_list); in handle_done_ptds()
1153 qtd->status = QTD_PAYLOAD_ALLOC; in handle_done_ptds()
1165 qtd->status = QTD_RETIRE; in handle_done_ptds()
1166 if ((qtd->urb->dev->speed != USB_SPEED_HIGH) && in handle_done_ptds()
1167 (qtd->urb->status != -EPIPE) && in handle_done_ptds()
1168 (qtd->urb->status != -EREMOTEIO)) { in handle_done_ptds()
1170 if (usb_hub_clear_tt_buffer(qtd->urb)) in handle_done_ptds()
1175 qtd = NULL; in handle_done_ptds()
1185 if (qtd && (qtd->status == QTD_PAYLOAD_ALLOC)) { in handle_done_ptds()
1192 create_ptd_int(qh, qtd, &ptd); in handle_done_ptds()
1195 create_ptd_atl(qh, qtd, &ptd); in handle_done_ptds()
1198 start_bus_transfer(hcd, ptd_offset, slot, slots, qtd, in handle_done_ptds()
1365 static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len) in qtd_fill() argument
1367 qtd->data_buffer = databuffer; in qtd_fill()
1371 qtd->length = len; in qtd_fill()
1373 return qtd->length; in qtd_fill()
1378 struct isp1760_qtd *qtd, *qtd_next; in qtd_list_free() local
1380 list_for_each_entry_safe(qtd, qtd_next, qtd_list, qtd_list) { in qtd_list_free()
1381 list_del(&qtd->qtd_list); in qtd_list_free()
1382 qtd_free(qtd); in qtd_list_free()
1394 struct isp1760_qtd *qtd; in packetize_urb() local
1418 qtd = qtd_alloc(flags, urb, SETUP_PID); in packetize_urb()
1419 if (!qtd) in packetize_urb()
1421 qtd_fill(qtd, urb->setup_packet, sizeof(struct usb_ctrlrequest)); in packetize_urb()
1422 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1443 qtd = qtd_alloc(flags, urb, packet_type); in packetize_urb()
1444 if (!qtd) in packetize_urb()
1446 this_qtd_len = qtd_fill(qtd, buf, len); in packetize_urb()
1447 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1476 qtd = qtd_alloc(flags, urb, packet_type); in packetize_urb()
1477 if (!qtd) in packetize_urb()
1481 qtd_fill(qtd, NULL, 0); in packetize_urb()
1482 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1594 priv->atl_slots[qh->slot].qtd = NULL; in kill_transfer()
1600 priv->int_slots[qh->slot].qtd = NULL; in kill_transfer()
1611 struct isp1760_qtd *qtd) in dequeue_urb_from_qtd() argument
1616 urb = qtd->urb; in dequeue_urb_from_qtd()
1618 list_for_each_entry_from(qtd, &qh->qtd_list, qtd_list) { in dequeue_urb_from_qtd()
1619 if (qtd->urb != urb) in dequeue_urb_from_qtd()
1622 if (qtd->status >= QTD_XFER_STARTED) in dequeue_urb_from_qtd()
1624 if (last_qtd_of_urb(qtd, qh) && in dequeue_urb_from_qtd()
1625 (qtd->status >= QTD_XFER_COMPLETE)) in dequeue_urb_from_qtd()
1628 if (qtd->status == QTD_XFER_STARTED) in dequeue_urb_from_qtd()
1630 qtd->status = QTD_RETIRE; in dequeue_urb_from_qtd()
1647 struct isp1760_qtd *qtd; in isp1760_urb_dequeue() local
1661 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) in isp1760_urb_dequeue()
1662 if (qtd->urb == urb) { in isp1760_urb_dequeue()
1663 dequeue_urb_from_qtd(hcd, qh, qtd); in isp1760_urb_dequeue()
1664 list_move(&qtd->qtd_list, &qh->qtd_list); in isp1760_urb_dequeue()