[U-Boot] [PATCH 4/4] usb: ci_udc: complete ep0 direction handling

Marek Vasut marex at denx.de
Sun Jun 1 19:22:45 CEST 2014


On Thursday, May 29, 2014 at 10:53:03 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren at nvidia.com>
> 
> 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 <swarren at nvidia.com>
> ---
>  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


More information about the U-Boot mailing list