Lines Matching refs:qtd

42 		struct isp1760_qtd *qtd);
603 static void alloc_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd) in alloc_mem() argument
609 WARN_ON(qtd->payload_addr); in alloc_mem()
611 if (!qtd->length) in alloc_mem()
615 if (priv->memory_pool[i].size >= qtd->length && in alloc_mem()
618 qtd->payload_addr = priv->memory_pool[i].start; in alloc_mem()
624 static void free_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd) in free_mem() argument
630 if (!qtd->payload_addr) in free_mem()
634 if (priv->memory_pool[i].start == qtd->payload_addr) { in free_mem()
637 qtd->payload_addr = 0; in free_mem()
643 __func__, qtd->payload_addr); in free_mem()
645 qtd->payload_addr = 0; in free_mem()
797 static int last_qtd_of_urb(struct isp1760_qtd *qtd, struct isp1760_qh *qh) in last_qtd_of_urb() argument
801 if (list_is_last(&qtd->qtd_list, &qh->qtd_list)) in last_qtd_of_urb()
804 urb = qtd->urb; in last_qtd_of_urb()
805 qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list); in last_qtd_of_urb()
806 return (qtd->urb != urb); in last_qtd_of_urb()
818 struct isp1760_qtd *qtd, struct ptd *ptd) in create_ptd_atl() argument
828 maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe); in create_ptd_atl()
834 ptd->dw0 |= TO_DW0_LENGTH(qtd->length); in create_ptd_atl()
836 ptd->dw0 |= TO_DW0_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe)); in create_ptd_atl()
839 ptd->dw1 = TO_DW((usb_pipeendpoint(qtd->urb->pipe) >> 1)); in create_ptd_atl()
840 ptd->dw1 |= TO_DW1_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe)); in create_ptd_atl()
841 ptd->dw1 |= TO_DW1_PID_TOKEN(qtd->packet_type); in create_ptd_atl()
843 if (usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
845 else if (usb_pipeint(qtd->urb->pipe)) in create_ptd_atl()
848 if (qtd->urb->dev->speed != USB_SPEED_HIGH) { in create_ptd_atl()
852 if (qtd->urb->dev->speed == USB_SPEED_LOW) in create_ptd_atl()
855 ptd->dw1 |= TO_DW1_PORT_NUM(qtd->urb->dev->ttport); in create_ptd_atl()
856 ptd->dw1 |= TO_DW1_HUB_NUM(qtd->urb->dev->tt->hub->devnum); in create_ptd_atl()
859 if (usb_pipeint(qtd->urb->pipe) && in create_ptd_atl()
860 (qtd->urb->dev->speed == USB_SPEED_LOW)) in create_ptd_atl()
867 if (usb_pipecontrol(qtd->urb->pipe) || in create_ptd_atl()
868 usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
873 ptd->dw2 |= TO_DW2_DATA_START_ADDR(base_to_chip(qtd->payload_addr)); in create_ptd_atl()
879 if (usb_pipecontrol(qtd->urb->pipe)) { in create_ptd_atl()
880 if (qtd->data_buffer == qtd->urb->setup_packet) in create_ptd_atl()
882 else if (last_qtd_of_urb(qtd, qh)) in create_ptd_atl()
892 struct isp1760_qtd *qtd, struct ptd *ptd) in transform_add_int() argument
906 if (qtd->urb->dev->speed == USB_SPEED_HIGH) { in transform_add_int()
908 period = qtd->urb->interval >> 3; in transform_add_int()
910 if (qtd->urb->interval > 4) in transform_add_int()
913 else if (qtd->urb->interval > 2) in transform_add_int()
915 else if (qtd->urb->interval > 1) in transform_add_int()
921 period = qtd->urb->interval; in transform_add_int()
944 struct isp1760_qtd *qtd, struct ptd *ptd) in create_ptd_int() argument
946 create_ptd_atl(qh, qtd, ptd); in create_ptd_int()
947 transform_add_int(qh, qtd, ptd); in create_ptd_int()
979 struct isp1760_qtd *qtd; in qtd_alloc() local
981 qtd = kmem_cache_zalloc(qtd_cachep, flags); in qtd_alloc()
982 if (!qtd) in qtd_alloc()
985 INIT_LIST_HEAD(&qtd->qtd_list); in qtd_alloc()
986 qtd->urb = urb; in qtd_alloc()
987 qtd->packet_type = packet_type; in qtd_alloc()
988 qtd->status = QTD_ENQUEUED; in qtd_alloc()
989 qtd->actual_length = 0; in qtd_alloc()
991 return qtd; in qtd_alloc()
994 static void qtd_free(struct isp1760_qtd *qtd) in qtd_free() argument
996 WARN_ON(qtd->payload_addr); in qtd_free()
997 kmem_cache_free(qtd_cachep, qtd); in qtd_free()
1002 struct isp1760_qtd *qtd, struct isp1760_qh *qh, in start_bus_transfer() argument
1010 WARN_ON(qtd->length && !qtd->payload_addr); in start_bus_transfer()
1011 WARN_ON(slots[slot].qtd); in start_bus_transfer()
1013 WARN_ON(qtd->status != QTD_PAYLOAD_ALLOC); in start_bus_transfer()
1035 qtd->status = QTD_XFER_STARTED; in start_bus_transfer()
1037 slots[slot].qtd = qtd; in start_bus_transfer()
1047 static int is_short_bulk(struct isp1760_qtd *qtd) in is_short_bulk() argument
1049 return (usb_pipebulk(qtd->urb->pipe) && in is_short_bulk()
1050 (qtd->actual_length < qtd->length)); in is_short_bulk()
1056 struct isp1760_qtd *qtd, *qtd_next; in collect_qtds() local
1060 list_for_each_entry_safe(qtd, qtd_next, &qh->qtd_list, qtd_list) { in collect_qtds()
1061 if (qtd->status < QTD_XFER_COMPLETE) in collect_qtds()
1064 last_qtd = last_qtd_of_urb(qtd, qh); in collect_qtds()
1066 if ((!last_qtd) && (qtd->status == QTD_RETIRE)) in collect_qtds()
1069 if (qtd->status == QTD_XFER_COMPLETE) { in collect_qtds()
1070 if (qtd->actual_length) { in collect_qtds()
1071 switch (qtd->packet_type) { in collect_qtds()
1073 mem_read(hcd, qtd->payload_addr, in collect_qtds()
1074 qtd->data_buffer, in collect_qtds()
1075 qtd->actual_length); in collect_qtds()
1078 qtd->urb->actual_length += in collect_qtds()
1079 qtd->actual_length; in collect_qtds()
1086 if (is_short_bulk(qtd)) { in collect_qtds()
1087 if (qtd->urb->transfer_flags & URB_SHORT_NOT_OK) in collect_qtds()
1088 qtd->urb->status = -EREMOTEIO; in collect_qtds()
1094 if (qtd->payload_addr) in collect_qtds()
1095 free_mem(hcd, qtd); in collect_qtds()
1098 if ((qtd->status == QTD_RETIRE) && in collect_qtds()
1099 (qtd->urb->status == -EINPROGRESS)) in collect_qtds()
1100 qtd->urb->status = -EPIPE; in collect_qtds()
1106 urb_listitem->urb = qtd->urb; in collect_qtds()
1110 list_del(&qtd->qtd_list); in collect_qtds()
1111 qtd_free(qtd); in collect_qtds()
1126 struct isp1760_qtd *qtd; in enqueue_qtds() local
1148 if ((free_slot == -1) && (slots[curr_slot].qtd == NULL)) in enqueue_qtds()
1155 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) { in enqueue_qtds()
1156 if (qtd->status == QTD_ENQUEUED) { in enqueue_qtds()
1157 WARN_ON(qtd->payload_addr); in enqueue_qtds()
1158 alloc_mem(hcd, qtd); in enqueue_qtds()
1159 if ((qtd->length) && (!qtd->payload_addr)) in enqueue_qtds()
1162 if (qtd->length && (qtd->packet_type == SETUP_PID || in enqueue_qtds()
1163 qtd->packet_type == OUT_PID)) { in enqueue_qtds()
1164 mem_write(hcd, qtd->payload_addr, in enqueue_qtds()
1165 qtd->data_buffer, qtd->length); in enqueue_qtds()
1168 qtd->status = QTD_PAYLOAD_ALLOC; in enqueue_qtds()
1171 if (qtd->status == QTD_PAYLOAD_ALLOC) { in enqueue_qtds()
1179 if (usb_pipeint(qtd->urb->pipe)) in enqueue_qtds()
1180 create_ptd_int(qh, qtd, &ptd); in enqueue_qtds()
1182 create_ptd_atl(qh, qtd, &ptd); in enqueue_qtds()
1185 slots, qtd, qh, &ptd); in enqueue_qtds()
1361 struct isp1760_qtd *qtd; in handle_done_ptds() local
1387 slots[slot].qtd->urb); in handle_done_ptds()
1402 slots[slot].qtd->urb); in handle_done_ptds()
1405 qtd = slots[slot].qtd; in handle_done_ptds()
1406 slots[slot].qtd = NULL; in handle_done_ptds()
1411 WARN_ON(qtd->status != QTD_XFER_STARTED); in handle_done_ptds()
1415 if ((usb_pipeint(qtd->urb->pipe)) && in handle_done_ptds()
1416 (qtd->urb->dev->speed != USB_SPEED_HIGH)) in handle_done_ptds()
1417 qtd->actual_length = in handle_done_ptds()
1420 qtd->actual_length = in handle_done_ptds()
1423 qtd->status = QTD_XFER_COMPLETE; in handle_done_ptds()
1424 if (list_is_last(&qtd->qtd_list, &qh->qtd_list) || in handle_done_ptds()
1425 is_short_bulk(qtd)) in handle_done_ptds()
1426 qtd = NULL; in handle_done_ptds()
1428 qtd = list_entry(qtd->qtd_list.next, in handle_done_ptds()
1429 typeof(*qtd), qtd_list); in handle_done_ptds()
1436 qtd->status = QTD_PAYLOAD_ALLOC; in handle_done_ptds()
1448 qtd->status = QTD_RETIRE; in handle_done_ptds()
1449 if ((qtd->urb->dev->speed != USB_SPEED_HIGH) && in handle_done_ptds()
1450 (qtd->urb->status != -EPIPE) && in handle_done_ptds()
1451 (qtd->urb->status != -EREMOTEIO)) { in handle_done_ptds()
1453 if (usb_hub_clear_tt_buffer(qtd->urb)) in handle_done_ptds()
1458 qtd = NULL; in handle_done_ptds()
1468 if (qtd && (qtd->status == QTD_PAYLOAD_ALLOC)) { in handle_done_ptds()
1475 create_ptd_int(qh, qtd, &ptd); in handle_done_ptds()
1478 create_ptd_atl(qh, qtd, &ptd); in handle_done_ptds()
1481 start_bus_transfer(hcd, ptd_offset, slot, slots, qtd, in handle_done_ptds()
1747 static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len) in qtd_fill() argument
1749 qtd->data_buffer = databuffer; in qtd_fill()
1751 qtd->length = len; in qtd_fill()
1753 return qtd->length; in qtd_fill()
1758 struct isp1760_qtd *qtd, *qtd_next; in qtd_list_free() local
1760 list_for_each_entry_safe(qtd, qtd_next, qtd_list, qtd_list) { in qtd_list_free()
1761 list_del(&qtd->qtd_list); in qtd_list_free()
1762 qtd_free(qtd); in qtd_list_free()
1775 struct isp1760_qtd *qtd; in packetize_urb() local
1799 qtd = qtd_alloc(flags, urb, SETUP_PID); in packetize_urb()
1800 if (!qtd) in packetize_urb()
1802 qtd_fill(qtd, urb->setup_packet, sizeof(struct usb_ctrlrequest)); in packetize_urb()
1803 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1823 qtd = qtd_alloc(flags, urb, packet_type); in packetize_urb()
1824 if (!qtd) in packetize_urb()
1832 this_qtd_len = qtd_fill(qtd, buf, this_qtd_len); in packetize_urb()
1833 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1862 qtd = qtd_alloc(flags, urb, packet_type); in packetize_urb()
1863 if (!qtd) in packetize_urb()
1867 qtd_fill(qtd, NULL, 0); in packetize_urb()
1868 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1982 priv->atl_slots[qh->slot].qtd = NULL; in kill_transfer()
1990 priv->int_slots[qh->slot].qtd = NULL; in kill_transfer()
2001 struct isp1760_qtd *qtd) in dequeue_urb_from_qtd() argument
2006 urb = qtd->urb; in dequeue_urb_from_qtd()
2008 list_for_each_entry_from(qtd, &qh->qtd_list, qtd_list) { in dequeue_urb_from_qtd()
2009 if (qtd->urb != urb) in dequeue_urb_from_qtd()
2012 if (qtd->status >= QTD_XFER_STARTED) in dequeue_urb_from_qtd()
2014 if (last_qtd_of_urb(qtd, qh) && in dequeue_urb_from_qtd()
2015 (qtd->status >= QTD_XFER_COMPLETE)) in dequeue_urb_from_qtd()
2018 if (qtd->status == QTD_XFER_STARTED) in dequeue_urb_from_qtd()
2020 qtd->status = QTD_RETIRE; in dequeue_urb_from_qtd()
2037 struct isp1760_qtd *qtd; in isp1760_urb_dequeue() local
2051 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) in isp1760_urb_dequeue()
2052 if (qtd->urb == urb) { in isp1760_urb_dequeue()
2053 dequeue_urb_from_qtd(hcd, qh, qtd); in isp1760_urb_dequeue()
2054 list_move(&qtd->qtd_list, &qh->qtd_list); in isp1760_urb_dequeue()