Hi Maynard, On 11/7/2018 2:07 AM, Maynard CABIENTE wrote: > Hi John, > > Sorry re-sending as it was detected as spam before (due to HTML subpart). > > I’m not certain if you are the correct person that maintains the > drivers/usb/dwc2 for Linux kernel 4.14. I noticed that 4.20 is a different > person. > > We are using an Altera Cyclone V SoC FPGA on our board with linux kernel > 4.14.44 and enabling the USB gadget for HID (keyboard and mouse) and mass > storage (2 interfaces). The USB will always be configured for USB gadget (and > never host). At times, we are encountering the kernel warning as seen below. > It can happen a few times and it may cause our board to reboot. This mostly > happens when a USB reset occurs and the (HID and mass storage) gadget is in a > connected state. > > Here is my understanding of the issue. > > When in connected state and a USB reset has occurred, the irq handler > dwc2_hstog_irq() will report the disconnection to the individual gadget > functions (e.g. hid and mass storage). Each hid gadget function (keyboard and > mouse) will call hidg_disable() and will in turn disable the USB endpoints > and clear the respective bits in the FIFO map. Each mass storage function > will also call fsg_disable() and will in turn disable the USB endpoints and > clear the bits in the FIFO map. The function > dwc2_hsotg_core_init_disconnected() will be called afterwards and it assumes > that all the USB endpoints have been disabled already and FIFO map is zeroed > out. > > What I notice here is that there is a race condition that can happen where > the mass storage gadget function can be delayed in disabling the USB > endpoints prior to the call to dwc2_hsotg_core_init_disconnected(), which > results to the kernel warning message: > > [ 135.400063] WARNING: CPU: 0 PID: 0 at ../drivers/usb/dwc2/gadget.c:300 > dwc2_hsotg_init_fifo+0x34/0x1b4 > [ 135.409327] Modules linked in: usb_f_mass_storage usb_f_hid libcomposite > [ 135.416020] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.14.44-kx4+ #8 > [ 135.422433] Hardware name: Altera SOCFPGA > [ 135.426450] [<c011107c>] (unwind_backtrace) from [<c010d20c>] > (show_stack+0x20/0x24) > [ 135.434170] [<c010d20c>] (show_stack) from [<c06e7ae8>] > (dump_stack+0xa4/0xd8) > [ 135.441375] [<c06e7ae8>] (dump_stack) from [<c0120910>] (__warn+0xe0/0x110) > [ 135.448318] [<c0120910>] (__warn) from [<c0120a10>] > (warn_slowpath_null+0x30/0x38) > [ 135.455866] [<c0120a10>] (warn_slowpath_null) from [<c047a938>] > (dwc2_hsotg_init_fifo+0x34/0x1b4) > [ 135.464714] [<c047a938>] (dwc2_hsotg_init_fifo) from [<c047eafc>] > (dwc2_hsotg_core_init_disconnected+0xb8/0x4ac) > [ 135.474856] [<c047eafc>] (dwc2_hsotg_core_init_disconnected) from > [<c047eff0>] (dwc2_hsotg_irq.part.4+0x100/0x9a4) > [ 135.485168] [<c047eff0>] (dwc2_hsotg_irq.part.4) from [<c047f8c4>] > (dwc2_hsotg_irq+0x30/0x3c) > [ 135.493671] [<c047f8c4>] (dwc2_hsotg_irq) from [<c016f8ec>] > (__handle_irq_event_percpu+0xb0/0x2bc) > [ 135.502602] [<c016f8ec>] (__handle_irq_event_percpu) from [<c016fb24>] > (handle_irq_event_percpu+0x2c/0x68) > [ 135.512223] [<c016fb24>] (handle_irq_event_percpu) from [<c016fbcc>] > (handle_irq_event+0x6c/0x90) > [ 135.521066] [<c016fbcc>] (handle_irq_event) from [<c0173e40>] > (handle_fasteoi_irq+0xb4/0x158) > [ 135.529562] [<c0173e40>] (handle_fasteoi_irq) from [<c016ea6c>] > (generic_handle_irq+0x28/0x38) > [ 135.538145] [<c016ea6c>] (generic_handle_irq) from [<c016f128>] > (__handle_domain_irq+0x9c/0xc4) > [ 135.546815] [<c016f128>] (__handle_domain_irq) from [<c01014fc>] > (gic_handle_irq+0x5c/0x88) > [ 135.555140] [<c01014fc>] (gic_handle_irq) from [<c0703570>] > (__irq_svc+0x70/0x98) > [ 135.562591] Exception stack(0xc0c01f00 to 0xc0c01f48) > > I am hoping that you will be able to help me determine a possible solution to > this kernel warning. I tried to put a delay to the call to > dwc2_hsotg_core_init_disconnected() in dwc2_hstog_irq() by using a workqueue > but there are other issues that popped up. I appreciate any help I can get to > resolve this issue.
This warn message popup due to on disconnect not all EP's are disabled and FIFO released in fifo_map. To solve this issue I submitted patches: [PATCH v2] usb: dwc2: Disable all EP's on disconnect and fix to above patch: [PATCH] usb: dwc2: Fix ep disable spinlock flow. Please apply these patches and test. Let me know if this fix your issue. Thanks, Minas > > Regards, > Maynard > > > ________________________________ > > Ce message, ainsi que tous les fichiers joints à ce message, peuvent contenir > des informations sensibles et/ ou confidentielles ne devant pas être > divulguées. Si vous n'êtes pas le destinataire de ce message (ou que vous > recevez ce message par erreur), nous vous remercions de le notifier > immédiatement à son expéditeur, et de détruire ce message. Toute copie, > divulgation, modification, utilisation ou diffusion, non autorisée, directe > ou indirecte, de tout ou partie de ce message, est strictement interdite. > > > This e-mail, and any document attached hereby, may contain confidential > and/or privileged information. If you are not the intended recipient (or have > received this e-mail in error) please notify the sender immediately and > destroy this e-mail. Any unauthorized, direct or indirect, copying, > disclosure, distribution or other use of the material or parts thereof is > strictly forbidden. >
