On Fri, Jun 28, 2024 at 09:39:10PM +0200, Andrey Konovalov wrote: > On Fri, Jun 28, 2024 at 8:33 PM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > > Checking whether the device is suspended is subject to races. The > > result would not be fully reliable. > > I see. > > I assume doing a wake-up-if-suspended procedure within a single ioctl > would not be race free as well? That's a reasonable thing to do; after all, if the gadget is already at full power then a wakeup request will simply fail. In fact, raw-gadget wouldn't even have to do the test; the UDC core takes care of it. Of course, there's then nothing to stop the host from putting the gadget back into suspend right away. But that's not the gadget's fault. Alan Stern > But overall, I don't view the userspace <-> Raw Gadget <-> Gadget core > <-> UDC driver <-> UDC approach to be very robust in general. My > understanding is that you need to be very close to the hardware to > implement decent USB emulation. So perhaps, we could just add the > ioctl and document it as being racy. > > Thank you!