RK3288 dwc2 USB OTG + macOS

2019-08-22 Thread Jack Mitchell
I'm having issues on a Firefly rk3288 board when trying to use USB
gadget ethernet on macOS. The dr_mode is set to "otg" and it works fine
with my Linux desktop.

If I set the dr_mode to "peripheral" macOS will work, but still takes
around 10 seconds to enumerate the device which makes me think it's only
just working. However, I need the port to be in "otg" mode as it will
switch between peripheral/host use cases.

I've attached a log from the dwc2 driver from mainline Linux 5.2 when
being plugged into the macOS device for 30 seconds, then removed. The
mac in this case is a 2013 macbook pro. Any pointers in the right
direction would be greatly appreciated.

Regards,
Jack.
[  141.300412] dwc2 ff58.usb: ep1in: req 58615452: 337@a3ab679a, noi=0, 
zero=1, snok=0
[  141.300418] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_start: ep1in: 
buf=a3ab679a length=337
[  142.285792] dwc2 ff58.usb: dwc2_hsotg_irq: 04008428 0400 (d88c3cc4) 
retry 8
[  142.285797] dwc2 ff58.usb: GINTSTS_ErlySusp
[  142.288847] dwc2 ff58.usb: gintsts=04008828  gintmsk=d88c3cc4
[  142.288851] dwc2 ff58.usb: USB SUSPEND
[  142.288855] dwc2 ff58.usb: dwc2_handle_usb_suspend_intr: DSTS=0x483901
[  142.288859] dwc2 ff58.usb: DSTS.Suspend Status=1 HWCFG4.Power Optimize=1 
HWCFG4.Hibernation=0
[  142.288862] g_ether gadget: suspend
[  142.288868] dwc2 ff58.usb: dwc2_hsotg_irq: 04008028  (d88c3cc4) 
retry 8
[  142.382505] dwc2 ff58.usb: dwc2_hsotg_irq: 04809028 00801000 (d88c3cc4) 
retry 8
[  142.382510] dwc2 ff58.usb: dwc2_hsotg_irq: USBRstDet
[  142.382513] dwc2 ff58.usb: dwc2_hsotg_irq: USBRst
[  142.382516] dwc2 ff58.usb: GNPTXSTS=00080010
[  142.382524] dwc2 ff58.usb: complete: ep 3944e9db ep0, req d536b4a1, -108 
=> 397b7f01
[  142.382530] dwc2 ff58.usb: dwc2_hsotg_complete_setup: failed -108
[  142.382535] dwc2 ff58.usb: complete: ep a23a8600 ep1in, req 5373e218, 
-108 => 5f11106e
[  142.382538] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep1in: status=-108 actual-length=0
[  142.382545] dwc2 ff58.usb: complete: ep a23a8600 ep1in, req 0c36dad6, 
-108 => 5f11106e
[  142.382548] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep1in: status=-108 actual-length=0
[  142.382553] dwc2 ff58.usb: complete: ep a23a8600 ep1in, req 9060b312, 
-108 => 5f11106e
[  142.382556] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep1in: status=-108 actual-length=0
[  142.382561] dwc2 ff58.usb: complete: ep a23a8600 ep1in, req 721cede2, 
-108 => 5f11106e
[  142.382564] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep1in: status=-108 actual-length=0
[  142.382568] dwc2 ff58.usb: complete: ep a23a8600 ep1in, req 220f7ef1, 
-108 => 5f11106e
[  142.382571] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep1in: status=-108 actual-length=0
[  142.382576] dwc2 ff58.usb: complete: ep a23a8600 ep1in, req 5beaf0e1, 
-108 => 5f11106e
[  142.382579] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep1in: status=-108 actual-length=0
[  142.382584] dwc2 ff58.usb: complete: ep a23a8600 ep1in, req 58615452, 
-108 => 5f11106e
[  142.382587] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep1in: status=-108 actual-length=0
[  142.382592] dwc2 ff58.usb: complete: ep 1a3e8513 ep2out, req 8dad2bf7, 
-108 => d4895dfd
[  142.382596] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep2out: status=-108 actual-length=0
[  142.382601] dwc2 ff58.usb: complete: ep 1a3e8513 ep2out, req 6a45280f, 
-108 => d4895dfd
[  142.382605] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep2out: status=-108 actual-length=0
[  142.382610] dwc2 ff58.usb: complete: ep 1a3e8513 ep2out, req 82a9d402, 
-108 => d4895dfd
[  142.382613] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep2out: status=-108 actual-length=0
[  142.382618] dwc2 ff58.usb: complete: ep 1a3e8513 ep2out, req 7adb743e, 
-108 => d4895dfd
[  142.382622] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep2out: status=-108 actual-length=0
[  142.382626] dwc2 ff58.usb: complete: ep 1a3e8513 ep2out, req 2e0b57de, 
-108 => d4895dfd
[  142.382629] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep2out: status=-108 actual-length=0
[  142.382634] dwc2 ff58.usb: complete: ep 1a3e8513 ep2out, req 3920b6da, 
-108 => d4895dfd
[  142.382638] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep2out: status=-108 actual-length=0
[  142.382642] dwc2 ff58.usb: complete: ep 1a3e8513 ep2out, req 7941a31e, 
-108 => d4895dfd
[  142.382646] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep2out: status=-108 actual-length=0
[  142.382650] dwc2 ff58.usb: complete: ep 1a3e8513 ep2out, req 2fb2d569, 
-108 => d4895dfd
[  142.382654] dwc2 ff58.usb: dwc2_hsotg_handle_unaligned_buf_complete: 
ep2out: status=-108 actual-length=0
[  142.382658] d

Re: RK3288 dwc2 USB OTG + macOS

2019-08-30 Thread Jack Mitchell
On 22/08/2019 17:06, Jack Mitchell wrote:
> I'm having issues on a Firefly rk3288 board when trying to use USB
> gadget ethernet on macOS. The dr_mode is set to "otg" and it works fine
> with my Linux desktop.
> 
> If I set the dr_mode to "peripheral" macOS will work, but still takes
> around 10 seconds to enumerate the device which makes me think it's only
> just working. However, I need the port to be in "otg" mode as it will
> switch between peripheral/host use cases.
> 
> I've attached a log from the dwc2 driver from mainline Linux 5.2 when
> being plugged into the macOS device for 30 seconds, then removed. The
> mac in this case is a 2013 macbook pro. Any pointers in the right
> direction would be greatly appreciated.
> 
> Regards,
> Jack.
> 

I've been poking about with this some more and I've managed to bisect
the issue down to the following commit

729cac693eecfebdb9e152ead358ae2decb7 usb: dwc2: Change ISOC DDMA flow

If I build before this commit everything works fine with a g_ether
gadget device on mac. Unfortunately it's a rather large change which I
can't just revert in master as it's got multiple dependant commits
later. So, any advice on what could be causing this or how to help debug
it would be much appreciated, as at the moment I've just forward ported
the working 4.16 version of the driver over the 5.3-rc6 broken driver
which isn't very sustainable in the long run.

Regards,
Jack.