From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Sun, 1 Jun 2014 19:22:45 +0200 Subject: [U-Boot] [PATCH 4/4] usb: ci_udc: complete ep0 direction handling In-Reply-To: <1401396783-21873-4-git-send-email-swarren@wwwdotorg.org> References: <1401396783-21873-1-git-send-email-swarren@wwwdotorg.org> <1401396783-21873-4-git-send-email-swarren@wwwdotorg.org> Message-ID: <201406011922.45126.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thursday, May 29, 2014 at 10:53:03 PM, Stephen Warren wrote: > From: Stephen Warren > > handle_setup() currently assumes that the response to a Setup transaction > will be an OUT transaction, and any subsequent packet (if any) will be an > IN transaction. This appears to be valid in many cases; both USB > enumeration and Mass Storage work OK with this restriction. However, DFU > uses ep0 to transfer data in both directions. This renders the assumption > invalid; when sending data from device to host, the Data Stage is an IN > transaction, and the Status Stage is an OUT transaction. Enhance > handle_setup() to deduce the correct direction for the USB transactions > based on Setup transaction data. > > ep0's request object only needs to be automatically re-queued when the > Data Stage completes, in order to implement the Status Stage. Once the > Status Stage transaction is complete, there is no need to re-queue the > USB request, so don't do that. > > Don't sent USB request completion callbacks for Status Stage transactions. > These were queued by ci_udc itself, and only serve to confuse the USB > function code. For example, f_dfu attempts to interpret the 0-length data > buffers for Status Stage transactions as DFU packets. These buffers > contain stale data from the previous transaction. This causes f_dfu to > complain about a sequence number mismatch. > > Signed-off-by: Stephen Warren > --- > drivers/usb/gadget/ci_udc.c | 48 > ++++++++++++++++++++++++++++++++++++++------- drivers/usb/gadget/ci_udc.h > | 1 + > 2 files changed, 42 insertions(+), 7 deletions(-) Applied all, thanks. btw. we should weed out those DBG() macros and replace them with regular debug() or debug_cond(). Best regards, Marek Vasut