Hi, Dan Scally <dan.scally@xxxxxxxxxxxxxxxx> writes: > Good morning > > On 08/12/2022 06:11, Felipe Balbi wrote: >> Hi, >> >> Dan Scally <dan.scally@xxxxxxxxxxxxxxxx> writes: >>> I'm having an issue with DWC3 which I'm hoping you might be able to shed >>> light on. I'm using the UVC gadget function to stream video from an >>> imx8mp platform, which works just fine. Once I have stopped streaming >>> however and after some time has passed (the exact duration seems to vary >>> quite a lot from 1-2 minutes to 15+ mins) I get a kernel warning like so: >> As Greg mentioned, please add Thinh, the new maintainer, to the loop. > > > Apologies to both of you; for some reason I thought you had taken over > from Thinh rather than the other way around. Thanks for the heads up Greg. no worries, it happens. >> [1] https://kernel.org/doc/html/latest/driver-api/usb/dwc3.html#reporting-bugs > > > Both the trace and regdump should be in the attached .tar.gz Can you confirm which kernel version you're using? It looks like there's a missing End Transfer on ep1in: > uvc-gadget-696 [000] ..... 2646.761444: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Transfer Resource' [402] params 00000001 00000000 00000000 --> status: Successful > irq/208-dwc3-689 [000] D..3. 2647.237436: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Configuration' [401] params 00020086 06070200 00000000 --> status: Successful > irq/208-dwc3-689 [000] D..3. 2647.237457: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [406] params 00000000 45751000 00000000 --> status: Successful > irq/208-dwc3-689 [000] D..3. 2647.237467: dwc3_gadget_ep_enable: ep1in: mps 16/1024 streams 16 burst 0 ring 0/0 flags E:swBp:< > uvc-gadget-696 [003] d..1. 2648.484042: dwc3_gadget_ep_cmd: ep1in: cmd 'End Transfer' [30c08] params 00000000 00000000 00000000 --> status: Successful > uvc-gadget-696 [003] d..3. 2648.490356: dwc3_gadget_ep_disable: ep1in: mps 16/1024 streams 16 burst 0 ring 0/0 flags E:swbp:< > uvc-gadget-698 [001] ..... 2650.645667: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Transfer Resource' [402] params 00000001 00000000 00000000 --> status: Successful > irq/208-dwc3-689 [000] D..3. 2651.141040: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Configuration' [401] params 00020086 06070200 00000000 --> status: Successful > irq/208-dwc3-689 [000] D..3. 2651.141061: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [406] params 00000000 45751000 00000000 --> status: Successful > irq/208-dwc3-689 [000] D..3. 2651.141070: dwc3_gadget_ep_enable: ep1in: mps 16/1024 streams 16 burst 0 ring 0/0 flags E:swBp:< > irq/208-dwc3-689 [000] D..3. 3201.415410: dwc3_gadget_ep_disable: ep1in: mps 16/1024 streams 16 burst 0 ring 0/0 flags E:swBp:< Right here we don't know if DWC3_EP_DELAY_STOP flag is set. In fact, there are many flags which are not decoded to the trace points, which makes this trace point "pointless" as it's not helping with debug activities anymore. In any case, I suspect DELAY_STOP is set at this point, which is causing dwc3_stop_active_transfer() to bail out without issuing the End Transfer command, see lines 3725 - 3728 in gadget.c (quoted below): if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) || (dep->flags & DWC3_EP_DELAY_STOP) || (dep->flags & DWC3_EP_END_TRANSFER_PENDING)) return; This, in turn, will cause a subsequent ep_enable to fail with No Resource, as the resource is still occupied by the same endpoint due to lack of End Transfer. @Thinh, looks like something you should patch up. Also, you should probably go through the trace points and make sure all relevant information is being printed to trace points. We don't want to have to guess what's going on :-) > irq/208-dwc3-689 [000] D..3. 3201.584476: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Configuration' [401] params 00020086 06070200 00000000 --> status: Successful > irq/208-dwc3-689 [000] D..3. 3201.584506: dwc3_send_gadget_ep_cmd: No resource for ep1in > irq/208-dwc3-689 [000] D..3. 3201.814837: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [406] params 00000000 45751000 00000000 --> status: No Resource -- balbi