From: Arnaud Mandy <ext-arnaud.2.mandy@xxxxxxxxx> It seems like the hardware is generating irq before setting RxPktRdy in the RxCSR register, so let's wait a little bit until that gets set. Signed-off-by: Arnaud Mandy <ext-arnaud.2.mandy@xxxxxxxxx> Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxx> --- drivers/usb/musb/musb_gadget.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 2f09a9e..808a432 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -637,9 +637,21 @@ static void do_pio_rx(struct musb *musb, struct musb_request *req) void __iomem *epio = musb->endpoints[epnum].regs; unsigned fifo_count = 0; u16 count = musb_ep->packet_sz; + int retries = 1000; csr = musb_readw(epio, MUSB_RXCSR); + /* RxPktRdy should be the only possibility here. + * Sometimes the IRQ is generated before + * RxPktRdy gets set, so we'll wait a while. */ + while (!(csr & MUSB_RXCSR_RXPKTRDY)) { + if (retries-- == 0) { + DBG(1, "RxPktRdy did not get set (CSR %04x)\n", csr); + BUG_ON(!(csr & MUSB_RXCSR_RXPKTRDY)); + } + csr = musb_readw(epio, MUSB_RXCSR); + } + musb_ep->busy = 1; count = musb_readw(epio, MUSB_RXCOUNT); -- 1.6.4.2.253.g0b1fac -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html