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()
829 usb_pipeout(qtd->urb->pipe)); in create_ptd_atl()
835 ptd->dw0 |= TO_DW0_LENGTH(qtd->length); in create_ptd_atl()
837 ptd->dw0 |= TO_DW0_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe)); in create_ptd_atl()
840 ptd->dw1 = TO_DW((usb_pipeendpoint(qtd->urb->pipe) >> 1)); in create_ptd_atl()
841 ptd->dw1 |= TO_DW1_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe)); in create_ptd_atl()
842 ptd->dw1 |= TO_DW1_PID_TOKEN(qtd->packet_type); in create_ptd_atl()
844 if (usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
846 else if (usb_pipeint(qtd->urb->pipe)) in create_ptd_atl()
849 if (qtd->urb->dev->speed != USB_SPEED_HIGH) { in create_ptd_atl()
853 if (qtd->urb->dev->speed == USB_SPEED_LOW) in create_ptd_atl()
856 ptd->dw1 |= TO_DW1_PORT_NUM(qtd->urb->dev->ttport); in create_ptd_atl()
857 ptd->dw1 |= TO_DW1_HUB_NUM(qtd->urb->dev->tt->hub->devnum); in create_ptd_atl()
860 if (usb_pipeint(qtd->urb->pipe) && in create_ptd_atl()
861 (qtd->urb->dev->speed == USB_SPEED_LOW)) in create_ptd_atl()
868 if (usb_pipecontrol(qtd->urb->pipe) || in create_ptd_atl()
869 usb_pipebulk(qtd->urb->pipe)) in create_ptd_atl()
874 ptd->dw2 |= TO_DW2_DATA_START_ADDR(base_to_chip(qtd->payload_addr)); in create_ptd_atl()
880 if (usb_pipecontrol(qtd->urb->pipe)) { in create_ptd_atl()
881 if (qtd->data_buffer == qtd->urb->setup_packet) in create_ptd_atl()
883 else if (last_qtd_of_urb(qtd, qh)) in create_ptd_atl()
893 struct isp1760_qtd *qtd, struct ptd *ptd) in transform_add_int() argument
907 if (qtd->urb->dev->speed == USB_SPEED_HIGH) { in transform_add_int()
909 period = qtd->urb->interval >> 3; in transform_add_int()
911 if (qtd->urb->interval > 4) in transform_add_int()
914 else if (qtd->urb->interval > 2) in transform_add_int()
916 else if (qtd->urb->interval > 1) in transform_add_int()
922 period = qtd->urb->interval; in transform_add_int()
945 struct isp1760_qtd *qtd, struct ptd *ptd) in create_ptd_int() argument
947 create_ptd_atl(qh, qtd, ptd); in create_ptd_int()
948 transform_add_int(qh, qtd, ptd); in create_ptd_int()
980 struct isp1760_qtd *qtd; in qtd_alloc() local
982 qtd = kmem_cache_zalloc(qtd_cachep, flags); in qtd_alloc()
983 if (!qtd) in qtd_alloc()
986 INIT_LIST_HEAD(&qtd->qtd_list); in qtd_alloc()
987 qtd->urb = urb; in qtd_alloc()
988 qtd->packet_type = packet_type; in qtd_alloc()
989 qtd->status = QTD_ENQUEUED; in qtd_alloc()
990 qtd->actual_length = 0; in qtd_alloc()
992 return qtd; in qtd_alloc()
995 static void qtd_free(struct isp1760_qtd *qtd) in qtd_free() argument
997 WARN_ON(qtd->payload_addr); in qtd_free()
998 kmem_cache_free(qtd_cachep, qtd); in qtd_free()
1003 struct isp1760_qtd *qtd, struct isp1760_qh *qh, in start_bus_transfer() argument
1011 WARN_ON(qtd->length && !qtd->payload_addr); in start_bus_transfer()
1012 WARN_ON(slots[slot].qtd); in start_bus_transfer()
1014 WARN_ON(qtd->status != QTD_PAYLOAD_ALLOC); in start_bus_transfer()
1036 qtd->status = QTD_XFER_STARTED; in start_bus_transfer()
1038 slots[slot].qtd = qtd; in start_bus_transfer()
1048 static int is_short_bulk(struct isp1760_qtd *qtd) in is_short_bulk() argument
1050 return (usb_pipebulk(qtd->urb->pipe) && in is_short_bulk()
1051 (qtd->actual_length < qtd->length)); in is_short_bulk()
1057 struct isp1760_qtd *qtd, *qtd_next; in collect_qtds() local
1061 list_for_each_entry_safe(qtd, qtd_next, &qh->qtd_list, qtd_list) { in collect_qtds()
1062 if (qtd->status < QTD_XFER_COMPLETE) in collect_qtds()
1065 last_qtd = last_qtd_of_urb(qtd, qh); in collect_qtds()
1067 if ((!last_qtd) && (qtd->status == QTD_RETIRE)) in collect_qtds()
1070 if (qtd->status == QTD_XFER_COMPLETE) { in collect_qtds()
1071 if (qtd->actual_length) { in collect_qtds()
1072 switch (qtd->packet_type) { in collect_qtds()
1074 mem_read(hcd, qtd->payload_addr, in collect_qtds()
1075 qtd->data_buffer, in collect_qtds()
1076 qtd->actual_length); in collect_qtds()
1079 qtd->urb->actual_length += in collect_qtds()
1080 qtd->actual_length; in collect_qtds()
1087 if (is_short_bulk(qtd)) { in collect_qtds()
1088 if (qtd->urb->transfer_flags & URB_SHORT_NOT_OK) in collect_qtds()
1089 qtd->urb->status = -EREMOTEIO; in collect_qtds()
1095 if (qtd->payload_addr) in collect_qtds()
1096 free_mem(hcd, qtd); in collect_qtds()
1099 if ((qtd->status == QTD_RETIRE) && in collect_qtds()
1100 (qtd->urb->status == -EINPROGRESS)) in collect_qtds()
1101 qtd->urb->status = -EPIPE; in collect_qtds()
1107 urb_listitem->urb = qtd->urb; in collect_qtds()
1111 list_del(&qtd->qtd_list); in collect_qtds()
1112 qtd_free(qtd); in collect_qtds()
1127 struct isp1760_qtd *qtd; in enqueue_qtds() local
1149 if ((free_slot == -1) && (slots[curr_slot].qtd == NULL)) in enqueue_qtds()
1156 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) { in enqueue_qtds()
1157 if (qtd->status == QTD_ENQUEUED) { in enqueue_qtds()
1158 WARN_ON(qtd->payload_addr); in enqueue_qtds()
1159 alloc_mem(hcd, qtd); in enqueue_qtds()
1160 if ((qtd->length) && (!qtd->payload_addr)) in enqueue_qtds()
1163 if (qtd->length && (qtd->packet_type == SETUP_PID || in enqueue_qtds()
1164 qtd->packet_type == OUT_PID)) { in enqueue_qtds()
1165 mem_write(hcd, qtd->payload_addr, in enqueue_qtds()
1166 qtd->data_buffer, qtd->length); in enqueue_qtds()
1169 qtd->status = QTD_PAYLOAD_ALLOC; in enqueue_qtds()
1172 if (qtd->status == QTD_PAYLOAD_ALLOC) { in enqueue_qtds()
1180 if (usb_pipeint(qtd->urb->pipe)) in enqueue_qtds()
1181 create_ptd_int(qh, qtd, &ptd); in enqueue_qtds()
1183 create_ptd_atl(qh, qtd, &ptd); in enqueue_qtds()
1186 slots, qtd, qh, &ptd); in enqueue_qtds()
1362 struct isp1760_qtd *qtd; in handle_done_ptds() local
1388 slots[slot].qtd->urb); in handle_done_ptds()
1403 slots[slot].qtd->urb); in handle_done_ptds()
1406 qtd = slots[slot].qtd; in handle_done_ptds()
1407 slots[slot].qtd = NULL; in handle_done_ptds()
1412 WARN_ON(qtd->status != QTD_XFER_STARTED); in handle_done_ptds()
1416 if ((usb_pipeint(qtd->urb->pipe)) && in handle_done_ptds()
1417 (qtd->urb->dev->speed != USB_SPEED_HIGH)) in handle_done_ptds()
1418 qtd->actual_length = in handle_done_ptds()
1421 qtd->actual_length = in handle_done_ptds()
1424 qtd->status = QTD_XFER_COMPLETE; in handle_done_ptds()
1425 if (list_is_last(&qtd->qtd_list, &qh->qtd_list) || in handle_done_ptds()
1426 is_short_bulk(qtd)) in handle_done_ptds()
1427 qtd = NULL; in handle_done_ptds()
1429 qtd = list_entry(qtd->qtd_list.next, in handle_done_ptds()
1430 typeof(*qtd), qtd_list); in handle_done_ptds()
1437 qtd->status = QTD_PAYLOAD_ALLOC; in handle_done_ptds()
1449 qtd->status = QTD_RETIRE; in handle_done_ptds()
1450 if ((qtd->urb->dev->speed != USB_SPEED_HIGH) && in handle_done_ptds()
1451 (qtd->urb->status != -EPIPE) && in handle_done_ptds()
1452 (qtd->urb->status != -EREMOTEIO)) { in handle_done_ptds()
1454 if (usb_hub_clear_tt_buffer(qtd->urb)) in handle_done_ptds()
1459 qtd = NULL; in handle_done_ptds()
1469 if (qtd && (qtd->status == QTD_PAYLOAD_ALLOC)) { in handle_done_ptds()
1476 create_ptd_int(qh, qtd, &ptd); in handle_done_ptds()
1479 create_ptd_atl(qh, qtd, &ptd); in handle_done_ptds()
1482 start_bus_transfer(hcd, ptd_offset, slot, slots, qtd, in handle_done_ptds()
1748 static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len) in qtd_fill() argument
1750 qtd->data_buffer = databuffer; in qtd_fill()
1752 qtd->length = len; in qtd_fill()
1754 return qtd->length; in qtd_fill()
1759 struct isp1760_qtd *qtd, *qtd_next; in qtd_list_free() local
1761 list_for_each_entry_safe(qtd, qtd_next, qtd_list, qtd_list) { in qtd_list_free()
1762 list_del(&qtd->qtd_list); in qtd_list_free()
1763 qtd_free(qtd); in qtd_list_free()
1777 struct isp1760_qtd *qtd; in packetize_urb() local
1801 qtd = qtd_alloc(flags, urb, SETUP_PID); in packetize_urb()
1802 if (!qtd) in packetize_urb()
1804 qtd_fill(qtd, urb->setup_packet, sizeof(struct usb_ctrlrequest)); in packetize_urb()
1805 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1826 qtd = qtd_alloc(flags, urb, packet_type); in packetize_urb()
1827 if (!qtd) in packetize_urb()
1835 this_qtd_len = qtd_fill(qtd, buf, this_qtd_len); in packetize_urb()
1836 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1865 qtd = qtd_alloc(flags, urb, packet_type); in packetize_urb()
1866 if (!qtd) in packetize_urb()
1870 qtd_fill(qtd, NULL, 0); in packetize_urb()
1871 list_add_tail(&qtd->qtd_list, head); in packetize_urb()
1985 priv->atl_slots[qh->slot].qtd = NULL; in kill_transfer()
1993 priv->int_slots[qh->slot].qtd = NULL; in kill_transfer()
2004 struct isp1760_qtd *qtd) in dequeue_urb_from_qtd() argument
2009 urb = qtd->urb; in dequeue_urb_from_qtd()
2011 list_for_each_entry_from(qtd, &qh->qtd_list, qtd_list) { in dequeue_urb_from_qtd()
2012 if (qtd->urb != urb) in dequeue_urb_from_qtd()
2015 if (qtd->status >= QTD_XFER_STARTED) in dequeue_urb_from_qtd()
2017 if (last_qtd_of_urb(qtd, qh) && in dequeue_urb_from_qtd()
2018 (qtd->status >= QTD_XFER_COMPLETE)) in dequeue_urb_from_qtd()
2021 if (qtd->status == QTD_XFER_STARTED) in dequeue_urb_from_qtd()
2023 qtd->status = QTD_RETIRE; in dequeue_urb_from_qtd()
2040 struct isp1760_qtd *qtd; in isp1760_urb_dequeue() local
2054 list_for_each_entry(qtd, &qh->qtd_list, qtd_list) in isp1760_urb_dequeue()
2055 if (qtd->urb == urb) { in isp1760_urb_dequeue()
2056 dequeue_urb_from_qtd(hcd, qh, qtd); in isp1760_urb_dequeue()
2057 list_move(&qtd->qtd_list, &qh->qtd_list); in isp1760_urb_dequeue()