Closed htot closed 3 years ago
I'm dropping trace and regdump after a cold and a warm boot captured according to instructions here: https://www.kernel.org/doc/html/latest/driver-api/usb/dwc3.html#reporting-bugs
While the above traces in boot.zip allow compare which regs not correctly initialized on warm boot, I have also captured traces of unplug/plug. Here kernel is 5.10.27 (LTS), edison cold booted with USB cable plugged. Loggin via console, verified connection inet 10.42.0.221 netmask 255.255.255.0
root@yuna:~# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 metric 1
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 44 bytes 3412 (3.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 44 bytes 3412 (3.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 metric 1
inet 10.42.0.221 netmask 255.255.255.0 broadcast 10.42.0.255
inet6 fe80::a8bb:ccff:fedd:eef1 prefixlen 64 scopeid 0x20<link>
ether aa:bb:cc:dd:ee:f1 txqueuelen 1000 (Ethernet)
RX packets 61 bytes 8416 (8.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 54 bytes 7779 (7.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC> mtu 1500 metric 1
ether 78:4b:87:ad:4d:70 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Then trace unplug. Then trace plug.
Now, with host updated to ubuntu kernel ppa 5.12.0-051200rc5-generic and edison to 5.12.0-rc5-edison-acpi-standard vanilla + 2 patches appearing in rc6:
I added another 3:
The latter seems to solve the throttling, while the first 2 help to make switching from host -> device mode work (better).
I retested usb-next (based 5.12-rc7) + "[PATCH v3] usb: dwc3: core: Do core softreset when switch mode". No throttling, but
kernel: usb 1-5: new high-speed USB device number 18 using xhci_hcd
kernel: usb 1-5: New USB device found, idVendor=1d6b,
idProduct=0104, bcdDevice= 1.00 kernel: usb 1-5: New USB device
strings: Mfr=1, Product=2, SerialNumber=3 kernel: usb 1-5: Product:
USBArmory Gadget kernel: usb 1-5: Manufacturer: USBArmory kernel:
usb 1-5: SerialNumber: 0123456789abcdef kernel: usb 1-5: can't set
config #1, error -110
In the zip file 1 more trace of just the switch from host->gadget 5.12-rc7+usb-next.zip
regdump in zip files empty, resend.. regdump.txt
After flipping the first time the trace is empty see first-switch.zip
I found the gadget configuration script was not called, which normally gets called due to a udev rule:
ACTION=="add", KERNEL=="dwc3.0.auto", SUBSYSTEMS=="udc", ATTRS{state}=="not attached", RUN+="/usr/bin/conf-gadget.sh"
So I retried and see with udevadm monitor
flipping the switch from host->gadget
KERNEL[51.824914] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/enp0s17u1u1/queues/rx-0 (queues)
KERNEL[51.825682] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/enp0s17u1u1/queues/tx-0 (queues)
KERNEL[51.826226] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/enp0s17u1u1 (net)
KERNEL[51.836041] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:003/usb-001:003:01 (mdio_bus)
KERNEL[51.836709] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:003/usb-001:003:01 (mdio_bus)
KERNEL[51.837342] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:003 (mdio_bus)
KERNEL[51.837763] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
KERNEL[51.838116] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
KERNEL[51.873712] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1 (usb)
KERNEL[51.874000] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1 (usb)
KERNEL[51.874207] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1:1.0 (usb)
KERNEL[51.874431] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1:1.0 (usb)
KERNEL[51.897175] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1 (usb)
KERNEL[51.897486] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1 (usb)
stopped capture tracepoints here, then switch back to host
KERNEL[253.214406] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1 (usb)
KERNEL[253.263305] change /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1 (usb)
KERNEL[253.263687] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1:1.0 (usb)
KERNEL[253.328354] bind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1:1.0 (usb)
KERNEL[253.328734] bind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1 (usb)
KERNEL[253.699341] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1 (usb)
KERNEL[253.744911] change /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1 (usb)
KERNEL[253.745804] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
KERNEL[253.805307] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:005 (mdio_bus)
KERNEL[253.812978] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:005/usb-001:005:01 (mdio_bus)
KERNEL[253.814318] bind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:005/usb-001:005:01 (mdio_bus)
KERNEL[253.815386] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/eth0 (net)
KERNEL[253.815552] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/eth0/queues/rx-0 (queues)
KERNEL[253.815778] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/eth0/queues/tx-0 (queues)
KERNEL[253.825279] bind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
KERNEL[253.825667] bind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1 (usb)
switch to gadget again
KERNEL[314.212144] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/eth0/queues/rx-0 (queues)
KERNEL[314.212473] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/eth0/queues/tx-0 (queues)
KERNEL[314.214691] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0/net/eth0 (net)
extcon event didn't show the first time
KERNEL[314.238385] change /devices/pci0000:00/0000:00:13.0/INTC100E:00/mrfld_bcove_pwrsrc/extcon/extcon0 (extcon)
KERNEL[314.238677] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:005/usb-001:005:01 (mdio_bus)
KERNEL[314.238863] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:005/usb-001:005:01 (mdio_bus)
KERNEL[314.239015] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/mdio_bus/usb-001:005 (mdio_bus)
KERNEL[314.239205] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
KERNEL[314.239429] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
KERNEL[314.239666] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb2/2-0:1.0 (usb)
KERNEL[314.239933] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb2/2-0:1.0 (usb)
KERNEL[314.262713] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb2 (usb)
KERNEL[314.263030] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1 (usb)
KERNEL[314.263298] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb2 (usb)
KERNEL[314.263569] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1.1 (usb)
KERNEL[314.263815] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1:1.0 (usb)
KERNEL[314.264042] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1/1-1:1.0 (usb)
KERNEL[314.264753] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usbmon/usbmon2 (usbmon)
KERNEL[314.265019] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1 (usb)
KERNEL[314.265289] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-1 (usb)
KERNEL[314.288792] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-0:1.0 (usb)
KERNEL[314.289057] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1/1-0:1.0 (usb)
KERNEL[314.289327] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1 (usb)
KERNEL[314.289661] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usb1 (usb)
KERNEL[314.647375] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto/usbmon/usbmon1 (usbmon)
KERNEL[314.647816] unbind /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto (platform)
KERNEL[314.648143] remove /kernel/software_nodes/node1 (software_nodes)
KERNEL[314.648672] remove /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/xhci-hcd.2.auto (platform)
here is the event we were waiting for
KERNEL[314.649158] add /devices/pci0000:00/0000:00:11.0/dwc3.0.auto/udc/dwc3.0.auto (udc)
after this gadget devices appear normally
Also after some time (a few minutes) the connection drop but automatically reconnects. The following trace shows that near the end. lost-connection.zip
In total there have appeared to be 5 separate issues, summury here:
https://lore.kernel.org/linux-usb Caused by LPM
Fixed by “PROPERTY_ENTRY_BOOL("snps,dis_enblslpm_quirk")”
Also fixed by “BESL baseline to 6”:
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 60e850a395a2..423533df8927 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2895,7 +2895,7 @@ static void dwc3_gadget_config_params(struct usb_gadget *g,
recommended BESL baseline to 1 and clamp the BESL deep to be within 2 to 15. /
params->besl_baseline = 1;
params->besl_baseline = 6; if (dwc->is_utmi_l1_suspend) params->besl_deep = clamp_t(u8, dwc->hird_threshold, 2, 15);
### Problems switching DRD
[https://lore.kernel.org/linux-usb](https://lore.kernel.org/linux-usb/96c64e6a788552371081f37f544041b7ee046ef5.1618452732.git.Thinh.Nguyen@synopsys.com/)
Need to quickly flip switch back and forth to switch to gadget mode
Fixed by “usb: dwc3: core: Do core softreset when switch mode“
https://lore.kernel.org/linux-usb
So, as far as I understand we need only two patches now to fix all 5 issues, i.e. extcon + snps,usb2-gadget-lpm-disable
. Correct?
Yes. Thanks for reviewing, sent to ml.
This was with your configurations rebased on 5.10.24 (LTS) https://github.com/edison-fw/linux/commits/eds-acpi-5.10.24 I have bitbake apply 2 other (relevant) patches:
I'll highlight the interesting bits and have some conclusions at the end:
This is to test eem ethernet gadget (Connector USB 2 shown as 2 on the photo).
In these tests I leave edison-arduino switch in gadget mode (Switch 1 in the position as shown on the photo). Communication with edison is through console (Connector USB 1 shown as 3 on the photo)
1) Cold boot (press Edison reset button 7 sec), with USB 2 unplugged, wait for prompt, login, plug USB 2
On host (run 2 min, at 200Mb/sec Edison doesn't crash in other cases often does)
2) kill iperf3 on Edison, unplug USB 2, wait 5 sec, plug USB 2
On host
3) warm reboot Edison with USB 2 plugged: no change 4) warm reboot Edison with USB 2 unplugged: plug event seems not detected, other gadgets do not appear (sound, mass storage) But connman thinks gadget is there, powered, but not connected:
And device is standbye (R) but not pinging intel.com.
Didn't receive correct config from dhcp (or not at all)
5) Cold reboot with USB 2 plugged: same as with cable unplugged. 6) Warm reboot with USB 2 plugged (network in good state): device is standbye (R) but not pinging intel.com.
7) Cold reboot, then Warm reboot with USB 2 unplugged, connected but bad:
8) Cold reboot with USB 2 plugged:
unplug USB 2, wait 5 sec, plug USB 2:
Conclusion
ip link set dev usb0 down
), plug/replug followed by enabling again, eem gadget works.