Thread (27 messages) 27 messages, 4 authors, 2021-04-13

Re: USB network gadget / DWC3 issue

From: Ferry Toth <hidden>
Date: 2021-03-30 20:27:01

Hi,

Op 30-03-2021 om 18:17 schreef Felipe Balbi:
Hi,

Andy Shevchenko [off-list ref] writes:
quoted
Hi!

I have a platform with DWC3 in Dual Role mode. Currently I'm
experimenting on v5.12-rc5 with a few patches (mostly configuration)
applied [1]. I'm using Debian Unstable on the host machine and
BuildRoot with the above mentioned kernel on the target.

**So, scenario 0:
1. Run iperf3 -s on target
2. Run iperf3 -c ... -t 0 on the host
3.  0.00-10.36  sec   237 MBytes   192 Mbits/sec                  receiver

**Scenario 1:
1. Now, detach USB cable, wait for several seconds, attach it back,
repeat above:
0.00-9.94   sec   209 MBytes   176 Mbits/sec                  receiver

Note the bandwidth drop (177 vs. 192).

(Repeating scenario 1 will give now the same result)

**Scenario 2.
1. Detach USB cable, attach a device, for example USB stick,
2. See it being enumerated and detach it.
3. Attach cable from host
4 .   0.00-19.36  sec   315 MBytes   136 Mbits/sec                  receiver

Note even more bandwidth drop!

(Repeating scenario 1 keeps the same lower bandwidth)

NOTE, sometimes on this scenario after several seconds the target
simply reboots (w/o any logs [from kernel] printed)!

So, any pointers on how to debug and what can be a smoking gun here?

Ferry reported this in [2]. There are different kernel versions and
tools to establish the connection (like connman vs. none in my case).

[1]: https://github.com/andy-shev/linux/
[2]: https://github.com/andy-shev/linux/issues/31
dwc3 tracepoints should give some initial hints. Look at packets sizes
and period of transmission. From dwc3 side, I can't think of anything we
would do to throttle the transmission, but tracepoints should tell a
clearer story.
My testing (but yes, with difference kernel and network managed by 
connman) shows:

1) on cold boot eem network gadget works fine

2) after unplug or warm reboot (which is also an unplug) it's broken, 
speed is lost (|12.0 Mbits/sec from 200Mb/s normally)|, packets lost, no 
configuration received from dhcp, occasional reboot, only way to fix is 
cold boot

3) if before unplug `connmanctl disable gadget`, on replugging and 
enabling it works fine

My theory is that some HW register is disturbed on a surprise unplug, 
but not reset on plug or warm boot. But on cold boot is cleared. Maybe 
that can help to narrow down tracepoints?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help