提交 0afb20e0 编写于 作者: W Warren Free 提交者: Greg Kroah-Hartman

USB: isp1760: urb_dequeue doesn't always find the urbs

The option driver (and presumably others) allocates several URBs when it
opens and tries to free them when it closes. The isp1760_urb_dequeue
function gets called, but the packet being dequeued is not necessarily at
the
front of one of the 32 queues. If not, the isp1760_urb_done function doesn't
get called for the URB and the process trying to free it hangs forever on a
wait_queue. This patch does two things. If the URB being dequeued has others
queued behind it, it re-queues them. And it searches the queues looking for
the URB being dequeued rather than just looking at the one at the front of
the queue.

[bigeasy@linutronix] whitespace fixes, reformating

Cc: stable <stable@kernel.org>
Signed-off-by: NWarren Free <wfree@ipmn.com>
Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 cab98a0a
...@@ -1658,6 +1658,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, ...@@ -1658,6 +1658,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
u32 reg_base, or_reg, skip_reg; u32 reg_base, or_reg, skip_reg;
unsigned long flags; unsigned long flags;
struct ptd ptd; struct ptd ptd;
packet_enqueue *pe;
switch (usb_pipetype(urb->pipe)) { switch (usb_pipetype(urb->pipe)) {
case PIPE_ISOCHRONOUS: case PIPE_ISOCHRONOUS:
...@@ -1669,6 +1670,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, ...@@ -1669,6 +1670,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
reg_base = INT_REGS_OFFSET; reg_base = INT_REGS_OFFSET;
or_reg = HC_INT_IRQ_MASK_OR_REG; or_reg = HC_INT_IRQ_MASK_OR_REG;
skip_reg = HC_INT_PTD_SKIPMAP_REG; skip_reg = HC_INT_PTD_SKIPMAP_REG;
pe = enqueue_an_INT_packet;
break; break;
default: default:
...@@ -1676,6 +1678,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, ...@@ -1676,6 +1678,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
reg_base = ATL_REGS_OFFSET; reg_base = ATL_REGS_OFFSET;
or_reg = HC_ATL_IRQ_MASK_OR_REG; or_reg = HC_ATL_IRQ_MASK_OR_REG;
skip_reg = HC_ATL_PTD_SKIPMAP_REG; skip_reg = HC_ATL_PTD_SKIPMAP_REG;
pe = enqueue_an_ATL_packet;
break; break;
} }
...@@ -1687,6 +1690,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, ...@@ -1687,6 +1690,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
u32 skip_map; u32 skip_map;
u32 or_map; u32 or_map;
struct isp1760_qtd *qtd; struct isp1760_qtd *qtd;
struct isp1760_qh *qh = ints->qh;
skip_map = isp1760_readl(hcd->regs + skip_reg); skip_map = isp1760_readl(hcd->regs + skip_reg);
skip_map |= 1 << i; skip_map |= 1 << i;
...@@ -1699,8 +1703,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, ...@@ -1699,8 +1703,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
priv_write_copy(priv, (u32 *)&ptd, hcd->regs + reg_base priv_write_copy(priv, (u32 *)&ptd, hcd->regs + reg_base
+ i * sizeof(ptd), sizeof(ptd)); + i * sizeof(ptd), sizeof(ptd));
qtd = ints->qtd; qtd = ints->qtd;
qtd = clean_up_qtdlist(qtd);
clean_up_qtdlist(qtd);
free_mem(priv, ints->payload); free_mem(priv, ints->payload);
...@@ -1711,7 +1714,24 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, ...@@ -1711,7 +1714,24 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
ints->payload = 0; ints->payload = 0;
isp1760_urb_done(priv, urb, status); isp1760_urb_done(priv, urb, status);
if (qtd)
pe(hcd, qh, qtd);
break; break;
} else if (ints->qtd) {
struct isp1760_qtd *qtd, *prev_qtd = ints->qtd;
for (qtd = ints->qtd->hw_next; qtd; qtd = qtd->hw_next) {
if (qtd->urb == urb) {
prev_qtd->hw_next = clean_up_qtdlist(qtd);
isp1760_urb_done(priv, urb, status);
break;
}
prev_qtd = qtd;
}
/* we found the urb before the end of the list */
if (qtd)
break;
} }
ints++; ints++;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册