Commit 5c33addf authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] ehci misc patches

small fixes flushed by the hunt for bigger game:

- terminate td lists with dummy, not list end marker
- use alt_next only for real short control reads
- un-halt async qhs before scheduling
- deletes unused debug code, pointless assignments
- surely nobody ever sees that memleak
- terminate two related "while" loops the same way
parent bdd00dbd
...@@ -884,7 +884,7 @@ static void ehci_free_config (struct usb_hcd *hcd, struct usb_device *udev) ...@@ -884,7 +884,7 @@ static void ehci_free_config (struct usb_hcd *hcd, struct usb_device *udev)
*/ */
while (qh->qh_state == QH_STATE_LINKED while (qh->qh_state == QH_STATE_LINKED
&& ehci->reclaim && ehci->reclaim
&& ehci->hcd.state != USB_STATE_HALT && HCD_IS_RUNNING (ehci->hcd.state)
) { ) {
spin_unlock_irqrestore (&ehci->lock, flags); spin_unlock_irqrestore (&ehci->lock, flags);
/* wait_ms() won't spin, we're a thread; /* wait_ms() won't spin, we're a thread;
......
...@@ -73,11 +73,6 @@ qtd_fill (struct ehci_qtd *qtd, dma_addr_t buf, size_t len, int token) ...@@ -73,11 +73,6 @@ qtd_fill (struct ehci_qtd *qtd, dma_addr_t buf, size_t len, int token)
qtd->hw_token = cpu_to_le32 ((count << 16) | token); qtd->hw_token = cpu_to_le32 ((count << 16) | token);
qtd->length = count; qtd->length = count;
#if 0
vdbg (" qtd_fill %p, token %8x bytes %d dma %x",
qtd, le32_to_cpu (qtd->hw_token), count, qtd->hw_buf [0]);
#endif
return count; return count;
} }
...@@ -315,16 +310,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs) ...@@ -315,16 +310,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs)
spin_unlock (&urb->lock); spin_unlock (&urb->lock);
list_del (&qtd->qtd_list); list_del (&qtd->qtd_list);
#if 0
if (urb->status == -EINPROGRESS)
vdbg (" qtd %p ok, urb %p, token %8x, len %d",
qtd, urb, token, urb->actual_length);
else
vdbg ("urb %p status %d, qtd %p, token %8x, len %d",
urb, urb->status, qtd, token,
urb->actual_length);
#endif
} }
/* last urb's completion might still need calling */ /* last urb's completion might still need calling */
...@@ -387,7 +372,6 @@ qh_urb_transaction ( ...@@ -387,7 +372,6 @@ qh_urb_transaction (
qtd = ehci_qtd_alloc (ehci, flags); qtd = ehci_qtd_alloc (ehci, flags);
if (unlikely (!qtd)) if (unlikely (!qtd))
return 0; return 0;
qtd_prev = 0;
list_add_tail (&qtd->qtd_list, head); list_add_tail (&qtd->qtd_list, head);
qtd->urb = urb; qtd->urb = urb;
...@@ -395,6 +379,8 @@ qh_urb_transaction ( ...@@ -395,6 +379,8 @@ qh_urb_transaction (
token |= (EHCI_TUNE_CERR << 10); token |= (EHCI_TUNE_CERR << 10);
/* for split transactions, SplitXState initialized to zero */ /* for split transactions, SplitXState initialized to zero */
len = urb->transfer_buffer_length;
is_input = usb_pipein (urb->pipe);
if (usb_pipecontrol (urb->pipe)) { if (usb_pipecontrol (urb->pipe)) {
/* SETUP pid */ /* SETUP pid */
qtd_fill (qtd, urb->setup_dma, sizeof (struct usb_ctrlrequest), qtd_fill (qtd, urb->setup_dma, sizeof (struct usb_ctrlrequest),
...@@ -410,15 +396,14 @@ qh_urb_transaction ( ...@@ -410,15 +396,14 @@ qh_urb_transaction (
qtd_prev->hw_next = QTD_NEXT (qtd->qtd_dma); qtd_prev->hw_next = QTD_NEXT (qtd->qtd_dma);
list_add_tail (&qtd->qtd_list, head); list_add_tail (&qtd->qtd_list, head);
if (!(urb->transfer_flags & URB_SHORT_NOT_OK)) if (len > 0 && is_input
&& !(urb->transfer_flags & URB_SHORT_NOT_OK))
status_patch = 1; status_patch = 1;
} }
/* /*
* data transfer stage: buffer setup * data transfer stage: buffer setup
*/ */
len = urb->transfer_buffer_length;
is_input = usb_pipein (urb->pipe);
if (likely (len > 0)) if (likely (len > 0))
buf = urb->transfer_dma; buf = urb->transfer_dma;
else else
...@@ -595,7 +580,6 @@ ehci_qh_make ( ...@@ -595,7 +580,6 @@ ehci_qh_make (
if (qh->period < 1) { if (qh->period < 1) {
dbg ("intr period %d uframes, NYET!", dbg ("intr period %d uframes, NYET!",
urb->interval); urb->interval);
qh = 0;
goto done; goto done;
} }
} else { } else {
...@@ -656,6 +640,8 @@ ehci_qh_make ( ...@@ -656,6 +640,8 @@ ehci_qh_make (
break; break;
default: default:
dbg ("bogus dev %p speed %d", urb->dev, urb->dev->speed); dbg ("bogus dev %p speed %d", urb->dev, urb->dev->speed);
done:
qh_put (ehci, qh);
return 0; return 0;
} }
...@@ -682,8 +668,6 @@ ehci_qh_make ( ...@@ -682,8 +668,6 @@ ehci_qh_make (
/* initialize data toggle state */ /* initialize data toggle state */
clear_toggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, qh); clear_toggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, qh);
done:
return qh; return qh;
} }
#undef hb_mult #undef hb_mult
...@@ -715,6 +699,8 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh) ...@@ -715,6 +699,8 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
} }
} }
qh->hw_token &= ~__constant_cpu_to_le32 (QTD_STS_HALT);
/* splice right after start */ /* splice right after start */
qh->qh_next = head->qh_next; qh->qh_next = head->qh_next;
qh->hw_next = head->hw_next; qh->hw_next = head->hw_next;
...@@ -791,8 +777,8 @@ static struct ehci_qh *qh_append_tds ( ...@@ -791,8 +777,8 @@ static struct ehci_qh *qh_append_tds (
*/ */
token = qtd->hw_token; token = qtd->hw_token;
qtd->hw_token = 0; qtd->hw_token = 0;
wmb ();
dummy = qh->dummy; dummy = qh->dummy;
// dbg ("swap td %p with dummy %p", qtd, dummy);
dma = dummy->qtd_dma; dma = dummy->qtd_dma;
*dummy = *qtd; *dummy = *qtd;
...@@ -805,6 +791,7 @@ static struct ehci_qh *qh_append_tds ( ...@@ -805,6 +791,7 @@ static struct ehci_qh *qh_append_tds (
qh->dummy = qtd; qh->dummy = qtd;
/* hc must see the new dummy at list end */ /* hc must see the new dummy at list end */
dma = qtd->qtd_dma;
qtd = list_entry (qh->qtd_list.prev, qtd = list_entry (qh->qtd_list.prev,
struct ehci_qtd, qtd_list); struct ehci_qtd, qtd_list);
qtd->hw_next = QTD_NEXT (dma); qtd->hw_next = QTD_NEXT (dma);
...@@ -839,7 +826,6 @@ static struct ehci_qh *qh_append_tds ( ...@@ -839,7 +826,6 @@ static struct ehci_qh *qh_append_tds (
} else { } else {
/* can't sleep here, we have ehci->lock... */ /* can't sleep here, we have ehci->lock... */
qh = ehci_qh_make (ehci, urb, qtd_list, SLAB_ATOMIC); qh = ehci_qh_make (ehci, urb, qtd_list, SLAB_ATOMIC);
// if (qh) dbg_qh ("new qh", ehci, qh);
*ptr = qh; *ptr = qh;
} }
if (qh) if (qh)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment