&& urb->status == 0) {
urb->status = -EREMOTEIO;
#ifdef ADMHC_VERBOSE_DEBUG
- urb_print(urb, "SHORT", usb_pipeout (urb->pipe));
+ urb_print(ahcd, urb, "SHORT", usb_pipeout(urb->pipe));
#endif
}
spin_unlock(&urb->lock);
}
#ifdef ADMHC_VERBOSE_DEBUG
- urb_print(urb, "RET", usb_pipeout (urb->pipe));
+ urb_print(ahcd, urb, "RET", usb_pipeout (urb->pipe));
#endif
/* urb->complete() can reenter this HCD */
unsigned i;
admhc_vdbg (ahcd, "link %sed %p branch %d [%dus.], interval %d\n",
- (ed->hwINFO & cpu_to_hc32 (ahcd, ED_ISO)) ? "iso " : "",
+ (ed->hwINFO & cpu_to_hc32(ahcd, ED_ISO)) ? "iso " : "",
ed, ed->branch, ed->load, ed->interval);
for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
admhcd_to_hcd(ahcd)->self.bandwidth_allocated -= ed->load / ed->interval;
admhc_vdbg (ahcd, "unlink %sed %p branch %d [%dus.], interval %d\n",
- (ed->hwINFO & cpu_to_hc32 (ahcd, ED_ISO)) ? "iso " : "",
+ (ed->hwINFO & cpu_to_hc32(ahcd, ED_ISO)) ? "iso " : "",
ed, ed->branch, ed->load, ed->interval);
}
#endif
unsigned long flags;
spin_lock_irqsave(&ahcd->lock, flags);
+
ed = ep->hcpriv;
if (!ed) {
u32 info;
if (ed)
ep->hcpriv = ed;
}
+
spin_unlock_irqrestore(&ahcd->lock, flags);
return ed;
*/
static void start_ed_unlink(struct admhcd *ahcd, struct ed *ed)
{
- ed->hwINFO |= cpu_to_hc32 (ahcd, ED_DEQUEUE);
+ ed->hwINFO |= cpu_to_hc32(ahcd, ED_DEQUEUE);
ed_deschedule(ahcd, ed);
/* add this ED into the remove list */
int cnt = 0;
u32 info = 0;
int is_out = usb_pipeout(urb->pipe);
- int periodic = 0;
u32 toggle = 0;
- struct td *td;
/* OHCI handles the bulk/interrupt data toggles itself. We just
* use the device toggle bits for resetting, and rely on the fact
/* calculate transfer length/status and update the urb
* PRECONDITION: irqsafe (only for urb->status locking)
*/
-static void td_done(struct admhcd *ahcd, struct urb *urb, struct td *td)
+static int td_done(struct admhcd *ahcd, struct urb *urb, struct td *td)
{
+ struct urb_priv *urb_priv = urb->hcpriv;
u32 info = hc32_to_cpup(ahcd, &td->hwINFO);
int type = usb_pipetype(urb->pipe);
- int cc = TD_CC_NOERROR;
+ int cc;
+
+ cc = TD_CC_GET(info);
/* ISO ... drivers see per-TD length/status */
if (type == PIPE_ISOCHRONOUS) {
u32 bl = TD_BL_GET(hc32_to_cpup(ahcd, &td->hwCBL));
u32 tdDBP = hc32_to_cpup(ahcd, &td->hwDBP);
- cc = TD_CC_GET(info);
-
/* update packet status if needed (short is normally ok) */
if (cc == TD_CC_DATAUNDERRUN
&& !(urb->transfer_flags & URB_SHORT_NOT_OK))
cc = TD_CC_NOERROR;
if (cc != TD_CC_NOERROR && cc < TD_CC_HCD0) {
- admhc_dump_ed(ahcd, "CC ERROR", td->ed, 1);
spin_lock(&urb->lock);
if (urb->status == -EINPROGRESS)
urb->status = cc_to_error[cc];
}
list_del(&td->td_list);
+ urb_priv->td_idx++;
+ return cc;
}
/*-------------------------------------------------------------------------*/
struct urb *urb = td->urb;
struct ed *ed = td->ed;
struct list_head *tmp = td->td_list.next;
- __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ahcd, ED_C);
+ __hc32 toggle = ed->hwHeadP & cpu_to_hc32(ahcd, ED_C);
admhc_dump_ed(ahcd, "ed halted", td->ed, 1);
/* clear ed halt; this is the td that caused it, but keep it inactive
* until its urb->complete() has a chance to clean up.
*/
- ed->hwINFO |= cpu_to_hc32 (ahcd, ED_SKIP);
- wmb ();
- ed->hwHeadP &= ~cpu_to_hc32 (ahcd, ED_H);
+ ed->hwINFO |= cpu_to_hc32(ahcd, ED_SKIP);
+ wmb();
+ ed->hwHeadP &= ~cpu_to_hc32(ahcd, ED_H);
/* put any later tds from this urb onto the donelist, after 'td',
* order won't matter here: no errors, and nothing was transferred.
*/
info = next->hwINFO;
#if 0 /* FIXME */
- info |= cpu_to_hc32 (ahcd, TD_DONE);
- info &= ~cpu_to_hc32 (ahcd, TD_CC);
+ info |= cpu_to_hc32(ahcd, TD_DONE);
#endif
+ info &= ~cpu_to_hc32(ahcd, TD_CC);
next->hwINFO = info;
next->next_dl_td = rev;
break;
/* fallthrough */
case TD_CC_STALL:
- if (usb_pipecontrol (urb->pipe))
+ if (usb_pipecontrol(urb->pipe))
break;
/* fallthrough */
default:
continue;
}
- if (!list_empty (&ed->td_list)) {
+ if (!list_empty(&ed->td_list)) {
struct td *td;
u32 head;
rescan_this:
completed = 0;
prev = &ed->hwHeadP;
- list_for_each_safe (entry, tmp, &ed->td_list) {
+ list_for_each_safe(entry, tmp, &ed->td_list) {
struct td *td;
struct urb *urb;
struct urb_priv *urb_priv;
*prev = td->hwNextTD | savebits;
/* HC may have partly processed this TD */
- urb_print(urb, "PARTIAL",1);
+ urb_print(ahcd, urb, "PARTIAL", 1);
td_done(ahcd, urb, td);
- urb_priv->td_idx++;
/* if URB is done, clean up */
if (urb_priv->td_idx == urb_priv->td_cnt) {
finish_urb(ahcd, urb);
}
}
- if (completed && !list_empty (&ed->td_list))
+ if (completed && !list_empty(&ed->td_list))
goto rescan_this;
/* ED's now officially unlinked, hc doesn't see */
ed->hwHeadP &= ~cpu_to_hc32(ahcd, ED_H);
ed->hwNextED = 0;
wmb ();
- ed->hwINFO &= ~cpu_to_hc32 (ahcd, ED_SKIP | ED_DEQUEUE);
+ ed->hwINFO &= ~cpu_to_hc32(ahcd, ED_SKIP | ED_DEQUEUE);
/* but if there's work queued, reschedule */
- if (!list_empty (&ed->td_list)) {
+ if (!list_empty(&ed->td_list)) {
if (HC_IS_RUNNING(admhcd_to_hcd(ahcd)->state))
ed_schedule(ahcd, ed);
}
* scanning the (re-reversed) donelist as this does.
*/
+static void ed_unhalt(struct admhcd *ahcd, struct ed *ed, struct urb *urb)
+{
+ struct list_head *entry,*tmp;
+ __hc32 toggle = ed->hwHeadP & cpu_to_hc32(ahcd, ED_C);
+
+#ifdef ADMHC_VERBOSE_DEBUG
+ admhc_dump_ed(ahcd, "UNHALT", ed, 0);
+#endif
+ /* clear ed halt; this is the td that caused it, but keep it inactive
+ * until its urb->complete() has a chance to clean up.
+ */
+ ed->hwINFO |= cpu_to_hc32(ahcd, ED_SKIP);
+ wmb();
+ ed->hwHeadP &= ~cpu_to_hc32(ahcd, ED_H);
+
+ list_for_each_safe(entry, tmp, &ed->td_list) {
+ struct td *td = list_entry(entry, struct td, td_list);
+ __hc32 info;
+
+ if (td->urb != urb)
+ break;
+
+ info = td->hwINFO;
+ info &= ~cpu_to_hc32(ahcd, TD_CC | TD_OWN);
+ td->hwINFO = info;
+
+ ed->hwHeadP = td->hwNextTD | toggle;
+ wmb();
+ }
+
+}
+
+static inline int is_ed_halted(struct admhcd *ahcd, struct ed *ed)
+{
+ return ((hc32_to_cpup(ahcd, &ed->hwHeadP) & ED_H) == ED_H);
+}
+
+static inline int is_td_halted(struct admhcd *ahcd, struct ed *ed,
+ struct td *td)
+{
+ return ((hc32_to_cpup(ahcd, &ed->hwHeadP) & TD_MASK) ==
+ (hc32_to_cpup(ahcd, &td->hwNextTD) & TD_MASK));
+}
+
static void ed_update(struct admhcd *ahcd, struct ed *ed)
{
struct list_head *entry,*tmp;
- admhc_dump_ed(ahcd, "ed update", ed, 1);
+#ifdef ADMHC_VERBOSE_DEBUG
+ admhc_dump_ed(ahcd, "UPDATE", ed, 0);
+#endif
list_for_each_safe(entry, tmp, &ed->td_list) {
struct td *td = list_entry(entry, struct td, td_list);
struct urb *urb = td->urb;
struct urb_priv *urb_priv = urb->hcpriv;
+ int cc;
if (hc32_to_cpup(ahcd, &td->hwINFO) & TD_OWN)
break;
/* update URB's length and status from TD */
- td_done(ahcd, urb, td);
- urb_priv->td_idx++;
+ cc = td_done(ahcd, urb, td);
+ if (is_ed_halted(ahcd, ed) && is_td_halted(ahcd, ed, td))
+ ed_unhalt(ahcd, ed, urb);
/* If all this urb's TDs are done, call complete() */
if (urb_priv->td_idx == urb_priv->td_cnt)
start_ed_unlink(ahcd, ed);
/* ... reenabling halted EDs only after fault cleanup */
- } else if ((ed->hwINFO & cpu_to_hc32 (ahcd,
+ } else if ((ed->hwINFO & cpu_to_hc32(ahcd,
ED_SKIP | ED_DEQUEUE))
- == cpu_to_hc32 (ahcd, ED_SKIP)) {
+ == cpu_to_hc32(ahcd, ED_SKIP)) {
td = list_entry(ed->td_list.next, struct td, td_list);
#if 0
- if (!(td->hwINFO & cpu_to_hc32 (ahcd, TD_DONE))) {
- ed->hwINFO &= ~cpu_to_hc32 (ahcd, ED_SKIP);
+ if (!(td->hwINFO & cpu_to_hc32(ahcd, TD_DONE))) {
+ ed->hwINFO &= ~cpu_to_hc32(ahcd, ED_SKIP);
/* ... hc may need waking-up */
switch (ed->type) {
case PIPE_CONTROL:
}
}
-static void ed_halt(struct admhcd *ahcd, struct ed *ed)
-{
- admhc_dump_ed(ahcd, "ed_halt", ed, 1);
-}
-
/* there are some tds completed; called in_irq(), with HCD locked */
static void admhc_td_complete(struct admhcd *ahcd)
{
if (ed->state != ED_OPER)
continue;
- if (hc32_to_cpup(ahcd, &ed->hwINFO) & ED_SKIP)
- continue;
-
- if (hc32_to_cpup(ahcd, &ed->hwHeadP) & ED_H) {
- ed_halt(ahcd, ed);
- continue;
- }
-
ed_update(ahcd, ed);
}
}