From: Felipe Balbi
> According to Section 8.5.3.2 of the USB 2.0 specification,
> a USB device must terminate a Data Phase with either a
> short packet or a ZLP (if the previous transfer was
> a multiple of wMaxPacketSize).
>
> For reference, here's what the USB 2.0 specification, section
> 8.5.3.2 says:
>
> "
> 8.5.3.2 Variable-length Data Stage
>
> A control pipe may have a variable-length data phase
> in which the host requests more data than is contained
> in the specified data structure. When all of the data
> structure is returned to the host, the function should
> indicate that the Data stage is ended by returning a
> packet that is shorter than the MaxPacketSize for the
> pipe. If the data structure is an exact multiple of
> wMaxPacketSize for the pipe, the function will return
> a zero-length packet to indicate the end of the Data
> stage.
> "
If that is the same as my understanding of the USB3 spec then the
requirement for a ZLP isn't unconditional.
In particular if the data phase isn't variable length then a ZLP
must not be added.
David
> Signed-off-by: Felipe Balbi <[email protected]>
> ---
> drivers/usb/dwc3/ep0.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
> index a47cc1e..0a34e71 100644
> --- a/drivers/usb/dwc3/ep0.c
> +++ b/drivers/usb/dwc3/ep0.c
> @@ -828,12 +828,18 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
>
> dwc3_ep0_stall_and_restart(dwc);
> } else {
> - /*
> - * handle the case where we have to send a zero packet. This
> - * seems to be case when req.length > maxpacket. Could it be?
> - */
> - if (r)
> - dwc3_gadget_giveback(ep0, r, 0);
> + dwc3_gadget_giveback(ep0, r, 0);
> +
> + if (IS_ALIGNED(ur->length, ep0->endpoint.maxpacket)) {
> + int ret;
> +
> + dwc->ep0_next_event = DWC3_EP0_COMPLETE;
> +
> + ret = dwc3_ep0_start_trans(dwc, epnum,
> + dwc->ctrl_req_addr, 0,
> + DWC3_TRBCTL_CONTROL_DATA);
> + WARN_ON(ret < 0);
> + }
> }
> }
>
> --
> 2.1.0.GIT
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html