Lines Matching refs:qtd
40 struct isp1760_qtd *qtd);
337 static void alloc_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd) in alloc_mem() argument
342 WARN_ON(qtd->payload_addr); in alloc_mem()
344 if (!qtd->length) in alloc_mem()
348 if (priv->memory_pool[i].size >= qtd->length && in alloc_mem()
351 qtd->payload_addr = priv->memory_pool[i].start; in alloc_mem()
357 static void free_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd) in free_mem() argument
362 if (!qtd->payload_addr) in free_mem()
366 if (priv->memory_pool[i].start == qtd->payload_addr) { in free_mem()
369 qtd->payload_addr = 0; in free_mem()
375 __func__, qtd->payload_addr); in free_mem()
377 qtd->payload_addr = 0; in free_mem()
513 static int last_qtd_of_urb(struct isp1760_qtd *qtd, struct isp1760_qh *qh) in last_qtd_of_urb() argument
517 if (list_is_last(&qtd->qtd_list, &qh->qtd_list)) in last_qtd_of_urb()
520 urb = qtd->urb; in last_qtd_of_urb()
521 qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list); in last_qtd_of_urb()
522 return (qtd->urb != urb); in last_qtd_of_urb()
534 struct isp1760_qtd *qtd, struct ptd *ptd) in create_ptd_atl() argument
544 maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe, in create_ptd_atl()
545 usb_pipeout(qtd->urb->pipe)); in create_ptd_atl()
551 ptd->dw0 |= TO_DW0_LENGTH(qtd->length); in create_ptd_atl()
553 ptd->dw0 |= TO_DW0_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe)); in create_ptd_atl()
556 ptd->dw1 = usb_pipeendpoint(qtd->urb->pipe) >> 1; in create_ptd_atl()
557 ptd->dw1 |= TO_DW1_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe)); in create_ptd_atl()
558 ptd->dw1 |= TO_DW1_PID_TOKEN(qtd->packet_type); in create_ptd_atl()
560 if (usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
562 else if (usb_pipeint(qtd->urb->pipe)) in create_ptd_atl()
565 if (qtd->urb->dev->speed != USB_SPEED_HIGH) { in create_ptd_atl()
569 if (qtd->urb->dev->speed == USB_SPEED_LOW) in create_ptd_atl()
572 ptd->dw1 |= TO_DW1_PORT_NUM(qtd->urb->dev->ttport); in create_ptd_atl()
573 ptd->dw1 |= TO_DW1_HUB_NUM(qtd->urb->dev->tt->hub->devnum); in create_ptd_atl()
576 if (usb_pipeint(qtd->urb->pipe) && in create_ptd_atl()
577 (qtd->urb->dev->speed == USB_SPEED_LOW)) in create_ptd_atl()
584 if (usb_pipecontrol(qtd->urb->pipe) || in create_ptd_atl()
585 usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
590 ptd->dw2 |= TO_DW2_DATA_START_ADDR(base_to_chip(qtd->payload_addr)); in create_ptd_atl()
596 if (usb_pipecontrol(qtd->urb->pipe)) { in create_ptd_atl()
597 if (qtd->data_buffer == qtd->urb->setup_packet) in create_ptd_atl()
599 else if (last_qtd_of_urb(qtd, qh)) in create_ptd_atl()
609 struct isp1760_qtd *qtd, struct ptd *ptd) in transform_add_int() argument
623 if (qtd->urb->dev->speed == USB_SPEED_HIGH) { in transform_add_int()
625 period = qtd->urb->interval >> 3; in transform_add_int()
627 if (qtd->urb->interval > 4) in transform_add_int()
630 else if (qtd->urb->interval > 2) in transform_add_int()
632 else if (qtd->urb->interval > 1) in transform_add_int()
638 period = qtd->urb->interval; in transform_add_int()
661 struct isp1760_qtd *qtd, struct ptd *ptd) in create_ptd_int() argument
663 create_ptd_atl(qh, qtd, ptd); in create_ptd_int()
664 transform_add_int(qh, qtd, ptd); in create_ptd_int()
696 struct isp1760_qtd *qtd; in qtd_alloc() local
698 qtd = kmem_cache_zalloc(qtd_cachep, flags); in qtd_alloc()
699 if (!qtd) in qtd_alloc()
702 INIT_LIST_HEAD(&qtd->qtd_list); in qtd_alloc()
703 qtd->urb = urb; in qtd_alloc()
704 qtd->packet_type = packet_type; in qtd_alloc()
705 qtd->status = QTD_ENQUEUED; in qtd_alloc()
706 qtd->actual_length = 0; in qtd_alloc()
708 return qtd; in qtd_alloc()
711 static void qtd_free(struct isp1760_qtd *qtd) in qtd_free() argument
713 WARN_ON(qtd->payload_addr); in qtd_free()
714 kmem_cache_free(qtd_cachep, qtd); in qtd_free()
719 struct isp1760_qtd *qtd, struct isp1760_qh *qh, in start_bus_transfer() argument
726 WARN_ON(qtd->length && !qtd->payload_addr); in start_bus_transfer()
727 WARN_ON(slots[slot].qtd); in start_bus_transfer()
729 WARN_ON(qtd->status != QTD_PAYLOAD_ALLOC); in start_bus_transfer()
743 qtd->status = QTD_XFER_STARTED; in start_bus_transfer()
745 slots[slot].qtd = qtd; in start_bus_transfer()
760 static int is_short_bulk(struct isp1760_qtd *qtd) in is_short_bulk() argument
762 return (usb_pipebulk(qtd->urb->pipe) && in is_short_bulk()
763 (qtd->actual_length < qtd->length)); in is_short_bulk()
770 struct isp1760_qtd *qtd, *qtd_next; in collect_qtds() local
773 list_for_each_entry_safe(qtd, qtd_next, &qh->qtd_list, qtd_list) { in collect_qtds()
774 if (qtd->status < QTD_XFER_COMPLETE) in collect_qtds()
777 last_qtd = last_qtd_of_urb(qtd, qh); in collect_qtds()
779 if ((!last_qtd) && (qtd->status == QTD_RETIRE)) in collect_qtds()
782 if (qtd->status == QTD_XFER_COMPLETE) { in collect_qtds()
783 if (qtd->actual_length) { in collect_qtds()
784 switch (qtd->packet_type) { in collect_qtds()
786 mem_reads8(hcd->regs, qtd->payload_addr, in collect_qtds()
787 qtd->data_buffer, in collect_qtds()
788 qtd->actual_length); in collect_qtds()
791 qtd->urb->actual_length += in collect_qtds()
792 qtd->actual_length; in collect_qtds()
799 if (is_short_bulk(qtd)) { in collect_qtds()
800 if (qtd->urb->transfer_flags & URB_SHORT_NOT_OK) in collect_qtds()
801 qtd->urb->status = -EREMOTEIO; in collect_qtds()
807 if (qtd->payload_addr) in collect_qtds()
808 free_mem(hcd, qtd); in collect_qtds()
811 if ((qtd->status == QTD_RETIRE) && in collect_qtds()
812 (qtd->urb->status == -EINPROGRESS)) in collect_qtds()
813 qtd->urb->status = -EPIPE; in collect_qtds()
819 urb_listitem->urb = qtd->urb; in collect_qtds()
823 list_del(&qtd->qtd_list); in collect_qtds()
824 qtd_free(qtd); in collect_qtds()
837 struct isp1760_qtd *qtd; in enqueue_qtds() local
859 if ((free_slot == -1) && (slots[curr_slot].qtd == NULL)) in enqueue_qtds()
866 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) { in enqueue_qtds()
867 if (qtd->status == QTD_ENQUEUED) { in enqueue_qtds()
868 WARN_ON(qtd->payload_addr); in enqueue_qtds()
869 alloc_mem(hcd, qtd); in enqueue_qtds()
870 if ((qtd->length) && (!qtd->payload_addr)) in enqueue_qtds()
873 if ((qtd->length) && in enqueue_qtds()
874 ((qtd->packet_type == SETUP_PID) || in enqueue_qtds()
875 (qtd->packet_type == OUT_PID))) { in enqueue_qtds()
876 mem_writes8(hcd->regs, qtd->payload_addr, in enqueue_qtds()
877 qtd->data_buffer, qtd->length); in enqueue_qtds()
880 qtd->status = QTD_PAYLOAD_ALLOC; in enqueue_qtds()
883 if (qtd->status == QTD_PAYLOAD_ALLOC) { in enqueue_qtds()
891 if (usb_pipeint(qtd->urb->pipe)) in enqueue_qtds()
892 create_ptd_int(qh, qtd, &ptd); in enqueue_qtds()
894 create_ptd_atl(qh, qtd, &ptd); in enqueue_qtds()
897 slots, qtd, qh, &ptd); in enqueue_qtds()
1073 struct isp1760_qtd *qtd; in handle_done_ptds() local
1099 slots[slot].qtd->urb); in handle_done_ptds()
1114 slots[slot].qtd->urb); in handle_done_ptds()
1117 qtd = slots[slot].qtd; in handle_done_ptds()
1118 slots[slot].qtd = NULL; in handle_done_ptds()
1123 WARN_ON(qtd->status != QTD_XFER_STARTED); in handle_done_ptds()
1127 if ((usb_pipeint(qtd->urb->pipe)) && in handle_done_ptds()
1128 (qtd->urb->dev->speed != USB_SPEED_HIGH)) in handle_done_ptds()
1129 qtd->actual_length = in handle_done_ptds()
1132 qtd->actual_length = in handle_done_ptds()
1135 qtd->status = QTD_XFER_COMPLETE; in handle_done_ptds()
1136 if (list_is_last(&qtd->qtd_list, &qh->qtd_list) || in handle_done_ptds()
1137 is_short_bulk(qtd)) in handle_done_ptds()
1138 qtd = NULL; in handle_done_ptds()
1140 qtd = list_entry(qtd->qtd_list.next, in handle_done_ptds()
1141 typeof(*qtd), qtd_list); in handle_done_ptds()
1148 qtd->status = QTD_PAYLOAD_ALLOC; in handle_done_ptds()
1160 qtd->status = QTD_RETIRE; in handle_done_ptds()
1161 if ((qtd->urb->dev->speed != USB_SPEED_HIGH) && in handle_done_ptds()
1162 (qtd->urb->status != -EPIPE) && in handle_done_ptds()
1163 (qtd->urb->status != -EREMOTEIO)) { in handle_done_ptds()
1165 if (usb_hub_clear_tt_buffer(qtd->urb)) in handle_done_ptds()
1170 qtd = NULL; in handle_done_ptds()
1180 if (qtd && (qtd->status == QTD_PAYLOAD_ALLOC)) { in handle_done_ptds()
1187 create_ptd_int(qh, qtd, &ptd); in handle_done_ptds()
1190 create_ptd_atl(qh, qtd, &ptd); in handle_done_ptds()
1193 start_bus_transfer(hcd, ptd_offset, slot, slots, qtd, in handle_done_ptds()
1362 static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len) in qtd_fill() argument
1364 qtd->data_buffer = databuffer; in qtd_fill()
1368 qtd->length = len; in qtd_fill()
1370 return qtd->length; in qtd_fill()
1375 struct isp1760_qtd *qtd, *qtd_next; in qtd_list_free() local
1377 list_for_each_entry_safe(qtd, qtd_next, qtd_list, qtd_list) { in qtd_list_free()
1378 list_del(&qtd->qtd_list); in qtd_list_free()
1379 qtd_free(qtd); in qtd_list_free()
1391 struct isp1760_qtd *qtd; in packetize_urb() local
1415 qtd = qtd_alloc(flags, urb, SETUP_PID); in packetize_urb()
1416 if (!qtd) in packetize_urb()
1418 qtd_fill(qtd, urb->setup_packet, sizeof(struct usb_ctrlrequest)); in packetize_urb()
1419 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1440 qtd = qtd_alloc(flags, urb, packet_type); in packetize_urb()
1441 if (!qtd) in packetize_urb()
1443 this_qtd_len = qtd_fill(qtd, buf, len); in packetize_urb()
1444 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1473 qtd = qtd_alloc(flags, urb, packet_type); in packetize_urb()
1474 if (!qtd) in packetize_urb()
1478 qtd_fill(qtd, NULL, 0); in packetize_urb()
1479 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1591 priv->atl_slots[qh->slot].qtd = NULL; in kill_transfer()
1597 priv->int_slots[qh->slot].qtd = NULL; in kill_transfer()
1608 struct isp1760_qtd *qtd) in dequeue_urb_from_qtd() argument
1613 urb = qtd->urb; in dequeue_urb_from_qtd()
1615 list_for_each_entry_from(qtd, &qh->qtd_list, qtd_list) { in dequeue_urb_from_qtd()
1616 if (qtd->urb != urb) in dequeue_urb_from_qtd()
1619 if (qtd->status >= QTD_XFER_STARTED) in dequeue_urb_from_qtd()
1621 if (last_qtd_of_urb(qtd, qh) && in dequeue_urb_from_qtd()
1622 (qtd->status >= QTD_XFER_COMPLETE)) in dequeue_urb_from_qtd()
1625 if (qtd->status == QTD_XFER_STARTED) in dequeue_urb_from_qtd()
1627 qtd->status = QTD_RETIRE; in dequeue_urb_from_qtd()
1644 struct isp1760_qtd *qtd; in isp1760_urb_dequeue() local
1658 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) in isp1760_urb_dequeue()
1659 if (qtd->urb == urb) { in isp1760_urb_dequeue()
1660 dequeue_urb_from_qtd(hcd, qh, qtd); in isp1760_urb_dequeue()
1661 list_move(&qtd->qtd_list, &qh->qtd_list); in isp1760_urb_dequeue()