Lines Matching +full:self +full:- +full:working
1 // SPDX-License-Identifier: GPL-1.0+
6 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
16 int last = urb_priv->length - 1; in urb_free_priv()
23 td = urb_priv->td [i]; in urb_free_priv()
29 list_del (&urb_priv->pending); in urb_free_priv()
33 /*-------------------------------------------------------------------------*/
42 __releases(ohci->lock) in finish_urb()
43 __acquires(ohci->lock) in finish_urb()
45 struct device *dev = ohci_to_hcd(ohci)->self.controller; in finish_urb()
46 struct usb_host_endpoint *ep = urb->ep; in finish_urb()
49 // ASSERT (urb->hcpriv != 0); in finish_urb()
52 urb_free_priv (ohci, urb->hcpriv); in finish_urb()
53 urb->hcpriv = NULL; in finish_urb()
54 if (likely(status == -EINPROGRESS)) in finish_urb()
57 switch (usb_pipetype (urb->pipe)) { in finish_urb()
59 ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs--; in finish_urb()
60 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) { in finish_urb()
68 ohci_to_hcd(ohci)->self.bandwidth_int_reqs--; in finish_urb()
72 /* urb->complete() can reenter this HCD */ in finish_urb()
74 spin_unlock (&ohci->lock); in finish_urb()
76 spin_lock (&ohci->lock); in finish_urb()
79 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0 in finish_urb()
80 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0) { in finish_urb()
81 ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_IE); in finish_urb()
82 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in finish_urb()
91 if (!list_empty(&ep->urb_list)) { in finish_urb()
92 urb = list_first_entry(&ep->urb_list, struct urb, urb_list); in finish_urb()
93 urb_priv = urb->hcpriv; in finish_urb()
94 if (urb_priv->td_cnt > urb_priv->length) { in finish_urb()
102 /*-------------------------------------------------------------------------*
104 *-------------------------------------------------------------------------*/
111 int i, branch = -ENOSPC; in balance()
121 if (branch < 0 || ohci->load [branch] > ohci->load [i]) { in balance()
126 if ((ohci->load [j] + load) > 900) in balance()
137 /*-------------------------------------------------------------------------*/
148 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "", in periodic_link()
149 ed, ed->branch, ed->load, ed->interval); in periodic_link()
151 for (i = ed->branch; i < NUM_INTS; i += ed->interval) { in periodic_link()
152 struct ed **prev = &ohci->periodic [i]; in periodic_link()
153 __hc32 *prev_p = &ohci->hcca->int_table [i]; in periodic_link()
161 if (ed->interval > here->interval) in periodic_link()
163 prev = &here->ed_next; in periodic_link()
164 prev_p = &here->hwNextED; in periodic_link()
168 ed->ed_next = here; in periodic_link()
170 ed->hwNextED = *prev_p; in periodic_link()
173 *prev_p = cpu_to_hc32(ohci, ed->dma); in periodic_link()
176 ohci->load [i] += ed->load; in periodic_link()
178 ohci_to_hcd(ohci)->self.bandwidth_allocated += ed->load / ed->interval; in periodic_link()
187 ed->ed_prev = NULL; in ed_schedule()
188 ed->ed_next = NULL; in ed_schedule()
189 ed->hwNextED = 0; in ed_schedule()
198 * periodic schedule encodes a tree like figure 3-5 in the ohci in ed_schedule()
202 switch (ed->type) { in ed_schedule()
204 if (ohci->ed_controltail == NULL) { in ed_schedule()
205 WARN_ON (ohci->hc_control & OHCI_CTRL_CLE); in ed_schedule()
206 ohci_writel (ohci, ed->dma, in ed_schedule()
207 &ohci->regs->ed_controlhead); in ed_schedule()
209 ohci->ed_controltail->ed_next = ed; in ed_schedule()
210 ohci->ed_controltail->hwNextED = cpu_to_hc32 (ohci, in ed_schedule()
211 ed->dma); in ed_schedule()
213 ed->ed_prev = ohci->ed_controltail; in ed_schedule()
214 if (!ohci->ed_controltail && !ohci->ed_rm_list) { in ed_schedule()
216 ohci->hc_control |= OHCI_CTRL_CLE; in ed_schedule()
217 ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent); in ed_schedule()
218 ohci_writel (ohci, ohci->hc_control, in ed_schedule()
219 &ohci->regs->control); in ed_schedule()
221 ohci->ed_controltail = ed; in ed_schedule()
225 if (ohci->ed_bulktail == NULL) { in ed_schedule()
226 WARN_ON (ohci->hc_control & OHCI_CTRL_BLE); in ed_schedule()
227 ohci_writel (ohci, ed->dma, &ohci->regs->ed_bulkhead); in ed_schedule()
229 ohci->ed_bulktail->ed_next = ed; in ed_schedule()
230 ohci->ed_bulktail->hwNextED = cpu_to_hc32 (ohci, in ed_schedule()
231 ed->dma); in ed_schedule()
233 ed->ed_prev = ohci->ed_bulktail; in ed_schedule()
234 if (!ohci->ed_bulktail && !ohci->ed_rm_list) { in ed_schedule()
236 ohci->hc_control |= OHCI_CTRL_BLE; in ed_schedule()
237 ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent); in ed_schedule()
238 ohci_writel (ohci, ohci->hc_control, in ed_schedule()
239 &ohci->regs->control); in ed_schedule()
241 ohci->ed_bulktail = ed; in ed_schedule()
247 branch = balance (ohci, ed->interval, ed->load); in ed_schedule()
251 branch, ed->interval, ed->load); in ed_schedule()
255 ed->branch = branch; in ed_schedule()
263 ed->state = ED_OPER; in ed_schedule()
267 /*-------------------------------------------------------------------------*/
274 for (i = ed->branch; i < NUM_INTS; i += ed->interval) { in periodic_unlink()
276 struct ed **prev = &ohci->periodic [i]; in periodic_unlink()
277 __hc32 *prev_p = &ohci->hcca->int_table [i]; in periodic_unlink()
280 prev_p = &temp->hwNextED; in periodic_unlink()
281 prev = &temp->ed_next; in periodic_unlink()
284 *prev_p = ed->hwNextED; in periodic_unlink()
285 *prev = ed->ed_next; in periodic_unlink()
287 ohci->load [i] -= ed->load; in periodic_unlink()
289 ohci_to_hcd(ohci)->self.bandwidth_allocated -= ed->load / ed->interval; in periodic_unlink()
292 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "", in periodic_unlink()
293 ed, ed->branch, ed->load, ed->interval); in periodic_unlink()
305 * drivers don't know about this HCD-internal state.
309 * - ED_OPER: when there's any request queued, the ED gets rescheduled
310 * immediately. HC should be working on them.
312 * - ED_IDLE: when there's no TD queue or the HC isn't running.
319 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP); in ed_deschedule()
321 ed->state = ED_UNLINK; in ed_deschedule()
326 * tightly specified. Figure 6-5 and Section 6.4.2.2 show how in ed_deschedule()
333 switch (ed->type) { in ed_deschedule()
336 if (ed->ed_prev == NULL) { in ed_deschedule()
337 if (!ed->hwNextED) { in ed_deschedule()
338 ohci->hc_control &= ~OHCI_CTRL_CLE; in ed_deschedule()
339 ohci_writel (ohci, ohci->hc_control, in ed_deschedule()
340 &ohci->regs->control); in ed_deschedule()
344 hc32_to_cpup (ohci, &ed->hwNextED), in ed_deschedule()
345 &ohci->regs->ed_controlhead); in ed_deschedule()
347 ed->ed_prev->ed_next = ed->ed_next; in ed_deschedule()
348 ed->ed_prev->hwNextED = ed->hwNextED; in ed_deschedule()
351 if (ohci->ed_controltail == ed) { in ed_deschedule()
352 ohci->ed_controltail = ed->ed_prev; in ed_deschedule()
353 if (ohci->ed_controltail) in ed_deschedule()
354 ohci->ed_controltail->ed_next = NULL; in ed_deschedule()
355 } else if (ed->ed_next) { in ed_deschedule()
356 ed->ed_next->ed_prev = ed->ed_prev; in ed_deschedule()
362 if (ed->ed_prev == NULL) { in ed_deschedule()
363 if (!ed->hwNextED) { in ed_deschedule()
364 ohci->hc_control &= ~OHCI_CTRL_BLE; in ed_deschedule()
365 ohci_writel (ohci, ohci->hc_control, in ed_deschedule()
366 &ohci->regs->control); in ed_deschedule()
370 hc32_to_cpup (ohci, &ed->hwNextED), in ed_deschedule()
371 &ohci->regs->ed_bulkhead); in ed_deschedule()
373 ed->ed_prev->ed_next = ed->ed_next; in ed_deschedule()
374 ed->ed_prev->hwNextED = ed->hwNextED; in ed_deschedule()
377 if (ohci->ed_bulktail == ed) { in ed_deschedule()
378 ohci->ed_bulktail = ed->ed_prev; in ed_deschedule()
379 if (ohci->ed_bulktail) in ed_deschedule()
380 ohci->ed_bulktail->ed_next = NULL; in ed_deschedule()
381 } else if (ed->ed_next) { in ed_deschedule()
382 ed->ed_next->ed_prev = ed->ed_prev; in ed_deschedule()
395 /*-------------------------------------------------------------------------*/
410 spin_lock_irqsave (&ohci->lock, flags); in ed_get()
412 ed = ep->hcpriv; in ed_get()
432 ed->dummy = td; in ed_get()
433 ed->hwTailP = cpu_to_hc32 (ohci, td->td_dma); in ed_get()
434 ed->hwHeadP = ed->hwTailP; /* ED_C, ED_H zeroed */ in ed_get()
435 ed->state = ED_IDLE; in ed_get()
437 is_out = !(ep->desc.bEndpointAddress & USB_DIR_IN); in ed_get()
439 /* FIXME usbcore changes dev->devnum before SET_ADDRESS in ed_get()
443 ed->type = usb_pipetype(pipe); in ed_get()
445 info |= (ep->desc.bEndpointAddress & ~USB_DIR_IN) << 7; in ed_get()
446 info |= usb_endpoint_maxp(&ep->desc) << 16; in ed_get()
447 if (udev->speed == USB_SPEED_LOW) in ed_get()
450 if (ed->type != PIPE_CONTROL) { in ed_get()
452 if (ed->type != PIPE_BULK) { in ed_get()
454 if (ed->type == PIPE_ISOCHRONOUS) in ed_get()
458 ed->interval = interval; in ed_get()
459 ed->load = usb_calc_bus_time ( in ed_get()
460 udev->speed, !is_out, in ed_get()
461 ed->type == PIPE_ISOCHRONOUS, in ed_get()
462 usb_endpoint_maxp(&ep->desc)) in ed_get()
466 ed->hwINFO = cpu_to_hc32(ohci, info); in ed_get()
468 ep->hcpriv = ed; in ed_get()
472 spin_unlock_irqrestore (&ohci->lock, flags); in ed_get()
476 /*-------------------------------------------------------------------------*/
482 * and that ed->state is ED_OPER
486 ed->hwINFO |= cpu_to_hc32 (ohci, ED_DEQUEUE); in start_ed_unlink()
490 ed->ed_next = ohci->ed_rm_list; in start_ed_unlink()
491 ed->ed_prev = NULL; in start_ed_unlink()
492 ohci->ed_rm_list = ed; in start_ed_unlink()
495 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus); in start_ed_unlink()
496 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable); in start_ed_unlink()
498 (void) ohci_readl (ohci, &ohci->regs->control); in start_ed_unlink()
505 ed->tick = ohci_frame_no(ohci) + 1; in start_ed_unlink()
509 /*-------------------------------------------------------------------------*
511 *-------------------------------------------------------------------------*/
521 struct urb_priv *urb_priv = urb->hcpriv; in td_fill()
525 // ASSERT (index < urb_priv->length); in td_fill()
535 * interrupts ... increasing per-urb latency by sharing interrupts. in td_fill()
538 if (index != (urb_priv->length - 1) in td_fill()
539 || (urb->transfer_flags & URB_NO_INTERRUPT)) in td_fill()
543 td_pt = urb_priv->td [index]; in td_fill()
546 td = urb_priv->td [index] = urb_priv->ed->dummy; in td_fill()
547 urb_priv->ed->dummy = td_pt; in td_fill()
549 td->ed = urb_priv->ed; in td_fill()
550 td->next_dl_td = NULL; in td_fill()
551 td->index = index; in td_fill()
552 td->urb = urb; in td_fill()
553 td->data_dma = data; in td_fill()
557 td->hwINFO = cpu_to_hc32 (ohci, info); in td_fill()
559 td->hwCBP = cpu_to_hc32 (ohci, data & 0xFFFFF000); in td_fill()
563 td->hwCBP = cpu_to_hc32 (ohci, data); in td_fill()
566 td->hwBE = cpu_to_hc32 (ohci, data + len - 1); in td_fill()
568 td->hwBE = 0; in td_fill()
569 td->hwNextTD = cpu_to_hc32 (ohci, td_pt->td_dma); in td_fill()
572 list_add_tail (&td->td_list, &td->ed->td_list); in td_fill()
575 hash = TD_HASH_FUNC (td->td_dma); in td_fill()
576 td->td_hash = ohci->td_hash [hash]; in td_fill()
577 ohci->td_hash [hash] = td; in td_fill()
581 td->ed->hwTailP = td->hwNextTD; in td_fill()
584 /*-------------------------------------------------------------------------*/
595 struct urb_priv *urb_priv = urb->hcpriv; in td_submit_urb()
596 struct device *dev = ohci_to_hcd(ohci)->self.controller; in td_submit_urb()
598 int data_len = urb->transfer_buffer_length; in td_submit_urb()
601 int is_out = usb_pipeout (urb->pipe); in td_submit_urb()
610 if (!usb_gettoggle (urb->dev, usb_pipeendpoint (urb->pipe), is_out)) { in td_submit_urb()
611 usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), in td_submit_urb()
613 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); in td_submit_urb()
616 list_add (&urb_priv->pending, &ohci->pending); in td_submit_urb()
618 i = urb->num_mapped_sgs; in td_submit_urb()
620 sg = urb->sg; in td_submit_urb()
624 * urb->transfer_buffer_length may be smaller than the in td_submit_urb()
631 data = urb->transfer_dma; in td_submit_urb()
641 switch (urb_priv->ed->type) { in td_submit_urb()
648 periodic = ohci_to_hcd(ohci)->self.bandwidth_int_reqs++ == 0 in td_submit_urb()
649 && ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0; in td_submit_urb()
661 if (!(urb->transfer_flags & URB_SHORT_NOT_OK)) in td_submit_urb()
665 this_sg_len -= n; in td_submit_urb()
666 data_len -= n; in td_submit_urb()
671 if (--i <= 0 || data_len <= 0) in td_submit_urb()
679 if ((urb->transfer_flags & URB_ZERO_PACKET) in td_submit_urb()
680 && cnt < urb_priv->length) { in td_submit_urb()
685 if (urb_priv->ed->type == PIPE_BULK) { in td_submit_urb()
687 ohci_writel (ohci, OHCI_BLF, &ohci->regs->cmdstatus); in td_submit_urb()
691 /* control manages DATA0/DATA1 toggle per-request; SETUP resets it, in td_submit_urb()
696 td_fill (ohci, info, urb->setup_dma, 8, urb, cnt++); in td_submit_urb()
709 ohci_writel (ohci, OHCI_CLF, &ohci->regs->cmdstatus); in td_submit_urb()
717 for (cnt = urb_priv->td_cnt; cnt < urb->number_of_packets; in td_submit_urb()
719 int frame = urb->start_frame; in td_submit_urb()
722 // roll-around ... exotic case (and OHCI has in td_submit_urb()
724 frame += cnt * urb->interval; in td_submit_urb()
727 data + urb->iso_frame_desc [cnt].offset, in td_submit_urb()
728 urb->iso_frame_desc [cnt].length, urb, cnt); in td_submit_urb()
730 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) { in td_submit_urb()
736 periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0 in td_submit_urb()
737 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0; in td_submit_urb()
744 ohci->hc_control |= OHCI_CTRL_PLE|OHCI_CTRL_IE; in td_submit_urb()
745 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in td_submit_urb()
748 // ASSERT (urb_priv->length == cnt); in td_submit_urb()
751 /*-------------------------------------------------------------------------*
753 *-------------------------------------------------------------------------*/
758 u32 tdINFO = hc32_to_cpup (ohci, &td->hwINFO); in td_done()
760 int status = -EINPROGRESS; in td_done()
762 list_del (&td->td_list); in td_done()
764 /* ISO ... drivers see per-TD length/status */ in td_done()
777 if (usb_pipeout (urb->pipe)) in td_done()
778 dlen = urb->iso_frame_desc [td->index].length; in td_done()
785 urb->actual_length += dlen; in td_done()
786 urb->iso_frame_desc [td->index].actual_length = dlen; in td_done()
787 urb->iso_frame_desc [td->index].status = cc_to_error [cc]; in td_done()
792 urb, td, 1 + td->index, dlen, cc); in td_done()
799 int type = usb_pipetype (urb->pipe); in td_done()
800 u32 tdBE = hc32_to_cpup (ohci, &td->hwBE); in td_done()
806 && !(urb->transfer_flags & URB_SHORT_NOT_OK)) in td_done()
811 /* count all non-empty packets except control SETUP packet */ in td_done()
812 if ((type != PIPE_CONTROL || td->index != 0) && tdBE != 0) { in td_done()
813 if (td->hwCBP == 0) in td_done()
814 urb->actual_length += tdBE - td->data_dma + 1; in td_done()
816 urb->actual_length += in td_done()
817 hc32_to_cpup (ohci, &td->hwCBP) in td_done()
818 - td->data_dma; in td_done()
824 urb, td, 1 + td->index, cc, in td_done()
825 urb->actual_length, in td_done()
826 urb->transfer_buffer_length); in td_done()
831 /*-------------------------------------------------------------------------*/
835 struct urb *urb = td->urb; in ed_halted()
836 urb_priv_t *urb_priv = urb->hcpriv; in ed_halted()
837 struct ed *ed = td->ed; in ed_halted()
838 struct list_head *tmp = td->td_list.next; in ed_halted()
839 __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C); in ed_halted()
842 * until its urb->complete() has a chance to clean up. in ed_halted()
844 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP); in ed_halted()
846 ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H); in ed_halted()
852 while (tmp != &ed->td_list) { in ed_halted()
856 tmp = next->td_list.next; in ed_halted()
858 if (next->urb != urb) in ed_halted()
861 /* NOTE: if multi-td control DATA segments get supported, in ed_halted()
869 list_del(&next->td_list); in ed_halted()
870 urb_priv->td_cnt++; in ed_halted()
871 ed->hwHeadP = next->hwNextTD | toggle; in ed_halted()
880 if ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0) in ed_halted()
884 if (usb_pipecontrol (urb->pipe)) in ed_halted()
889 "urb %p path %s ep%d%s %08x cc %d --> status %d\n", in ed_halted()
890 urb, urb->dev->devpath, in ed_halted()
891 usb_pipeendpoint (urb->pipe), in ed_halted()
892 usb_pipein (urb->pipe) ? "in" : "out", in ed_halted()
893 hc32_to_cpu (ohci, td->hwINFO), in ed_halted()
904 if (td->next_dl_td) in add_to_done_list()
908 ed = td->ed; in add_to_done_list()
910 list_for_each_entry_continue_reverse(td2, &ed->td_list, td_list) { in add_to_done_list()
911 if (td2->next_dl_td) in add_to_done_list()
913 td2->next_dl_td = td_prev; in add_to_done_list()
917 if (ohci->dl_end) in add_to_done_list()
918 ohci->dl_end->next_dl_td = td_prev; in add_to_done_list()
920 ohci->dl_start = td_prev; in add_to_done_list()
923 * Make td->next_dl_td point to td itself, to mark the fact in add_to_done_list()
926 ohci->dl_end = td->next_dl_td = td; in add_to_done_list()
929 td2 = ed->pending_td; in add_to_done_list()
930 if (td2 && td2->next_dl_td) in add_to_done_list()
931 ed->pending_td = NULL; in add_to_done_list()
940 td_dma = hc32_to_cpup (ohci, &ohci->hcca->done_head); in update_done_list()
941 ohci->hcca->done_head = 0; in update_done_list()
945 * add to ours. ed->td_list changes later. in update_done_list()
956 td->hwINFO |= cpu_to_hc32 (ohci, TD_DONE); in update_done_list()
957 cc = TD_CC_GET (hc32_to_cpup (ohci, &td->hwINFO)); in update_done_list()
959 /* Non-iso endpoints can halt on error; un-halt, in update_done_list()
964 && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H))) in update_done_list()
967 td_dma = hc32_to_cpup (ohci, &td->hwNextTD); in update_done_list()
972 /*-------------------------------------------------------------------------*/
981 for (last = &ohci->ed_rm_list, ed = *last; ed != NULL; ed = *last) { in finish_unlinks()
989 if (likely(ohci->rh_state == OHCI_RH_RUNNING) && in finish_unlinks()
990 tick_before(tick, ed->tick)) { in finish_unlinks()
992 last = &ed->ed_next; in finish_unlinks()
995 if (!list_empty(&ed->td_list)) { in finish_unlinks()
999 td = list_first_entry(&ed->td_list, struct td, td_list); in finish_unlinks()
1002 head = hc32_to_cpu(ohci, ed->hwHeadP) & TD_MASK; in finish_unlinks()
1003 if (td->td_dma != head && in finish_unlinks()
1004 ohci->rh_state == OHCI_RH_RUNNING) in finish_unlinks()
1008 if (td->next_dl_td) in finish_unlinks()
1013 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H); in finish_unlinks()
1014 ed->hwNextED = 0; in finish_unlinks()
1016 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE); in finish_unlinks()
1022 *last = ed->ed_next; in finish_unlinks()
1023 ed->ed_next = NULL; in finish_unlinks()
1036 prev = &ed->hwHeadP; in finish_unlinks()
1037 list_for_each_safe (entry, tmp, &ed->td_list) { in finish_unlinks()
1045 urb = td->urb; in finish_unlinks()
1046 urb_priv = td->urb->hcpriv; in finish_unlinks()
1048 if (!urb->unlinked) { in finish_unlinks()
1049 prev = &td->hwNextTD; in finish_unlinks()
1055 *prev = td->hwNextTD | savebits; in finish_unlinks()
1062 tdINFO = hc32_to_cpup(ohci, &td->hwINFO); in finish_unlinks()
1064 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_C); in finish_unlinks()
1066 ed->hwHeadP |= cpu_to_hc32(ohci, ED_C); in finish_unlinks()
1070 urb_priv->td_cnt++; in finish_unlinks()
1073 if (urb_priv->td_cnt >= urb_priv->length) { in finish_unlinks()
1078 if (completed && !list_empty (&ed->td_list)) in finish_unlinks()
1087 if (list_empty(&ed->td_list)) { in finish_unlinks()
1088 ed->state = ED_IDLE; in finish_unlinks()
1089 list_del(&ed->in_use_list); in finish_unlinks()
1090 } else if (ohci->rh_state == OHCI_RH_RUNNING) { in finish_unlinks()
1093 ed->ed_next = ohci->ed_rm_list; in finish_unlinks()
1094 ohci->ed_rm_list = ed; in finish_unlinks()
1096 if (last == &ohci->ed_rm_list) in finish_unlinks()
1097 last = &ed->ed_next; in finish_unlinks()
1105 if (ohci->rh_state == OHCI_RH_RUNNING && !ohci->ed_rm_list) { in finish_unlinks()
1108 if (ohci->ed_controltail) { in finish_unlinks()
1112 if (!(ohci->hc_control & OHCI_CTRL_CLE)) { in finish_unlinks()
1115 &ohci->regs->ed_controlcurrent); in finish_unlinks()
1118 if (ohci->ed_bulktail) { in finish_unlinks()
1122 if (!(ohci->hc_control & OHCI_CTRL_BLE)) { in finish_unlinks()
1125 &ohci->regs->ed_bulkcurrent); in finish_unlinks()
1131 ohci->hc_control |= control; in finish_unlinks()
1134 ohci_writel (ohci, ohci->hc_control, in finish_unlinks()
1135 &ohci->regs->control); in finish_unlinks()
1140 ohci_writel (ohci, command, &ohci->regs->cmdstatus); in finish_unlinks()
1147 /*-------------------------------------------------------------------------*/
1152 struct urb *urb = td->urb; in takeback_td()
1153 urb_priv_t *urb_priv = urb->hcpriv; in takeback_td()
1154 struct ed *ed = td->ed; in takeback_td()
1159 urb_priv->td_cnt++; in takeback_td()
1162 if (urb_priv->td_cnt >= urb_priv->length) in takeback_td()
1166 if (list_empty(&ed->td_list)) { in takeback_td()
1167 if (ed->state == ED_OPER) in takeback_td()
1171 } else if ((ed->hwINFO & cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE)) in takeback_td()
1173 td = list_entry(ed->td_list.next, struct td, td_list); in takeback_td()
1174 if (!(td->hwINFO & cpu_to_hc32(ohci, TD_DONE))) { in takeback_td()
1175 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP); in takeback_td()
1176 /* ... hc may need waking-up */ in takeback_td()
1177 switch (ed->type) { in takeback_td()
1180 &ohci->regs->cmdstatus); in takeback_td()
1184 &ohci->regs->cmdstatus); in takeback_td()
1196 * instead of scanning the (re-reversed) donelist as this does.
1202 while (ohci->dl_start) { in process_done_list()
1203 td = ohci->dl_start; in process_done_list()
1204 if (td == ohci->dl_end) in process_done_list()
1205 ohci->dl_start = ohci->dl_end = NULL; in process_done_list()
1207 ohci->dl_start = td->next_dl_td; in process_done_list()
1214 * TD takeback and URB giveback must be single-threaded.
1219 if (ohci->working) { in ohci_work()
1220 ohci->restart_work = 1; in ohci_work()
1223 ohci->working = 1; in ohci_work()
1227 if (ohci->ed_rm_list) in ohci_work()
1230 if (ohci->restart_work) { in ohci_work()
1231 ohci->restart_work = 0; in ohci_work()
1234 ohci->working = 0; in ohci_work()