public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* Stalling non-0-length OUT control requests in Raw Gadget/GadgetFS
@ 2024-06-14 22:31 Andrey Konovalov
  2024-06-15  2:12 ` Alan Stern
  0 siblings, 1 reply; 12+ messages in thread
From: Andrey Konovalov @ 2024-06-14 22:31 UTC (permalink / raw)
  To: Alan Stern; +Cc: USB list

Hi Alan,

I'm working on implementing a USB proxy that uses libusb on one side
and Raw Gadget on the other. The idea is to pass all requests received
from the host via Raw Gadget to the proxied device via libusb and
report back the responses.

However, I've stumbled upon an issue with non-0-length control
requests that get stalled by the proxied device.

To pass an OUT control request to the device via libusb I need to
first retrieve the data for the request from the host. And with Raw
Gadget I can do that via USB_RAW_IOCTL_EP0_READ, which internally
calls usb_ep_queue, waits for its completion, and copies the data to
userspace.

But the problem is that once I retrieve the data, the request is
automatically acked. Thus, if the proxied device stalls the request,
it's already too late to stall it via Raw Gadget.

AFAIU, GadgetFS works the same way.

Is there a way to work around this? If this requires a change is Raw
Gadget, that is fine. But I'm wondering if this is possible to do at
all with the USB Gadget API: AFAIU, we have to either stall or
retrieve the data; we cannot do both.

If this is indeed impossible, perhaps you know if there's a way to
directly use usbfs to separately submit the control request header to
the proxied device to figure out if it wants to stall? And only then
retrieve the data from the host via Raw Gadget if the device doesn't
stall.

Thank you!

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-06-21  7:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-14 22:31 Stalling non-0-length OUT control requests in Raw Gadget/GadgetFS Andrey Konovalov
2024-06-15  2:12 ` Alan Stern
2024-06-15 20:49   ` Andrey Konovalov
2024-06-16  2:33     ` Alan Stern
2024-06-16 22:42       ` Andrey Konovalov
2024-06-17  2:10         ` Alan Stern
2024-06-17  6:29           ` Greg KH
2024-06-17 15:02             ` Partial isochronous support for dummy-hcd [was: Re: Stalling non-0-length OUT control requests in Raw Gadget/GadgetFS] Alan Stern
2024-06-19  1:44       ` Stalling non-0-length OUT control requests in Raw Gadget/GadgetFS Paul Elder
2024-06-19  1:46         ` Alan Stern
2024-06-20 12:57         ` Andrey Konovalov
2024-06-21  7:12           ` Paul Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox