On Thu, 20 Dec 2018, Frank Mori Hess wrote: > On Thu, Dec 20, 2018 at 2:12 AM Felipe Balbi <balbi@xxxxxxxxxx> wrote: > > > > You're using a really old kernel. Please try with v4.19.11 or v4.20-rc7 > > > > I have to use an altera patched kernel linux-socfpga to boot my board, > and it always lags behind mainline kernel. If I really had to, I can > probably backport an individual driver (I already backported dwc2 from > 4.17). Anyways, in principal is this a bug in dwc2 or libcomposite? > That is, is libcomposite correct in assuming the dwc2 should call the > gadget "resume" callback when the plug is reinserted? Or should > libcomposite getting just the gadget "reset" be enough for it to know > it may need to update the suspended flag? > > I played around with my hardware a bit more, and when I suspend/resume > the gadget from the host over the usb bus (rather than pulling out > then reinserting the physical cable) it works fine. That is, the dwc2 > hardware generates a suspend interrupt then later a resume/wakeup > interrupt which results in the gadget "resume" callback getting > called. > > However, when pulling/reinserting the cable only the suspend interrupt > is generated. When the cable is reinserted, there is no resume/wakeup > interrupt (only some usb reset interrupts) and thus the gadget > "resume" is never called. Maybe the problem is not lack of a resume callback but lack of a disconnect callback. When an unplugged cable is plugged in again, it is not a resume event but rather a connect event -- and the gadget API does not have callbacks for connect events. When a cable is unplugged it initially appears to be a suspend, but within a few milliseconds the UDC driver should realize what has actually happened. The disconnect callback should follow close on the heels of the suspend callback. Alan Stern