* [PATCHv2 1/2] musb: NAK timeout scheme on bulk reserved ep
@ 2008-11-04 12:16 Ajay Kumar Gupta
2008-11-04 12:40 ` Felipe Balbi
0 siblings, 1 reply; 2+ messages in thread
From: Ajay Kumar Gupta @ 2008-11-04 12:16 UTC (permalink / raw)
To: --to
Cc: linux-omap, david-b, felipe.balbi, Ajay Kumar Gupta, Ravi Babu,
Swaminathan S, Thomas Abraham
Fixes endpoint starvation issue when more than one bulk qhs
are multiplexed on reserved bulk endpoint.NAK timeout interval
is set for such qhs and next qh is scheduled when NAK timeout
occurs.
This scheme doesn't work for devices which are connected to a
high to full speed tree as there is no NAK timeout interrupt
at musb controller from such devices.
Signed-off-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: Swaminathan S <swami.iyer@ti.com>
Signed-off-by: Thomas Abraham <t-abraham@ti.com>
Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
---
These patches have been created against latest omap git and Felipe's
musb .28 patch series at,
http://marc.info/?l=linux-usb&m=122528597116718&w=2
drivers/usb/musb/musb_host.c | 64 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 30b5685..0b40a00 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1378,6 +1378,50 @@ finish:
#endif
+/* Schedule next qh from musb->in_bulk and add the current qh at tail
+ * to avoid endpoint starvation.
+ */
+static void musb_bulk_nak_timeout(struct musb *musb, struct musb_hw_ep *ep)
+{
+ struct dma_channel *dma;
+ struct urb *urb;
+ void __iomem *mbase = musb->mregs;
+ void __iomem *epio = ep->regs;
+ struct musb_qh *cur_qh, *next_qh;
+ u16 rx_csr;
+
+ musb_ep_select(mbase, ep->epnum);
+ dma = is_dma_capable() ? ep->rx_channel : NULL;
+
+ /* clear nak timeout bit */
+ rx_csr = musb_readw(epio, MUSB_RXCSR);
+ rx_csr &= ~MUSB_RXCSR_DATAERROR;
+ musb_writew(epio, MUSB_RXCSR, rx_csr);
+
+ cur_qh = first_qh(&musb->in_bulk);
+ if (cur_qh) {
+ urb = next_urb(cur_qh);
+ if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) {
+ dma->status = MUSB_DMA_STATUS_CORE_ABORT;
+ musb->dma_controller->channel_abort(dma);
+ urb->actual_length += dma->actual_len;
+ dma->actual_len = 0L;
+ }
+ musb_save_toggle(ep, 1, urb);
+
+ /* delete cur_qh and add to tail to musb->in_bulk */
+ list_del(&cur_qh->ring);
+ list_add_tail(&cur_qh->ring, &musb->in_bulk);
+
+ /* get the next qh from musb->in_bulk */
+ next_qh = first_qh(&musb->in_bulk);
+
+ /* set rx_reinit and schedule the next qh */
+ ep->rx_reinit = 1;
+ musb_start_urb(musb, 1, next_qh);
+ }
+}
+
/*
* Service an RX interrupt for the given IN endpoint; docs cover bulk, iso,
* and high-bandwidth IN transfer cases.
@@ -1449,10 +1493,14 @@ void musb_host_rx(struct musb *musb, u8 epnum)
* we have a candidate... NAKing is *NOT* an error
*/
DBG(6, "RX end %d NAK timeout\n", epnum);
+ if (usb_pipebulk(urb->pipe) && qh->mux == 1 &&
+ !list_is_singular(&musb->in_bulk)) {
+ musb_bulk_nak_timeout(musb, hw_ep);
+ return;
+ }
musb_ep_select(mbase, epnum);
- musb_writew(epio, MUSB_RXCSR,
- MUSB_RXCSR_H_WZC_BITS
- | MUSB_RXCSR_H_REQPKT);
+ rx_csr &= ~MUSB_RXCSR_DATAERROR;
+ musb_writew(epio, MUSB_RXCSR, rx_csr);
goto finish;
} else {
@@ -1795,6 +1843,16 @@ static int musb_schedule(
head = &musb->in_bulk;
else
head = &musb->out_bulk;
+ /* Enable bulk NAK time out scheme when bulk requests are
+ * multiplxed.This scheme doen't work in high speed to full
+ * speed scenario as NAK interrupts are not coming from a
+ * full speed device connected to a high speed device.
+ * NAK timeout interval is 8 (128 uframe or 16ms) for HS and
+ * 4 (8 frame or 8ms) for FS device.
+ */
+ if (is_in && qh->dev)
+ qh->intv_reg =
+ (USB_SPEED_HIGH == qh->dev->speed) ? 8 : 4;
goto success;
} else if (best_end < 0) {
return -ENOSPC;
--
1.5.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2 1/2] musb: NAK timeout scheme on bulk reserved ep
2008-11-04 12:16 [PATCHv2 1/2] musb: NAK timeout scheme on bulk reserved ep Ajay Kumar Gupta
@ 2008-11-04 12:40 ` Felipe Balbi
0 siblings, 0 replies; 2+ messages in thread
From: Felipe Balbi @ 2008-11-04 12:40 UTC (permalink / raw)
To: ext Ajay Kumar Gupta
Cc: --to, linux-omap, david-b, felipe.balbi, Ravi Babu, Swaminathan S,
Thomas Abraham
On Tue, Nov 04, 2008 at 05:46:10PM +0530, Ajay Kumar Gupta wrote:
> Fixes endpoint starvation issue when more than one bulk qhs
> are multiplexed on reserved bulk endpoint.NAK timeout interval
> is set for such qhs and next qh is scheduled when NAK timeout
> occurs.
> This scheme doesn't work for devices which are connected to a
> high to full speed tree as there is no NAK timeout interrupt
> at musb controller from such devices.
applied, thanks
--
balbi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-04 12:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-04 12:16 [PATCHv2 1/2] musb: NAK timeout scheme on bulk reserved ep Ajay Kumar Gupta
2008-11-04 12:40 ` Felipe Balbi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.