H A D | isp1362-hcd.c | 135 struct isp1362_ep_queue *epq = NULL; get_ptd_queue() local 138 epq = &isp1362_hcd->istl_queue[0]; get_ptd_queue() 140 epq = &isp1362_hcd->istl_queue[1]; get_ptd_queue() 142 epq = &isp1362_hcd->intl_queue; get_ptd_queue() 145 epq = &isp1362_hcd->atl_queue; get_ptd_queue() 147 if (epq) get_ptd_queue() 148 DBG(1, "%s: PTD $%04x is on %s queue\n", __func__, offset, epq->name); get_ptd_queue() 152 return epq; get_ptd_queue() 155 static inline int get_ptd_offset(struct isp1362_ep_queue *epq, u8 index) get_ptd_offset() argument 159 if (index * epq->blk_size > epq->buf_size) { get_ptd_offset() 160 pr_warning("%s: Bad %s index %d(%d)\n", __func__, epq->name, index, get_ptd_offset() 161 epq->buf_size / epq->blk_size); get_ptd_offset() 164 offset = epq->buf_start + index * epq->blk_size; get_ptd_offset() 165 DBG(3, "%s: %s PTD[%02x] # %04x\n", __func__, epq->name, index, offset); get_ptd_offset() 172 static inline u16 max_transfer_size(struct isp1362_ep_queue *epq, size_t size, max_transfer_size() argument 177 xfer_size = min_t(size_t, xfer_size, epq->buf_avail * epq->blk_size - PTD_HEADER_SIZE); max_transfer_size() 184 static int claim_ptd_buffers(struct isp1362_ep_queue *epq, claim_ptd_buffers() argument 188 int num_ptds = ((len + PTD_HEADER_SIZE - 1) / epq->blk_size) + 1; claim_ptd_buffers() 191 BUG_ON(len > epq->buf_size); claim_ptd_buffers() 193 if (!epq->buf_avail) claim_ptd_buffers() 198 epq->name, len, epq->blk_size, num_ptds, epq->buf_map, epq->skip_map); claim_ptd_buffers() 201 found = bitmap_find_next_zero_area(&epq->buf_map, epq->buf_count, 0, claim_ptd_buffers() 203 if (found >= epq->buf_count) claim_ptd_buffers() 207 num_ptds, found, len, (int)(epq->blk_size - PTD_HEADER_SIZE)); claim_ptd_buffers() 208 ptd_offset = get_ptd_offset(epq, found); claim_ptd_buffers() 212 epq->buf_avail -= num_ptds; claim_ptd_buffers() 213 BUG_ON(epq->buf_avail > epq->buf_count); claim_ptd_buffers() 215 bitmap_set(&epq->buf_map, found, num_ptds); claim_ptd_buffers() 217 __func__, epq->name, ep->ptd_index, ep->ptd_offset, claim_ptd_buffers() 218 epq->buf_avail, epq->buf_count, num_ptds, epq->buf_map, epq->skip_map); claim_ptd_buffers() 223 static inline void release_ptd_buffers(struct isp1362_ep_queue *epq, struct isp1362_ep *ep) release_ptd_buffers() argument 227 if (last > epq->buf_count) release_ptd_buffers() 229 __func__, ep, ep->num_req, ep->length, epq->name, ep->ptd_index, release_ptd_buffers() 230 ep->ptd_offset, ep->num_ptds, epq->buf_count, epq->buf_avail, release_ptd_buffers() 231 epq->buf_map, epq->skip_map); release_ptd_buffers() 232 BUG_ON(last > epq->buf_count); release_ptd_buffers() 234 bitmap_clear(&epq->buf_map, ep->ptd_index, ep->num_ptds); release_ptd_buffers() 235 bitmap_set(&epq->skip_map, ep->ptd_index, ep->num_ptds); release_ptd_buffers() 236 epq->buf_avail += ep->num_ptds; release_ptd_buffers() 237 epq->ptd_count--; release_ptd_buffers() 239 BUG_ON(epq->buf_avail > epq->buf_count); release_ptd_buffers() 240 BUG_ON(epq->ptd_count > epq->buf_count); release_ptd_buffers() 243 __func__, epq->name, release_ptd_buffers() 244 ep->ptd_offset, ep->num_ptds, epq->buf_avail, epq->buf_count); release_ptd_buffers() 246 epq->buf_map, epq->skip_map); release_ptd_buffers() 259 struct isp1362_ep *ep, struct isp1362_ep_queue *epq, prepare_ptd() 268 DBG(3, "%s: %s ep %p\n", __func__, epq->name, ep); prepare_ptd() 284 len = max_transfer_size(epq, buf_len, ep->maxpacket); prepare_ptd() 296 len = max_transfer_size(epq, buf_len, ep->maxpacket); prepare_ptd() 344 struct isp1362_ep_queue *epq) isp1362_write_ptd() 360 struct isp1362_ep_queue *epq) isp1362_read_ptd() 369 DBG(1, "%s: ep %p removed from active list %p\n", __func__, ep, &epq->active); isp1362_read_ptd() 400 struct isp1362_ep_queue *epq; remove_ptd() local 405 epq = get_ptd_queue(isp1362_hcd, ep->ptd_offset); remove_ptd() 406 BUG_ON(!epq); remove_ptd() 420 index, ep->ptd_offset, epq->skip_map, 1 << index); remove_ptd() 423 epq->skip_map |= 1 << index; remove_ptd() 424 if (epq == &isp1362_hcd->atl_queue) { remove_ptd() 426 isp1362_read_reg32(isp1362_hcd, HCATLSKIP), epq->skip_map); remove_ptd() 427 isp1362_write_reg32(isp1362_hcd, HCATLSKIP, epq->skip_map); remove_ptd() 428 if (~epq->skip_map == 0) remove_ptd() 430 } else if (epq == &isp1362_hcd->intl_queue) { remove_ptd() 432 isp1362_read_reg32(isp1362_hcd, HCINTLSKIP), epq->skip_map); remove_ptd() 433 isp1362_write_reg32(isp1362_hcd, HCINTLSKIP, epq->skip_map); remove_ptd() 434 if (~epq->skip_map == 0) remove_ptd() 657 struct isp1362_ep_queue *epq = finish_unlinks() local 661 BUG_ON(epq == NULL); finish_unlinks() 665 release_ptd_buffers(epq, ep); finish_unlinks() 712 struct isp1362_ep *ep, struct isp1362_ep_queue *epq) submit_req() 714 int index = epq->free_ptd; submit_req() 716 prepare_ptd(isp1362_hcd, urb, ep, epq, 0); submit_req() 717 index = claim_ptd_buffers(epq, ep, ep->length); submit_req() 720 ep->num_req, epq->name, ep->num_ptds, epq->buf_map, epq->skip_map); submit_req() 724 __func__, ep->num_req, ep->length, epq->name, ep->num_ptds, submit_req() 725 epq->buf_map, epq->skip_map); submit_req() 729 list_add_tail(&ep->active, &epq->active); submit_req() 731 ep, ep->num_req, ep->length, &epq->active); submit_req() 732 DBG(1, "%s: Submitting %s PTD $%04x for ep %p req %d\n", __func__, epq->name, submit_req() 734 isp1362_write_ptd(isp1362_hcd, ep, epq); submit_req() 735 __clear_bit(ep->ptd_index, &epq->skip_map); submit_req() 743 struct isp1362_ep_queue *epq = &isp1362_hcd->atl_queue; start_atl_transfers() local 747 if (atomic_read(&epq->finishing)) { start_atl_transfers() 748 DBG(1, "%s: finish_transfers is active for %s\n", __func__, epq->name); start_atl_transfers() 757 DBG(2, "%s: Skipping active %s ep %p\n", __func__, epq->name, ep); start_atl_transfers() 761 DBG(1, "%s: Processing %s ep %p req %d\n", __func__, epq->name, start_atl_transfers() 764 ret = submit_req(isp1362_hcd, urb, ep, epq); start_atl_transfers() 786 epq->ptd_count += ptd_count; start_atl_transfers() 787 if (epq->ptd_count > epq->stat_maxptds) { start_atl_transfers() 788 epq->stat_maxptds = epq->ptd_count; start_atl_transfers() 789 DBG(0, "%s: max_ptds: %d\n", __func__, epq->stat_maxptds); start_atl_transfers() 796 struct isp1362_ep_queue *epq = &isp1362_hcd->intl_queue; start_intl_transfers() local 799 if (atomic_read(&epq->finishing)) { start_intl_transfers() 800 DBG(1, "%s: finish_transfers is active for %s\n", __func__, epq->name); start_intl_transfers() 810 epq->name, ep); start_intl_transfers() 815 epq->name, ep, ep->num_req); start_intl_transfers() 816 ret = submit_req(isp1362_hcd, urb, ep, epq); start_intl_transfers() 834 epq->ptd_count += ptd_count; start_intl_transfers() 835 if (epq->ptd_count > epq->stat_maxptds) start_intl_transfers() 836 epq->stat_maxptds = epq->ptd_count; start_intl_transfers() 839 static inline int next_ptd(struct isp1362_ep_queue *epq, struct isp1362_ep *ep) next_ptd() argument 842 int num_ptds = (ep->length + PTD_HEADER_SIZE + (epq->blk_size - 1)) / epq->blk_size; next_ptd() 845 ep->length, num_ptds, epq->blk_size, ptd_offset + num_ptds * epq->blk_size); next_ptd() 847 ptd_offset += num_ptds * epq->blk_size; next_ptd() 848 if (ptd_offset < epq->buf_start + epq->buf_size) next_ptd() 858 struct isp1362_ep_queue *epq; start_iso_transfers() local 865 epq = &isp1362_hcd->istl_queue[flip]; start_iso_transfers() 866 if (atomic_read(&epq->finishing)) { start_iso_transfers() 867 DBG(1, "%s: finish_transfers is active for %s\n", __func__, epq->name); start_iso_transfers() 871 if (!list_empty(&epq->active)) start_iso_transfers() 874 ptd_offset = epq->buf_start; start_iso_transfers() 879 DBG(1, "%s: Processing %s ep %p\n", __func__, epq->name, ep); start_iso_transfers() 893 prepare_ptd(isp1362_hcd, urb, ep, epq, fno); start_iso_transfers() 895 epq->buf_start + epq->buf_size) { start_iso_transfers() 901 list_add_tail(&ep->active, &epq->active); start_iso_transfers() 903 ptd_offset = next_ptd(epq, ep); start_iso_transfers() 906 ep->num_req, epq->name); start_iso_transfers() 911 list_for_each_entry(ep, &epq->active, active) { start_iso_transfers() 912 if (epq->active.next == &ep->active) start_iso_transfers() 914 isp1362_write_ptd(isp1362_hcd, ep, epq); start_iso_transfers() 921 epq->ptd_count += ptd_count; start_iso_transfers() 922 if (epq->ptd_count > epq->stat_maxptds) start_iso_transfers() 923 epq->stat_maxptds = epq->ptd_count; start_iso_transfers() 936 struct isp1362_ep_queue *epq) finish_transfers() 941 if (list_empty(&epq->active)) { finish_transfers() 942 DBG(1, "%s: Nothing to do for %s queue\n", __func__, epq->name); finish_transfers() 946 DBG(1, "%s: Finishing %s transfers %08lx\n", __func__, epq->name, done_map); finish_transfers() 948 atomic_inc(&epq->finishing); finish_transfers() 949 list_for_each_entry_safe(ep, tmp, &epq->active, active) { finish_transfers() 952 DBG(1, "%s: Checking %s PTD[%02x] $%04x\n", __func__, epq->name, finish_transfers() 957 isp1362_read_ptd(isp1362_hcd, ep, epq); finish_transfers() 958 epq->free_ptd = index; finish_transfers() 960 release_ptd_buffers(epq, ep); finish_transfers() 968 DBG(1, "%s: Postprocessing %s ep %p req %d\n", __func__, epq->name, finish_transfers() 977 epq->skip_map); finish_transfers() 978 atomic_dec(&epq->finishing); finish_transfers() 981 static void finish_iso_transfers(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep_queue *epq) finish_iso_transfers() argument 986 if (list_empty(&epq->active)) { finish_iso_transfers() 987 DBG(1, "%s: Nothing to do for %s queue\n", __func__, epq->name); finish_iso_transfers() 991 DBG(1, "%s: Finishing %s transfers\n", __func__, epq->name); finish_iso_transfers() 993 atomic_inc(&epq->finishing); finish_iso_transfers() 994 list_for_each_entry_safe(ep, tmp, &epq->active, active) { finish_iso_transfers() 997 isp1362_read_ptd(isp1362_hcd, ep, epq); finish_iso_transfers() 998 DBG(1, "%s: Postprocessing %s ep %p\n", __func__, epq->name, ep); finish_iso_transfers() 1001 WARN_ON(epq->blk_size != 0); finish_iso_transfers() 1002 atomic_dec(&epq->finishing); finish_iso_transfers() 258 prepare_ptd(struct isp1362_hcd *isp1362_hcd, struct urb *urb, struct isp1362_ep *ep, struct isp1362_ep_queue *epq, u16 fno) prepare_ptd() argument 343 isp1362_write_ptd(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *ep, struct isp1362_ep_queue *epq) isp1362_write_ptd() argument 359 isp1362_read_ptd(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *ep, struct isp1362_ep_queue *epq) isp1362_read_ptd() argument 711 submit_req(struct isp1362_hcd *isp1362_hcd, struct urb *urb, struct isp1362_ep *ep, struct isp1362_ep_queue *epq) submit_req() argument 935 finish_transfers(struct isp1362_hcd *isp1362_hcd, unsigned long done_map, struct isp1362_ep_queue *epq) finish_transfers() argument
|