RE: [PATCH 18/28] usb: dwc3: ep0: fix Data Phase for transfer sizes aligned to wMaxPacketSize

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

> On Mon, 20 Oct 2014, Paul Zimmerman wrote:
> 
> > > From: linux-usb-owner@xxxxxxxxxxxxxxx [mailto:linux-usb-
> owner@xxxxxxxxxxxxxxx] On Behalf Of David Laight
> > > Sent: Monday, October 20, 2014 2:48 AM
> > >
> > > 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.
> >
> > Also, in the USB 3.0 spec, the corresponding section has been
> modified
> > a bit. The last sentence has been changed to this:
> >
> > "Note that if the amount of data in the data structure that is
> returned
> > to the host *is less than the amount requested by the host* and is an
> > exact multiple of maximum packet size then a control endpoint shall
> send
> > a zero length DP to terminate the data stage." (emphasis mine)
> >
> > So I think you also need to take into account the wLength field of
> the
> > request, and only send the ZLP if the amount of data returned is less
> > than wLength.
> 
> That's right, and it's true for USB-2 as well.  A ZLP is needed only in
> cases where the host otherwise wouldn't know the transfer is over,
> i.e., when the transfer length is a nonzero multiple of the maxpacket
> size and is smaller than wLength.

Shall we use/check struct usb_request's zero flag for this?

> 
> It's not clear what a "variable length" control transfer is supposed to
> be.  I guess it means that sometimes the device will send back less
> than wLength bytes of data.
> 
> Alan Stern
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux