Re: Testing endpoint halt support for raw-gadget

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

 



On Sat, 25 Apr 2020, Andrey Konovalov wrote:

> On Sat, Apr 25, 2020 at 3:53 AM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On Fri, 24 Apr 2020, Andrey Konovalov wrote:
> >
> > > On Fri, Apr 24, 2020 at 9:36 PM Andrey Konovalov <andreyknvl@xxxxxxxxxx> wrote:
> >
> > > > Hi Alan,
> > > >
> > > > I've started working on a test suite for raw-gadget based on the
> > > > usbtest module as you suggested and have a few questions:
> > > >
> > > > 1. (Re test #10:) Currently there's no way to stall USB (control)
> > > > requests with raw-gadget (which is what happens when you return -EPIPE
> > > > from gadget's setup() callback AFAIU). Is stalling an important part
> > > > of the protocol? Should we somehow support it? AFAIU gadgetfs also has
> > > > no ability to stall requests that are passed to userspace.
> >
> > Yes, stalling is important, and you do need to support it.  gadgetfs
> > does have a way to stall requests on ep0 from userspace: just perform
> > I/O in the "wrong" direction.  If the host sends a control-IN request
> > and the user does a read of the ep0 file, or if the host sends a
> > control-OUT request and the user does a write, gadgetfs will call
> > usb_ep_set_halt.  (However I do not remember how the setup_can_stall
> > flag is meant to work.)
> 
> Ah, so halting ep0 after having successfully received a setup stage
> request (setup() callback returns 0) will result in a stall during the
> data stage

Or during the status stage, if there is no data stage (a 0-length 
transfer).

>  (I hope I'm using those "stage" terms right) without the
> gadget needing to queue an URB as it happens during a normal response?

Yes.

> Shouldn't this halt the endpoint until the user (or the gadget)
> unhalts it? Does this work when we want to just stall a single
> request? What happens with the requests that come after?

Ep0 is special.  See the description of protocol stalls in sections 
8.4.5 and 8.5.3 (especially 8.5.3.4) in the USB 2.0 spec.

Think about the problem for a moment.  Suppose a halt of ep0 persisted 
until it was cleared by the host.  Then it would never get cleared -- 
the only way the host can clear a halt condition is by sending a 
Clear-Halt request on ep0!

Alan Stern




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

  Powered by Linux