public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] musb-new, dfu: first send request answer then call completions
@ 2014-04-10  5:08 Heiko Schocher
  2014-04-10  5:08 ` [U-Boot] [PATCH 2/2] dfu, nand: add medium specific polltimeout function Heiko Schocher
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Heiko Schocher @ 2014-04-10  5:08 UTC (permalink / raw)
  To: u-boot

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 <hs@denx.de>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Pantelis Antoniou <panto@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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-05-08  8:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-10  5:08 [U-Boot] [PATCH 1/2] musb-new, dfu: first send request answer then call completions Heiko Schocher
2014-04-10  5:08 ` [U-Boot] [PATCH 2/2] dfu, nand: add medium specific polltimeout function Heiko Schocher
2014-04-10  7:54   ` Marek Vasut
2014-04-10  8:29     ` Pantelis Antoniou
2014-04-10 10:08       ` Lukasz Majewski
2014-04-10 10:21         ` Heiko Schocher
2014-04-10 14:31           ` Lukasz Majewski
2014-04-11  4:22             ` Heiko Schocher
2014-04-11  7:20               ` Lukasz Majewski
2014-04-10 11:10         ` Marek Vasut
2014-04-10  7:50 ` [U-Boot] [PATCH 1/2] musb-new, dfu: first send request answer then call completions Marek Vasut
2014-05-08  8:47 ` Lukasz Majewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox