Hi Maynard, On 1/15/2019 3:36 AM, Maynard CABIENTE wrote: > Hi Minas and John, > > I'm hoping that one of you can help me devise a fix to a system hang issue > caused by BNA interrupts on USB Endpoint 0. > > Our system is 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 (either 1 or 2 interfaces). The USB will always be configured > for USB gadget (and never host). > > On a specific case when enumerating the USB gadget, dwc2 will continuously > trigger a BNA interrupts on DPOEPINT0. As a result, it will hang our system > and will trigger a watchdog reset. If the watchdog timer is disabled, the > system hangs for about 5 to 7 seconds and will get out of the hang after a > USB Reset has occur, which will then fix the USB re-enumeration. > > The USB gadget is configured in the following order: > - USB mass storage interface 0 > - USB HID keyboard > - USB HID mouse > > If the order is USB HID keyboard, USB HID mouse, and USB mass storage > interface 0, the issue will not be encountered. > > On first USB enumeration of the USB gadget as described above where mass > storage interface is enumerated first prior to HID, it will work fine. A copy > of a file to a Windows 10 PC will be initiated. The copy will be abruptly > interrupted and our system will re-configure the USB gadget to be > re-enumerated with only the USB HID available (i.e., no more USB mass > storage). On the next USB enumeration where USB mass storage is again > enabled, the problem will be encountered. > > The problem occurs after the following USB requests: > 1. After all the Get Descriptor requests for ep0 > 2. Get Max LUN request for ep0 > 3. SCSI Inquiry (Lun 0, Page 0) > 4. SCSI Inquiry (Lun 0, Page 0) > 5. SCSI Inquiry (Lun 0, Page 128) > 6. Set Idle on ep0 interface 0 <-- hangs here due to BNA interrupts on > DPOEPINT0 > > Would you guys know how to clear the BNA interrupt for DPOEPINT0? The > dwc2_hsotg_epint() function only handles the BNA interrupt if the transfer is > isochronous. Thus, in our case, it will never gets cleared. I could not find > how to clear this properly on the Altera Cyclone V Technical Reference > Manual. I am hoping that you guys would know. > > For now, once this issue happens on ep0, I just disable the BNA interrupt on > dwc2_hsotg_epint. It prevents the system hang but it still halts the USB > enumeration for a few seconds until the USB reset occurs. I prefer to resolve > it without any hang in the USB enumeration. > > Thanks in advance, > Maynard > >
Please apply follow patches which included starting from 4.16: 1. usb: dwc2: Add safety check in setting of descriptor chain pointers commit ID: 201ec568c57a43dbc73c7ac00e73c3c2d39559fc 2. usb: dwc2: Add safety check for STSPHSERCVD intr commit ID: 9e95a66cce7250c358d496e1c3b62e29ce79ef40 Let me know if it help. Thanks, Minas > ________________________________ > > 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. >