All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sid Spry" <sid@aeam.us>
To: "Alan Stern" <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org
Subject: Re: Unable to Use Isochronous Behavior w/ Isoc Endpoint in FunctionFC
Date: Mon, 22 Jun 2020 16:13:39 -0500	[thread overview]
Message-ID: <26bbc5be-0329-4f78-9ba8-7d3d773a8d09@www.fastmail.com> (raw)
In-Reply-To: <20200622164115.GD137824@rowland.harvard.edu>

On Mon, Jun 22, 2020, at 11:41 AM, Alan Stern wrote:
> On Mon, Jun 22, 2020 at 10:41:14AM -0500, Sid Spry wrote:
> > On Mon, Jun 22, 2020, at 9:02 AM, Alan Stern wrote:
> > > On Sun, Jun 21, 2020 at 09:25:53PM -0500, Sid Spry wrote:
> > > > I now must ask the list: What is the relation of the isochronous endpoint setup
> > > > to the allocated bandwidth on the bus?
> > > 
> > > Bandwidth allocation is determined by the host controller driver, or in 
> > > the case of xHCI, hardware.  Therefore it will vary with different drivers 
> > > or controllers.
> > > 
> > 
> > Ok, variation I expected. Sadly it seems like I am not made aware of which
> > interface alternate setting is chosen.
> > 
> > See: https://elixir.bootlin.com/linux/latest/source/drivers/usb/gadget/
> > function/f_fs.c#L3265.
> > 
> > The ctrlrequest struct (https://elixir.bootlin.com/linux/latest/source/include
> > /uapi/linux/usb/ch9.h#L213) is only sent for SETUP events. Of which I have
> > yet to triggered.
> 
> Like I said before, you'll need to ask someone who knows more about 
> FunctionFS.
> 

This is a mailing list, I am not only expecting you to reply.

> > > > libusb seems to encounter an error:
> > > > 
> > > > (pyusb error output)
> > > > ```
> > > > >>> import usb
> > > > >>> ds = [d for d in usb.core.find(find_all=True, idVendor=0x1d6b, idProduct=0x0104)]
> > > > >>> d = ds[0]
> > > > >>> d.set_interface_altsetting(interface=1, alternate_setting=1)
> > > > Traceback (most recent call last):
> > > >   File "<stdin>", line 1, in <module>
> > > >   File "/usr/lib/python3.7/site-packages/usb/core.py", line 902, in set_interface_altsetting
> > > >     self._ctx.managed_set_interface(self, interface, alternate_setting)
> > > >   File "/usr/lib/python3.7/site-packages/usb/core.py", line 102, in wrapper
> > > >     return f(self, *args, **kwargs)
> > > >   File "/usr/lib/python3.7/site-packages/usb/core.py", line 204, in managed_set_interface
> > > >     self.backend.set_interface_altsetting(self.handle, i.bInterfaceNumber, alt)
> > > >   File "/usr/lib/python3.7/site-packages/usb/backend/libusb1.py", line 807, in set_interface_altsetting
> > > >     altsetting))
> > > >   File "/usr/lib/python3.7/site-packages/usb/backend/libusb1.py", line 595, in _check
> > > >     raise USBError(_strerror(ret), ret, _libusb_errno[ret])
> > > > usb.core.USBError: [Errno None] Other error
> > > > ```
> > > > 
> > > > (libusb error from C code)
> > > > ```
> > > > libusb: error [op_set_interface] setintf failed error -1 errno 32
> > > > ```
> > > 
> > > Error 32 means that the device returned a STALL status when it received 
> > > the Set-Interface request.  The code responsible for this error response 
> > > might be in FunctionFS or in your driver.
> > >
> > 
> > I see the set-interface request in my code as a read/write error on the endpoints
> > (errno 11: resource temporarily unavailable) and an enable event. Otherwise
> > most things "just happen."
> > 
> > I've had issues reusing endpoint numbers like you are supposed to. Either the
> > descriptors aren't accepted or more commonly the UDC won't bind. E.g. I have
> > to give interface 0 eps 1, 2 and interface 1 eps 3, 4. The numbering is preserved
> > on the host, kind of. Eps are compacted into their numbering based on direction.
> > So you see interface 0 with eps 0x81 and 0x01, and interface 1 with eps 0x82 
> > and 0x02.
> 
> That's exactly how it's supposed to work.  Don't mix up endpoint _numbers_ 
> with endpoint _addresses_; they aren't the same thing.  Read through the 
> USB-2.0 specification for more information.
> 
> Also don't forget that two interfaces in the same configuration are not 
> allowed to share an endpoint (other than endpoint 0, which doesn't really 
> belong to any interface).
> 
> > This isn't causing me problems per se but does seem improper.
> 
> Why?
> 

Ah, yes, I was mixing up numbers/addresses. Strange as the only useful
number to me seems to be the address.

> > I'll look through the functionfs code when I have some time. The user mode
> > does not seem to be passed much information.
> 
> If you think this is a weakness of FunctionFS and it needs to be fixed, 
> report it to the FunctionFS maintainers.  See the MAINTAINERS file in the 
> top-level directory of the kernel source code.
> 
> > > > But, if interface 1 alternate setting 0 is dropped, and interface 1 alternate
> > > > setting 1 is kept, both invocations work and my C code spits out data very
> > > > fast, although I must inspect it further as I seem to be duplicating data in my
> > > > reads.
> > > 
> > > If you drop altsetting 0 then you're probably not issuing a Set-Interface 
> > > request.  That would explain why you don't get a failure.
> > > 
> > > If you like, you can try issuing a Set-Interface(0) request (even though 
> > > it's redundant) just to see if it fails.
> > > 
> > 
> > Ah, yes, I had done set-interface(0 [, 0]). set-interface(1, 0) also works. It is just
> > set-interface(1, 1) that is nonfunctional when an alternate mode 0 is provided.
> 
> Okay.  Maybe the problem occurs in the code that enables the endpoints for 
> altsetting 1.
> 

I do appreciate the help, I'll report to the maintainers later. I'll have to table it for
now. As it is I'm able to send reliably on each frame so I'm happy.

      reply	other threads:[~2020-06-22 21:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-21  3:38 Unable to Use Isochronous Behavior w/ Isoc Endpoint in FunctionFC Sid Spry
2020-06-21 14:09 ` Alan Stern
2020-06-22  2:25   ` Sid Spry
2020-06-22 14:02     ` Alan Stern
2020-06-22 15:41       ` Sid Spry
2020-06-22 16:41         ` Alan Stern
2020-06-22 21:13           ` Sid Spry [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26bbc5be-0329-4f78-9ba8-7d3d773a8d09@www.fastmail.com \
    --to=sid@aeam.us \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.