raspberrypi / linux

Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/
Other
11.02k stars 4.95k forks source link

[3+ model A] [dwc2] [g_multi] dwc2_hsotg_ep_stop_xfr: timeout #2962

Open maxnet opened 5 years ago

maxnet commented 5 years ago

Describe the bug

Playing with USB gadget functions using Linux 4.19.34 on a Pi 3+ model A.

To reproduce

dtoverlay=dwc2,dr_mode=peripheral
sudo dd if=/dev/zero of=/tmp/test bs=1M count=16
sudo modprobe g_multi file=/tmp/test

Expected behaviour

Expect to have working mass storage + Ethernet USB functionality exposed to host PC..

Actual behaviour

Ethernet and mass storage does appear on the host pc, but is not functional, and dmesg gives:

[  123.302691] using random self ethernet address
[  123.302706] using random host ethernet address
[  123.302978] Mass Storage Function, version: 2009/09/11
[  123.302991] LUN: removable file: (no medium)
[  123.303130] LUN: file: /tmp/test
[  123.303136] Number of LUNs=1
[  123.304025] usb0: HOST MAC c6:78:77:2d:28:d7
[  123.304153] usb0: MAC 5e:ff:15:d6:f5:ab
[  123.304743] g_multi gadget: Multifunction Composite Gadget
[  123.304754] g_multi gadget: userspace failed to provide iSerialNumber
[  123.304768] g_multi gadget: g_multi ready
[  123.304802] dwc2 3f980000.usb: bound driver g_multi
[  123.386658] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready
[  123.607193] dwc2 3f980000.usb: new device is high-speed
[  123.807244] dwc2 3f980000.usb: new device is high-speed
[  123.932566] dwc2 3f980000.usb: new address 56
[  123.983348] g_multi gadget: high-speed config #1: Multifunction with RNDIS
[  123.983550] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready
[  125.068336] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.181839] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.181864] dwc2 3f980000.usb: dwc2_hsotg_start_req: ep5 is stalled
[  125.183494] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 0)
[  125.184680] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.301842] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.301867] dwc2 3f980000.usb: dwc2_hsotg_start_req: ep5 is stalled
[  125.303506] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 0)
[  125.304961] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.421798] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.421824] dwc2 3f980000.usb: dwc2_hsotg_start_req: ep5 is stalled
[  125.423531] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 0)
[  125.424713] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.541850] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.541875] dwc2 3f980000.usb: dwc2_hsotg_start_req: ep5 is stalled
[  125.543536] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 0)
[  125.545934] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.661848] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.661869] dwc2 3f980000.usb: dwc2_hsotg_start_req: ep5 is stalled
[  125.663548] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 0)
[  125.664825] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.781803] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  125.781823] dwc2 3f980000.usb: dwc2_hsotg_start_req: ep5 is stalled
[  139.090467] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[  139.090609] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
[  139.090780] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[  139.090917] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
[  139.091058] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[  139.091195] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
[  139.157647] dwc2 3f980000.usb: new device is high-speed
[  139.357074] dwc2 3f980000.usb: new device is high-speed
[  139.480202] dwc2 3f980000.usb: new address 56
[  139.514251] g_multi gadget: high-speed config #1: Multifunction with RNDIS
[  139.575974] dwc2 3f980000.usb: dwc2_hsotg_start_req: ep5 is stalled
[  139.575993] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  139.577257] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 0)
[  139.691813] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[  139.811809] dwc2 3f980000.usb: dwc2_hsotg_ep_sethalt(ep (ptrval) ep5in, 1)
[..more lines of the same...]

If doing "modprobe g_multi file=/tmp/test stall=0" instead the stalled lines no longer appear, but the timeouts do, and not functional either.

[   94.483882] using random self ethernet address
[   94.483898] using random host ethernet address
[   94.484156] Mass Storage Function, version: 2009/09/11
[   94.484166] LUN: removable file: (no medium)
[   94.484302] LUN: file: /tmp/test
[   94.484309] Number of LUNs=1
[   94.485159] usb0: HOST MAC 5e:f7:9d:8a:83:20
[   94.485332] usb0: MAC 96:92:d2:ef:50:23
[   94.485844] g_multi gadget: Multifunction Composite Gadget
[   94.485863] g_multi gadget: userspace failed to provide iSerialNumber
[   94.485874] g_multi gadget: g_multi ready
[   94.485913] dwc2 3f980000.usb: bound driver g_multi
[   94.794225] dwc2 3f980000.usb: new device is high-speed
[   94.930071] dwc2 3f980000.usb: new device is high-speed
[   94.995663] dwc2 3f980000.usb: new address 73
[   95.046364] g_multi gadget: high-speed config #1: Multifunction with RNDIS
[  198.091416] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[  198.091559] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
[  198.091735] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[  198.091872] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
[  198.092014] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
[  198.092152] dwc2 3f980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
[  198.158516] dwc2 3f980000.usb: new device is high-speed
[  198.359637] dwc2 3f980000.usb: new device is high-speed
[  198.483747] dwc2 3f980000.usb: new address 73
[  198.521974] g_multi gadget: high-speed config #1: Multifunction with RNDIS
maxnet commented 5 years ago

Problem is related to the serial part, and only happens if nothing is connected on the Pi side to the serial. If as a workaround I attach a getty to it ("systemctl start serial-getty@ttyGS0.service"), errors no longer appear.

Seems that the pc side (running Ubuntu) wants to set parameters on the serial as soon as it detects the USB device, judging from messages on the pc side:

[40571.121868] cdc_acm 1-2:1.2: failed to set dtr/rts
[40576.242050] cdc_acm 1-2:1.2: failed to set dtr/rts
[40593.137657] cdc_acm 1-2:1.2: failed to set dtr/rts

And that does not work if the port is not open on the gadget side. Still should not react this badly to this, to the point that MSD and Ethernet also do not work.