On Fri, Jan 19, 2024 at 01:48:13PM +0800, yuan linyu wrote: > When write UDC to empty and unbind gadget driver from gadget device, it is > possible that there are many queue failures for mass storage function. > > The root cause is on platform like dwc3, if pull down called first, the > queue operation from mass storage main thread will fail as it is belong to > another thread context and always try to receive a command from host. > > In order to fix it, call gadget driver disconnect callback first, mass > storage function driver will disable endpoints and clear running flag, > so there will be no request queue to UDC. > > One note is when call disconnect callback first, it mean function will > disable endpoints before stop UDC controller. Exactly. So instead of getting a bunch of errors on the gadget, now you'll get a bunch of errors on the host. I don't think that's any better. Why don't you change the dwc3 driver instead? If it allowed ep_queue operations to succeed while the pull-up is off then this problem would go away. Alan Stern