comment in ep0_txstate() states:

"report completions as soon as the fifo's loaded; there's no win
 in waiting till this last packet gets acked".

This is wrong for using dfu. In the dfu usecase we must send
a PollTimeout to the host, so the host can wait until the
U-Boot Code is ready for answering new usb requests. So the
answer which contains the PollTimeout must send *before*
U-Boot calls req->complete.

The req->complete is used in the dfu case for flushing the
medium, when entering DFU_STATE_dfuMANIFEST_SYNC state.

Signed-off-by: Heiko Schocher <h...@denx.de>
Cc: Lukasz Majewski <l.majew...@samsung.com>
Cc: Kyungmin Park <kyungmin.p...@samsung.com>
Cc: Marek Vasut <ma...@denx.de>
Cc: Pantelis Antoniou <pa...@antoniou-consulting.com>

---

Tested on the dxr2 and pxm2 boards. If dfu_flush() needs longer
then 5 sec, dfu-util breaks with current mainline code:

[...]
finished!
unable to read DFU status
$

With this patch, it shows again:

[...]
finished!
state(7) = dfuMANIFEST, status(0) = No error condition is present
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
$
---
 drivers/usb/musb-new/musb_gadget_ep0.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb-new/musb_gadget_ep0.c 
b/drivers/usb/musb-new/musb_gadget_ep0.c
index 6599d38..8c3b0a1 100644
--- a/drivers/usb/musb-new/musb_gadget_ep0.c
+++ b/drivers/usb/musb-new/musb_gadget_ep0.c
@@ -576,6 +576,10 @@ static void ep0_txstate(struct musb *musb)
        } else
                request = NULL;
 
+       /* send it out, triggering a "txpktrdy cleared" irq */
+       musb_ep_select(musb->mregs, 0);
+       musb_writew(regs, MUSB_CSR0, csr);
+
        /* report completions as soon as the fifo's loaded; there's no
         * win in waiting till this last packet gets acked.  (other than
         * very precise fault reporting, needed by USB TMC; possible with
@@ -588,10 +592,6 @@ static void ep0_txstate(struct musb *musb)
                        return;
                musb->ackpend = 0;
        }
-
-       /* send it out, triggering a "txpktrdy cleared" irq */
-       musb_ep_select(musb->mregs, 0);
-       musb_writew(regs, MUSB_CSR0, csr);
 }
 
 /*
-- 
1.8.3.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to