Re: usb: dwc2: usb data transmitted to incorrect usb endpoint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Maynard,

On 1/22/2019 11:00 PM, Maynard CABIENTE wrote:
> Hi Minas,
> 
> I have one more issue on the dwc2 gadget driver that I can't figure out the root cause. Hopefully, you have an idea on this problem.
> 
> 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).
> 
> When 2 mass storage interfaces are enabled, at times the data that should be written to the USB endpoint is going to the wrong USB endpoint. As a consequence, USB reset will occur. Unfortunately, the USB reset will not fix the issue. Instead, another incorrect USB endpoint issue will trigger followed by USB reset, etc.
> 
> For example, the following configuration was used.
> Interface 0: ep1in ep1out: usb mass storage
> Interface 1: ep2in ep2out: usb mass storage
> Interface 2: ep3in ep3out: usb HID (keyboard)
> Interface 3: ep4in ep4out: usb HID (mouse)
> Interface 4: ep5in ep5out: usb HID (mouse)
> 
> During usb enumeration, the following usb mass storage requests have been sent by the USB Host Controller:
> - Test Unit Ready: ep2, interface 1 (Time 23.918 523 050 from USB Ellisys Analyzer)
>      + Command Transport (CBW) with dCBWSignature 43425355h and dCBWTag 00000002h
>      + Data Transport with 128 bytes (but this is actually 128 bytes data for Mode Sense ep1)
> - Mode Sense: ep1, interface 0 (Time 23.918 564 900 from USB Ellisys Analyzer)
>      + Command Transport (CBW) with dCBWSignature 43425355h, dCBWTag 00000005h, and dCBWDataTransferLength of 128 bytes
>      + Data Transport with 13 bytes (but this is actually a Status Transport/CSW for Test Unit Ready ep2 with dCSWSignature 53425355h and dCSWTag 00000002h)
> 
> The Test Unit Ready request for usb endpoint 2 should only have CBW followed by CSW (no Data). Mode Sense request for usb endpoint 1 should have CBW, Data, CSW. What happens in this case is that the CSW for Test Unit Ready was sent to ep1 instead of ep2 and the Data for Mode Sense was sent to ep2 instead of ep1. After these requests, a USB reset will happen.
> 
> I verified that both usb data were sent to the correct USB endpoints in driver/usb/gadget/function/f_mass_storage.c. I also verified that both usb data were sent to the correct USB endpoints in driver/usb/dwc2/gadget.c.
> 
> Here is a snippet of debugging messages in driver/usb/dwc2/gadget.c and driver/usb/gadget/function/f_mass_storage.c
> 
> [  368.961681] dwc2 ffb40000.usb: dwc2_hsotg_ep_queue: [req ce571940] ep2out: 512@ce064000, noi=0, zero=0, snok=0 (CBW for ep2)
> [  368.962850] dwc2 ffb40000.usb: dwc2_hsotg_ep_queue: [req ce60a380] ep1out: 512@ce188000, noi=0, zero=0, snok=0 (CBW for ep1)
> [  368.964183] configfs-gadget gadget: do_scsi_command: [intf1 ep2] TEST UNIT READY tag 00000002
> [  368.964198] dwc2 ffb40000.usb: dwc2_hsotg_ep_queue: [req ce5719c0] ep2in: 13@ce064000, noi=0, zero=0, snok=0 (CSW for Test Unit Ready ep2)
> [  368.964212] dwc2 ffb40000.usb: dwc2_hsotg_start_req: DxEPCTL=0x01c88200, ep 2, dir in TAG 00000002 (start request to send CSW for Test Unit Ready ep2)
> [  368.964228] dwc2 ffb40000.usb: dwc2_hsotg_ep_queue: [req ce571d00] ep2out: 512@ce518000, noi=0, zero=0, snok=0 (new CBW for ep2)
> [  368.964256] dwc2 ffb40000.usb: dwc2_hsotg_complete_in: ep2in: req->length:13 req->actual:13 req->zero:0 (completed sending CSW for Test Unit Ready ep2)
> [  368.964288] dwc2 ffb40000.usb: dwc2_hsotg_ep_queue: [req ce60a900] ep1in: 128@ce188000, noi=0, zero=0, snok=0 (Data for Mode Sense ep1)
> [  368.964305] dwc2 ffb40000.usb: dwc2_hsotg_ep_queue: [req ce60a640] ep1in: 13@cef30000, noi=0, zero=0, snok=0 (CSW for Mode Sense ep1)
> [  368.964329] dwc2 ffb40000.usb: dwc2_hsotg_complete_in: ep1in: req->length:128 req->actual:128 req->zero:0 (completed sending Data for Mode Sense ep1)
> [  368.964342] dwc2 ffb40000.usb: dwc2_hsotg_start_req: DxEPCTL=0x01c98200, ep 1, dir in TAG 00000005 (start request to send CSW for Mode Sense ep1)
> [  368.964362] dwc2 ffb40000.usb: dwc2_hsotg_complete_in: ep1in: req->length:13 req->actual:13 req->zero:0 (completed sending CSW for Mode Sense ep1)
> [  368.964378] dwc2 ffb40000.usb: dwc2_hsotg_ep_queue: [req ce60a380] ep1out: 512@ce188000, noi=0, zero=0, snok=0 (new CBW for ep1)
> [  368.967886] configfs-gadget gadget: End Point Request ERROR: -108  <-- ERROR DUE TO USB DATA TRANSMITTED TO INCORRECT USB EP
> [  368.977085] dwc2 ffb40000.usb: [req cf7e7400] ep0: 8@cec81ad0, noi=0, zero=0, snok=0     <-- USB RESET OCCURRED
> [  369.019382] dwc2 ffb40000.usb: new device is high-speed
> 

Can you provide USB trace for above fragment.

Thanks,
Minas


> There are cases as well where the HID packets for mouse gets sent to the USB endpoint for mass storage. This will also result in End Point Request ERROR: -108 and will trigger a USB reset.
> 
> It is looking like a Synopsys Designware USB 2.0 Core IP issue and not a driver issue. But, I think you would know better.
> 
> 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.
> 





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux