Re: DWC3 Gadget backtrace

2017-11-01 Thread Felipe Balbi

Hi,

"Howey, Dylan"  writes:
>> >> > It's also happening in v4.14-rc7.
>> >> 
>> >> Please make sure to also Cc: linux-usb@vger.kernel.org and send
>> >> plain-text emails, also avoid top-posting :-)
>> >> 
>> >> > [   59.716702] [ cut here ]
>> >> > [   59.721365] WARNING: CPU: 0 PID: 966 at 
>> >> > drivers/usb/dwc3/gadget.c:2610 
>> >> > dwc3_stop_active_transfer.constprop.4+0xe8/0xec
>> >> > [   59.732038] Modules linked in: matrix_keypad
>> >> > [   59.736311] CPU: 0 PID: 966 Comm: irq/90-dwc3 Tainted: GW
>> >> >4.14.0-rc7 #3
>> >> > [   59.744124] Hardware name: Generic AM43 (Flattened Device Tree)
>> >> > [   59.750029] Backtrace:
>> >> > [   59.752494] [] (dump_backtrace) from [] 
>> >> > (show_stack+0x18/0x1c)
>> >> > [   59.760051]  r7:0009 r6: r5:c0889bd0 r4:
>> >> > [   59.765707] [] (show_stack) from [] 
>> >> > (dump_stack+0x24/0x28)
>> >> > [   59.772926] [] (dump_stack) from [] 
>> >> > (__warn+0xe8/0x100)
>> >> > [   59.779877] [] (__warn) from [] 
>> >> > (warn_slowpath_null+0x28/0x30)
>> >> > [   59.787433]  r9: r8:a00e0093 r7:0002 r6:0003 
>> >> > r5:ee8b7810 r4:ee8bbf00
>> >> > [   59.795166] [] (warn_slowpath_null) from [] 
>> >> > (dwc3_stop_active_transfer.constprop.4+0xe8/0xec)
>> >> > [   59.805413] [] (dwc3_stop_active_transfer.constprop.4) 
>> >> > from [] (__dwc3_gadget_ep_disable+0x24/0x110)
>> >> > [   59.816259]  r6:ee8b7810 r5:ee8bbf34 r4:ee8bbf00
>> >> > [   59.820871] [] (__dwc3_gadget_ep_disable) from 
>> >> > [] (dwc3_gadget_ep_disable+0x30/0xac)
>> >> > [   59.830332]  r7:0002 r6:ee987638 r5:0001 r4:200e0093
>> >> > [   59.835993] [] (dwc3_gadget_ep_disable) from [] 
>> >> > (usb_ep_disable+0x30/0x3c)
>> >> > [   59.844585]  r5:0001 r4:ee8bbf00
>> >> > [   59.848158] [] (usb_ep_disable) from [] 
>> >> > (ffs_func_eps_disable+0x50/0x78)
>> >> > [   59.856576]  r5:0001 r4:ef0cfc80
>> >> > [   59.860145] [] (ffs_func_eps_disable) from [] 
>> >> > (ffs_func_set_alt+0x90/0x290)
>> >> > [   59.868827]  r9:5533194a r8:55332309 r7:ee98b254 r6: 
>> >> > r5:200e0093 r4:ee1f5e64
>> >> > [   59.876556] [] (ffs_func_set_alt) from [] 
>> >> > (ffs_func_disable+0x18/0x1c)
>> >> > [   59.884805]  r10:ee9f3d14 r9:5533194a r8:55332309 r7:ee98b254 
>> >> > r6: r5:200e0093
>> >> > [   59.892615]  r4:ee1f5e64
>> >> > [   59.895145] [] (ffs_func_disable) from [] 
>> >> > (composite_disconnect+0x4c/0x94)
>> >> 
>> >> okay, so you're using ffs. I see you're implementing your own HID gadget
>> >> on top of FFS. Could it be you have a bug there? Why not use the in-tree
>> >> HID function? Can you capture dwc3 logs? More details here:
>> >> 
>> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/usb/dwc3.rst#n113
>> >> 
>> >
>> > This implementation works on an AM335x platform.
>> 
>> that really doesn't mean much :-) Different controller will behave
>> completely differently when it comes to transfer cancellation.
>> 
>> > I should add that the host is Linux v4.4.0 on x86_64. I have not tried any
>> > other host yet.
>> 
>> okay.
>> 
>> 
>> > Attached the dwc3 logs as instructed.
>> 
>> Thank you.
>> 
>> (in below logs, I've removed register access traces to make it easier to 
>> read)
>> 
>> Roger, your PHY is toast :-(
>> 
>>  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event 
>> (0901): Erratic Error [U0]
>> 
>> Seems like your FFS HID is missing Data phase for this clear feature
>> request. Either that, or should stall this unknown interface feature
>> 
>> (and seems like I need to figure out a way to add the raw value to the
>> trace)
>> 
>>  irq/90-dwc3-969   [000] d...54.372175: dwc3_ctrl_req: Clear 
>> Interface Feature(UNKNOWN)
>>  irq/90-dwc3-969   [000] d...54.372186: dwc3_event: event 
>> (10c2): ep0in: Transfer Not Ready (Not Active) [Data Phase]
>>   UI_Touchscreen-963   [000] d...54.372437: dwc3_ep_queue: ep1in: req 
>> ee268c00 length 0/64 zsI ==> -115
>>   UI_Touchscreen-963   [000] d...54.372451: dwc3_prepare_trb: ep1in: 1/1 
>> trb f0a27000 buf a9409580 size 64 ctrl 0811 (Hlcs:sC:normal)
>>   UI_Touchscreen-963   [000] 

Re: DWC3 Gadget backtrace

2017-11-01 Thread Roger Quadros
Dylan,

On 31/10/17 17:42, Howey, Dylan wrote:
> Roger,
> 
> On 10/31/2017 10:23, Roger Quadros wrote:
>> Hi Dylan,
>>
>> On 30/10/17 10:59, Felipe Balbi wrote:
>>>
>>> Hi,
>>>
>>> "Howey, Dylan"  writes:
 Hello,

 I'm on an AM437x platform and I'm using FunctionFS to create a HID
 gadget. The device enumerates correctly when I plug it into a Linux
 host. If I unplug the cord and then plug it in again, I get a
 backtrace from dwc3, and the device fails to enumerate.

 I'm on ti-linux-4.9.y, but I see the same issue with 4.9.40 from
 kernel.org.

 Is this a known issue, and is there a workaround or a fix available?
>>>
>>> sorry, you need to ask help from TI. Either that, or test current
>>> mainline (v4.14-rc7) and let me know if the same problem is there.
>>>
>>> BTW, latest v4.9 stable is v4.9.58, not v4.9.40.
>>>
>>>
>>> Adding Roger Quadros here who works for TI and can, perhaps, point you
>>> in the right direction.
>>
>> I couldn't reproduce the problem with g_zero or with configfs based ethernet 
>> (ECM)
>> so I'm suspecting something is not going well with the ffs based HID 
>> solution.
>>
>> Do you have a known good kernel version where the ffs based HID solution 
>> works?
>> If there is such a kernel then could you please share the ffs-HID solution 
>> so I can try it at my end?
>>
> I do not have a known kernel version where this HID implementation works on an
> AM437x platform. I could share an implementation that's working on an AM335x
> platform and the kernel version if you think that would be useful for 
> resolving
> this issue.

AM335x uses a different USB controller though. Does it work with mainline 
kernel (v4.14-rc7)?

I could try out your solution on DRA7x which uses dwc3 controller.

>>>
>>> Best
>>>
 [   30.746934] [ cut here ]
 [   30.751587] WARNING: CPU: 0 PID: 947 at drivers/usb/dwc3/gadget.c:2303 
 dwc3_stop_active_transfer.constprop.5+0xd4/0xd8
 [   30.762259] Modules linked in: matrix_keypad
 [   30.766539] CPU: 0 PID: 947 Comm: irq/90-dwc3 Not tainted 
 4.9.40-02118-gde0a93a #4
 [   30.774092] Hardware name: Generic AM43 (Flattened Device Tree)
 [   30.779996] Backtrace:
 [   30.782465] [] (dump_backtrace) from [] 
 (show_stack+0x18/0x1c)
 [   30.790020]  r7:0009 r6: r5:c0899298 r4:
 [   30.795679] [] (show_stack) from [] 
 (dump_stack+0x24/0x28)
 [   30.802903] [] (dump_stack) from [] 
 (__warn+0xe8/0x100)
 [   30.809857] [] (__warn) from [] 
 (warn_slowpath_null+0x28/0x30)
 [   30.817413]  r9:55332309 r8:a093 r7: r6:ee82a010 
 r5:0003 r4:ee82c900
 [   30.825147] [] (warn_slowpath_null) from [] 
 (dwc3_stop_active_transfer.constprop.5+0xd4/0xd8)
 [   30.835393] [] (dwc3_stop_active_transfer.constprop.5) from 
 [] (dwc3_remove_requests+0x1c/0x98)
 [   30.845805]  r6:ee82a010 r5:ee82c934 r4:ee82c900
 [   30.850415] [] (dwc3_remove_requests) from [] 
 (__dwc3_gadget_ep_disable+0x38/0xdc)
 [   30.859700]  r5:ee9b13f8 r4:ee82c900
 [   30.863271] [] (__dwc3_gadget_ep_disable) from [] 
 (dwc3_gadget_ep_disable+0x30/0xac)
 [   30.872731]  r7: r6:0002 r5:ee9b13f8 r4:2093
 [   30.878387] [] (dwc3_gadget_ep_disable) from [] 
 (usb_ep_disable+0x30/0x3c)
 [   30.886979]  r5:ee9b13f8 r4:ee82c900
 [   30.890557] [] (usb_ep_disable) from [] 
 (ffs_func_eps_disable+0x40/0x64)
 [   30.898975]  r5:ee9b13f8 r4:ee7c8280
 [   30.902547] [] (ffs_func_eps_disable) from [] 
 (ffs_func_set_alt+0x90/0x288)
 [   30.911229]  r9:55332309 r8:55332509 r7:ee018e54 r6: 
 r5: r4:ee0271a4
 [   30.918960] [] (ffs_func_set_alt) from [] 
 (ffs_func_disable+0x18/0x1c)
 [   30.927211]  r10:55331839 r9:55332309 r8:55332509 r7:ee018e54 
 r6: r5:2093
 [   30.935021]  r4:ee0271a4
 [   30.937562] [] (ffs_func_disable) from [] 
 (composite_disconnect+0x4c/0x94)
 [   30.946160] [] (composite_disconnect) from [] 
 (usb_gadget_udc_reset+0x18/0x3c)
 [   30.955101]  r7:ee82cd80 r6:ee82a010 r5:0004 r4:ee82a160
 [   30.960752] [] (usb_gadget_udc_reset) from [] 
 (dwc3_gadget_reset_interrupt+0x60/0x1d0)
 [   30.970383]  r5:0004 r4:ee8251d0
 [   30.973953] [] (dwc3_gadget_reset_interrupt) from 
 [] (dwc3_thread_interrupt+0x220/0xaa8)
 [   30.983759]  r7:ee82cd80 r6:ee82a010 r5:0004 r4:ee8251d0
 [   30.989421] [] (dwc3_thread_interrupt) from [] 
 (irq_thread_fn+0x24/0x5c)
 [   30.997843]  r10: r9:c0b15fe4 r8:c0157eac r7:ee82cd80 
 r6:0001 r5:ee82cd80
 [   31.005654]  r4:ee00be40
 [   31.008185] [] (irq_thread_fn) from [] 
 (irq_thread+0x11c/0x19c)
 [   31.015825]  r7:ee82cd80 r6:0001 r5:ee4b4000 r4:ee00be40
 [   31.021478] [] (irq_thread) from [] 
 

Re: DWC3 Gadget backtrace

2017-10-31 Thread Howey, Dylan
Felipe,

The 10/31/2017 12:05, Felipe Balbi wrote:
> 
> Hi,
> 
> "Howey, Dylan"  writes:
> > Felipe,
> >
> > On 10/30/2017 15:28, Felipe Balbi wrote:
> >> 
> >> Hi,
> >> 
> >> "Howey, Dylan"  writes:
> >> > Felipe,
> >> >
> >> > It's also happening in v4.14-rc7.
> >> 
> >> Please make sure to also Cc: linux-usb@vger.kernel.org and send
> >> plain-text emails, also avoid top-posting :-)
> >> 
> >> > [   59.716702] [ cut here ]
> >> > [   59.721365] WARNING: CPU: 0 PID: 966 at 
> >> > drivers/usb/dwc3/gadget.c:2610 
> >> > dwc3_stop_active_transfer.constprop.4+0xe8/0xec
> >> > [   59.732038] Modules linked in: matrix_keypad
> >> > [   59.736311] CPU: 0 PID: 966 Comm: irq/90-dwc3 Tainted: GW 
> >> >   4.14.0-rc7 #3
> >> > [   59.744124] Hardware name: Generic AM43 (Flattened Device Tree)
> >> > [   59.750029] Backtrace:
> >> > [   59.752494] [] (dump_backtrace) from [] 
> >> > (show_stack+0x18/0x1c)
> >> > [   59.760051]  r7:0009 r6: r5:c0889bd0 r4:
> >> > [   59.765707] [] (show_stack) from [] 
> >> > (dump_stack+0x24/0x28)
> >> > [   59.772926] [] (dump_stack) from [] 
> >> > (__warn+0xe8/0x100)
> >> > [   59.779877] [] (__warn) from [] 
> >> > (warn_slowpath_null+0x28/0x30)
> >> > [   59.787433]  r9: r8:a00e0093 r7:0002 r6:0003 
> >> > r5:ee8b7810 r4:ee8bbf00
> >> > [   59.795166] [] (warn_slowpath_null) from [] 
> >> > (dwc3_stop_active_transfer.constprop.4+0xe8/0xec)
> >> > [   59.805413] [] (dwc3_stop_active_transfer.constprop.4) from 
> >> > [] (__dwc3_gadget_ep_disable+0x24/0x110)
> >> > [   59.816259]  r6:ee8b7810 r5:ee8bbf34 r4:ee8bbf00
> >> > [   59.820871] [] (__dwc3_gadget_ep_disable) from [] 
> >> > (dwc3_gadget_ep_disable+0x30/0xac)
> >> > [   59.830332]  r7:0002 r6:ee987638 r5:0001 r4:200e0093
> >> > [   59.835993] [] (dwc3_gadget_ep_disable) from [] 
> >> > (usb_ep_disable+0x30/0x3c)
> >> > [   59.844585]  r5:0001 r4:ee8bbf00
> >> > [   59.848158] [] (usb_ep_disable) from [] 
> >> > (ffs_func_eps_disable+0x50/0x78)
> >> > [   59.856576]  r5:0001 r4:ef0cfc80
> >> > [   59.860145] [] (ffs_func_eps_disable) from [] 
> >> > (ffs_func_set_alt+0x90/0x290)
> >> > [   59.868827]  r9:5533194a r8:55332309 r7:ee98b254 r6: 
> >> > r5:200e0093 r4:ee1f5e64
> >> > [   59.876556] [] (ffs_func_set_alt) from [] 
> >> > (ffs_func_disable+0x18/0x1c)
> >> > [   59.884805]  r10:ee9f3d14 r9:5533194a r8:55332309 r7:ee98b254 
> >> > r6: r5:200e0093
> >> > [   59.892615]  r4:ee1f5e64
> >> > [   59.895145] [] (ffs_func_disable) from [] 
> >> > (composite_disconnect+0x4c/0x94)
> >> 
> >> okay, so you're using ffs. I see you're implementing your own HID gadget
> >> on top of FFS. Could it be you have a bug there? Why not use the in-tree
> >> HID function? Can you capture dwc3 logs? More details here:
> >> 
> >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/usb/dwc3.rst#n113
> >> 
> >
> > This implementation works on an AM335x platform.
> 
> that really doesn't mean much :-) Different controller will behave
> completely differently when it comes to transfer cancellation.
> 
> > I should add that the host is Linux v4.4.0 on x86_64. I have not tried any
> > other host yet.
> 
> okay.
> 
> 
> > Attached the dwc3 logs as instructed.
> 
> Thank you.
> 
> (in below logs, I've removed register access traces to make it easier to read)
> 
> Roger, your PHY is toast :-(
> 
>  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event (0901): 
> Erratic Error [U0]
> 
> Seems like your FFS HID is missing Data phase for this clear feature
> request. Either that, or should stall this unknown interface feature
> 
> (and seems like I need to figure out a way to add the raw value to the
> trace)
> 
>  irq/90-dwc3-969   [000] d...54.372175: dwc3_ctrl_req: Clear 
> Interface Feature(UNKNOWN)
>  irq/90-dwc3-969   [000] d...54.372186: dwc3_event: event (10c2): 
> ep0in: Transfer Not Ready (Not Active) [Data Phase]
>   UI_Touchscreen-963   [000] d...54.372437: dwc3_ep_queue: ep1in: req 
> ee268c00 length 0/64 zsI ==> -115
>   UI_Touchscreen-963   [000] d...54.372451: dwc3_prepare_trb: ep1in: 1/1 
> 

Re: DWC3 Gadget backtrace

2017-10-31 Thread Howey, Dylan
Roger,

On 10/31/2017 10:23, Roger Quadros wrote:
> Hi Dylan,
> 
> On 30/10/17 10:59, Felipe Balbi wrote:
> > 
> > Hi,
> > 
> > "Howey, Dylan"  writes:
> >> Hello,
> >>
> >> I'm on an AM437x platform and I'm using FunctionFS to create a HID
> >> gadget. The device enumerates correctly when I plug it into a Linux
> >> host. If I unplug the cord and then plug it in again, I get a
> >> backtrace from dwc3, and the device fails to enumerate.
> >>
> >> I'm on ti-linux-4.9.y, but I see the same issue with 4.9.40 from
> >> kernel.org.
> >>
> >> Is this a known issue, and is there a workaround or a fix available?
> > 
> > sorry, you need to ask help from TI. Either that, or test current
> > mainline (v4.14-rc7) and let me know if the same problem is there.
> > 
> > BTW, latest v4.9 stable is v4.9.58, not v4.9.40.
> > 
> > 
> > Adding Roger Quadros here who works for TI and can, perhaps, point you
> > in the right direction.
> 
> I couldn't reproduce the problem with g_zero or with configfs based ethernet 
> (ECM)
> so I'm suspecting something is not going well with the ffs based HID solution.
> 
> Do you have a known good kernel version where the ffs based HID solution 
> works?
> If there is such a kernel then could you please share the ffs-HID solution so 
> I can try it at my end?
> 
I do not have a known kernel version where this HID implementation works on an
AM437x platform. I could share an implementation that's working on an AM335x
platform and the kernel version if you think that would be useful for resolving
this issue.
> > 
> > Best
> > 
> >> [   30.746934] [ cut here ]
> >> [   30.751587] WARNING: CPU: 0 PID: 947 at drivers/usb/dwc3/gadget.c:2303 
> >> dwc3_stop_active_transfer.constprop.5+0xd4/0xd8
> >> [   30.762259] Modules linked in: matrix_keypad
> >> [   30.766539] CPU: 0 PID: 947 Comm: irq/90-dwc3 Not tainted 
> >> 4.9.40-02118-gde0a93a #4
> >> [   30.774092] Hardware name: Generic AM43 (Flattened Device Tree)
> >> [   30.779996] Backtrace:
> >> [   30.782465] [] (dump_backtrace) from [] 
> >> (show_stack+0x18/0x1c)
> >> [   30.790020]  r7:0009 r6: r5:c0899298 r4:
> >> [   30.795679] [] (show_stack) from [] 
> >> (dump_stack+0x24/0x28)
> >> [   30.802903] [] (dump_stack) from [] 
> >> (__warn+0xe8/0x100)
> >> [   30.809857] [] (__warn) from [] 
> >> (warn_slowpath_null+0x28/0x30)
> >> [   30.817413]  r9:55332309 r8:a093 r7: r6:ee82a010 
> >> r5:0003 r4:ee82c900
> >> [   30.825147] [] (warn_slowpath_null) from [] 
> >> (dwc3_stop_active_transfer.constprop.5+0xd4/0xd8)
> >> [   30.835393] [] (dwc3_stop_active_transfer.constprop.5) from 
> >> [] (dwc3_remove_requests+0x1c/0x98)
> >> [   30.845805]  r6:ee82a010 r5:ee82c934 r4:ee82c900
> >> [   30.850415] [] (dwc3_remove_requests) from [] 
> >> (__dwc3_gadget_ep_disable+0x38/0xdc)
> >> [   30.859700]  r5:ee9b13f8 r4:ee82c900
> >> [   30.863271] [] (__dwc3_gadget_ep_disable) from [] 
> >> (dwc3_gadget_ep_disable+0x30/0xac)
> >> [   30.872731]  r7: r6:0002 r5:ee9b13f8 r4:2093
> >> [   30.878387] [] (dwc3_gadget_ep_disable) from [] 
> >> (usb_ep_disable+0x30/0x3c)
> >> [   30.886979]  r5:ee9b13f8 r4:ee82c900
> >> [   30.890557] [] (usb_ep_disable) from [] 
> >> (ffs_func_eps_disable+0x40/0x64)
> >> [   30.898975]  r5:ee9b13f8 r4:ee7c8280
> >> [   30.902547] [] (ffs_func_eps_disable) from [] 
> >> (ffs_func_set_alt+0x90/0x288)
> >> [   30.911229]  r9:55332309 r8:55332509 r7:ee018e54 r6: 
> >> r5: r4:ee0271a4
> >> [   30.918960] [] (ffs_func_set_alt) from [] 
> >> (ffs_func_disable+0x18/0x1c)
> >> [   30.927211]  r10:55331839 r9:55332309 r8:55332509 r7:ee018e54 
> >> r6: r5:2093
> >> [   30.935021]  r4:ee0271a4
> >> [   30.937562] [] (ffs_func_disable) from [] 
> >> (composite_disconnect+0x4c/0x94)
> >> [   30.946160] [] (composite_disconnect) from [] 
> >> (usb_gadget_udc_reset+0x18/0x3c)
> >> [   30.955101]  r7:ee82cd80 r6:ee82a010 r5:0004 r4:ee82a160
> >> [   30.960752] [] (usb_gadget_udc_reset) from [] 
> >> (dwc3_gadget_reset_interrupt+0x60/0x1d0)
> >> [   30.970383]  r5:0004 r4:ee8251d0
> >> [   30.973953] [] (dwc3_gadget_reset_interrupt) from 
> >> [] (dwc3_thread_interrupt+0x220/0xaa8)
> >> [   30.983759]  r7:ee82cd80 r6:ee82a010 r5:0004 r4:ee8251d0
> >> [   30.989421] [] (dwc3_thread_interrupt) from [] 
> >> (irq_thread_fn+0x24/0x5c)
> >> [   30.997843]  r10: r9:c0b15fe4 r8:c0157eac r7:ee82cd80 
> >> r6:0001 r5:ee82cd80
> >> [   31.005654]  r4:ee00be40
> >> [   31.008185] [] (irq_thread_fn) from [] 
> >> (irq_thread+0x11c/0x19c)
> >> [   31.015825]  r7:ee82cd80 r6:0001 r5:ee4b4000 r4:ee00be40
> >> [   31.021478] [] (irq_thread) from [] 
> >> (kthread+0xfc/0x114)
> >> [   31.028514]  r9: r8: r7:c015802c r6:ee00be40 
> >> r5:ee00be00 r4:
> >> [   31.036246] [] (kthread) from [] 
> >> (ret_from_fork+0x14/0x3c)
> >> [   31.043452]  r7: r6: r5:c01440b8 

Re: DWC3 Gadget backtrace

2017-10-31 Thread Roger Quadros
Felipe,

On 31/10/17 12:24, Felipe Balbi wrote:
> 
> Hi,
> 
> Roger Quadros  writes:
> 
> 
> 
>>> Roger, your PHY is toast :-(
>>>
>>>  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>
>>
>> This is known issue due to operating a HighSpeed PHY in SuperSpeed mode.
>>
>> from dwc3/gadget.c:2015
>>
>> /*
>>  * WORKAROUND: DWC3 revision < 2.20a have an issue
>>  * which would cause metastability state on Run/Stop
>>  * bit if we try to force the IP to USB2-only mode.
>>  *
>>  * Because of that, we cannot configure the IP to any
>>  * speed other than the SuperSpeed
>>  *
>>  * Refers to:
>>  *
>>  * STAR#9000525659: Clock Domain Crossing on DCTL in
>>  * USB 2.0 Mode
>>  */
>> if (dwc->revision < DWC3_REVISION_220A) {
>> reg |= DWC3_DCFG_SUPERSPEED;
>> } else {
>>
>> If we undo this workaround, the Erratic Error messages should go away.
> 
> right, I remember now. It's your call, if you wanna add a flag to ignore
> this STAR ticket, just keep in mind you'd have to cope with possible
> metastability on the Run/Stop bit :-)
> 

Actually AM437x uses rev 2.4a and is not affected by this. There is a problem
with dwc3_gadget_set_speed(). I'll send a fix for it.

We'll still need the flag for TI's DRA7 platform's USB2 instance though.

-- 
cheers,
-roger

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: DWC3 Gadget backtrace

2017-10-31 Thread Felipe Balbi

Hi,

Manu Gautam  writes:
> Hi,
>
> On 10/31/2017 4:12 PM, Felipe Balbi wrote:
>> Hi,
>>
>> Roger Quadros  writes:
>>> On 31/10/17 12:24, Felipe Balbi wrote:
 Hi,

 Roger Quadros  writes:

 

>> Roger, your PHY is toast :-(
>>
>>  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>
> This is known issue due to operating a HighSpeed PHY in SuperSpeed mode.
>
> from dwc3/gadget.c:2015
>
> /*
>  * WORKAROUND: DWC3 revision < 2.20a have an issue
>  * which would cause metastability state on Run/Stop
>  * bit if we try to force the IP to USB2-only mode.
>  *
>  * Because of that, we cannot configure the IP to any
>  * speed other than the SuperSpeed
>  *
>  * Refers to:
>  *
>  * STAR#9000525659: Clock Domain Crossing on DCTL in
>  * USB 2.0 Mode
>  */
> if (dwc->revision < DWC3_REVISION_220A) {
> reg |= DWC3_DCFG_SUPERSPEED;
> } else {
>
> If we undo this workaround, the Erratic Error messages should go away.
 right, I remember now. It's your call, if you wanna add a flag to ignore
 this STAR ticket, just keep in mind you'd have to cope with possible
 metastability on the Run/Stop bit :-)

>>> The TI kernel releases have been ignoring this workaround for quite 
>>> sometime now and
>>> there haven't been any surprises.
>>> I'd be happy to have a flag so I don't have to keep porting a patch around 
>>> :).
>>>
>>> Should I add a DT property?
>>> "snps,dis_metastability_quirk"?
>> Sure, we can send that on the next merge window (v4.15). Just make sure
>> to REALLY make it clear that this is a dangerous flag and should only be
>> enabled if you really, really know what you're doing :-)
>
> If SSPHY is not present on this platform(?) or maximum_speed = HS then we can
> avoid overriding max-speed to SS?

The problem here is that we have a SS controller with a HS-only
PHY. However, dwc3 revision is old enough that it has this erratum about
metasbility state on Run/Stop bit if we try to change maximum operating
speed for the controller.

-- 
balbi


signature.asc
Description: PGP signature


Re: DWC3 Gadget backtrace

2017-10-31 Thread Manu Gautam
Hi,

On 10/31/2017 4:12 PM, Felipe Balbi wrote:
> Hi,
>
> Roger Quadros  writes:
>> On 31/10/17 12:24, Felipe Balbi wrote:
>>> Hi,
>>>
>>> Roger Quadros  writes:
>>>
>>> 
>>>
> Roger, your PHY is toast :-(
>
>  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event 
> (0901): Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event 
> (0901): Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event 
> (0901): Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event 
> (0901): Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event 
> (0901): Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event 
> (0901): Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event 
> (0901): Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event 
> (0901): Erratic Error [U0]
>
 This is known issue due to operating a HighSpeed PHY in SuperSpeed mode.

 from dwc3/gadget.c:2015

 /*
  * WORKAROUND: DWC3 revision < 2.20a have an issue
  * which would cause metastability state on Run/Stop
  * bit if we try to force the IP to USB2-only mode.
  *
  * Because of that, we cannot configure the IP to any
  * speed other than the SuperSpeed
  *
  * Refers to:
  *
  * STAR#9000525659: Clock Domain Crossing on DCTL in
  * USB 2.0 Mode
  */
 if (dwc->revision < DWC3_REVISION_220A) {
 reg |= DWC3_DCFG_SUPERSPEED;
 } else {

 If we undo this workaround, the Erratic Error messages should go away.
>>> right, I remember now. It's your call, if you wanna add a flag to ignore
>>> this STAR ticket, just keep in mind you'd have to cope with possible
>>> metastability on the Run/Stop bit :-)
>>>
>> The TI kernel releases have been ignoring this workaround for quite sometime 
>> now and
>> there haven't been any surprises.
>> I'd be happy to have a flag so I don't have to keep porting a patch around 
>> :).
>>
>> Should I add a DT property?
>> "snps,dis_metastability_quirk"?
> Sure, we can send that on the next merge window (v4.15). Just make sure
> to REALLY make it clear that this is a dangerous flag and should only be
> enabled if you really, really know what you're doing :-)

If SSPHY is not present on this platform(?) or maximum_speed = HS then we can
avoid overriding max-speed to SS?


-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: DWC3 Gadget backtrace

2017-10-31 Thread Felipe Balbi

Hi,

Roger Quadros  writes:
> On 31/10/17 12:24, Felipe Balbi wrote:
>> 
>> Hi,
>> 
>> Roger Quadros  writes:
>> 
>> 
>> 
 Roger, your PHY is toast :-(

  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event 
 (0901): Erratic Error [U0]
  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event 
 (0901): Erratic Error [U0]
  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event 
 (0901): Erratic Error [U0]
  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event 
 (0901): Erratic Error [U0]
  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event 
 (0901): Erratic Error [U0]
  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event 
 (0901): Erratic Error [U0]
  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event 
 (0901): Erratic Error [U0]
  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event 
 (0901): Erratic Error [U0]

>>>
>>> This is known issue due to operating a HighSpeed PHY in SuperSpeed mode.
>>>
>>> from dwc3/gadget.c:2015
>>>
>>> /*
>>>  * WORKAROUND: DWC3 revision < 2.20a have an issue
>>>  * which would cause metastability state on Run/Stop
>>>  * bit if we try to force the IP to USB2-only mode.
>>>  *
>>>  * Because of that, we cannot configure the IP to any
>>>  * speed other than the SuperSpeed
>>>  *
>>>  * Refers to:
>>>  *
>>>  * STAR#9000525659: Clock Domain Crossing on DCTL in
>>>  * USB 2.0 Mode
>>>  */
>>> if (dwc->revision < DWC3_REVISION_220A) {
>>> reg |= DWC3_DCFG_SUPERSPEED;
>>> } else {
>>>
>>> If we undo this workaround, the Erratic Error messages should go away.
>> 
>> right, I remember now. It's your call, if you wanna add a flag to ignore
>> this STAR ticket, just keep in mind you'd have to cope with possible
>> metastability on the Run/Stop bit :-)
>> 
>
> The TI kernel releases have been ignoring this workaround for quite sometime 
> now and
> there haven't been any surprises.
> I'd be happy to have a flag so I don't have to keep porting a patch around :).
>
> Should I add a DT property?
> "snps,dis_metastability_quirk"?

Sure, we can send that on the next merge window (v4.15). Just make sure
to REALLY make it clear that this is a dangerous flag and should only be
enabled if you really, really know what you're doing :-)

-- 
balbi


signature.asc
Description: PGP signature


Re: DWC3 Gadget backtrace

2017-10-31 Thread Roger Quadros
On 31/10/17 12:24, Felipe Balbi wrote:
> 
> Hi,
> 
> Roger Quadros  writes:
> 
> 
> 
>>> Roger, your PHY is toast :-(
>>>
>>>  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event 
>>> (0901): Erratic Error [U0]
>>>
>>
>> This is known issue due to operating a HighSpeed PHY in SuperSpeed mode.
>>
>> from dwc3/gadget.c:2015
>>
>> /*
>>  * WORKAROUND: DWC3 revision < 2.20a have an issue
>>  * which would cause metastability state on Run/Stop
>>  * bit if we try to force the IP to USB2-only mode.
>>  *
>>  * Because of that, we cannot configure the IP to any
>>  * speed other than the SuperSpeed
>>  *
>>  * Refers to:
>>  *
>>  * STAR#9000525659: Clock Domain Crossing on DCTL in
>>  * USB 2.0 Mode
>>  */
>> if (dwc->revision < DWC3_REVISION_220A) {
>> reg |= DWC3_DCFG_SUPERSPEED;
>> } else {
>>
>> If we undo this workaround, the Erratic Error messages should go away.
> 
> right, I remember now. It's your call, if you wanna add a flag to ignore
> this STAR ticket, just keep in mind you'd have to cope with possible
> metastability on the Run/Stop bit :-)
> 

The TI kernel releases have been ignoring this workaround for quite sometime 
now and
there haven't been any surprises.
I'd be happy to have a flag so I don't have to keep porting a patch around :).

Should I add a DT property?
"snps,dis_metastability_quirk"?

-- 
cheers,
-roger

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: DWC3 Gadget backtrace

2017-10-31 Thread Felipe Balbi

Hi,

Roger Quadros  writes:



>> Roger, your PHY is toast :-(
>> 
>>  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event 
>> (0901): Erratic Error [U0]
>>  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event 
>> (0901): Erratic Error [U0]
>> 
>
> This is known issue due to operating a HighSpeed PHY in SuperSpeed mode.
>
> from dwc3/gadget.c:2015
>
> /*
>  * WORKAROUND: DWC3 revision < 2.20a have an issue
>  * which would cause metastability state on Run/Stop
>  * bit if we try to force the IP to USB2-only mode.
>  *
>  * Because of that, we cannot configure the IP to any
>  * speed other than the SuperSpeed
>  *
>  * Refers to:
>  *
>  * STAR#9000525659: Clock Domain Crossing on DCTL in
>  * USB 2.0 Mode
>  */
> if (dwc->revision < DWC3_REVISION_220A) {
> reg |= DWC3_DCFG_SUPERSPEED;
> } else {
>
> If we undo this workaround, the Erratic Error messages should go away.

right, I remember now. It's your call, if you wanna add a flag to ignore
this STAR ticket, just keep in mind you'd have to cope with possible
metastability on the Run/Stop bit :-)

-- 
balbi


signature.asc
Description: PGP signature


Re: DWC3 Gadget backtrace

2017-10-31 Thread Roger Quadros
On 31/10/17 12:05, Felipe Balbi wrote:
> 
> Hi,
> 
> "Howey, Dylan"  writes:
>> Felipe,
>>
>> On 10/30/2017 15:28, Felipe Balbi wrote:
>>>
>>> Hi,
>>>
>>> "Howey, Dylan"  writes:
 Felipe,

 It's also happening in v4.14-rc7.
>>>
>>> Please make sure to also Cc: linux-usb@vger.kernel.org and send
>>> plain-text emails, also avoid top-posting :-)
>>>
 [   59.716702] [ cut here ]
 [   59.721365] WARNING: CPU: 0 PID: 966 at drivers/usb/dwc3/gadget.c:2610 
 dwc3_stop_active_transfer.constprop.4+0xe8/0xec
 [   59.732038] Modules linked in: matrix_keypad
 [   59.736311] CPU: 0 PID: 966 Comm: irq/90-dwc3 Tainted: GW   
 4.14.0-rc7 #3
 [   59.744124] Hardware name: Generic AM43 (Flattened Device Tree)
 [   59.750029] Backtrace:
 [   59.752494] [] (dump_backtrace) from [] 
 (show_stack+0x18/0x1c)
 [   59.760051]  r7:0009 r6: r5:c0889bd0 r4:
 [   59.765707] [] (show_stack) from [] 
 (dump_stack+0x24/0x28)
 [   59.772926] [] (dump_stack) from [] 
 (__warn+0xe8/0x100)
 [   59.779877] [] (__warn) from [] 
 (warn_slowpath_null+0x28/0x30)
 [   59.787433]  r9: r8:a00e0093 r7:0002 r6:0003 
 r5:ee8b7810 r4:ee8bbf00
 [   59.795166] [] (warn_slowpath_null) from [] 
 (dwc3_stop_active_transfer.constprop.4+0xe8/0xec)
 [   59.805413] [] (dwc3_stop_active_transfer.constprop.4) from 
 [] (__dwc3_gadget_ep_disable+0x24/0x110)
 [   59.816259]  r6:ee8b7810 r5:ee8bbf34 r4:ee8bbf00
 [   59.820871] [] (__dwc3_gadget_ep_disable) from [] 
 (dwc3_gadget_ep_disable+0x30/0xac)
 [   59.830332]  r7:0002 r6:ee987638 r5:0001 r4:200e0093
 [   59.835993] [] (dwc3_gadget_ep_disable) from [] 
 (usb_ep_disable+0x30/0x3c)
 [   59.844585]  r5:0001 r4:ee8bbf00
 [   59.848158] [] (usb_ep_disable) from [] 
 (ffs_func_eps_disable+0x50/0x78)
 [   59.856576]  r5:0001 r4:ef0cfc80
 [   59.860145] [] (ffs_func_eps_disable) from [] 
 (ffs_func_set_alt+0x90/0x290)
 [   59.868827]  r9:5533194a r8:55332309 r7:ee98b254 r6: 
 r5:200e0093 r4:ee1f5e64
 [   59.876556] [] (ffs_func_set_alt) from [] 
 (ffs_func_disable+0x18/0x1c)
 [   59.884805]  r10:ee9f3d14 r9:5533194a r8:55332309 r7:ee98b254 
 r6: r5:200e0093
 [   59.892615]  r4:ee1f5e64
 [   59.895145] [] (ffs_func_disable) from [] 
 (composite_disconnect+0x4c/0x94)
>>>
>>> okay, so you're using ffs. I see you're implementing your own HID gadget
>>> on top of FFS. Could it be you have a bug there? Why not use the in-tree
>>> HID function? Can you capture dwc3 logs? More details here:
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/usb/dwc3.rst#n113
>>>
>>
>> This implementation works on an AM335x platform.
> 
> that really doesn't mean much :-) Different controller will behave
> completely differently when it comes to transfer cancellation.
> 
>> I should add that the host is Linux v4.4.0 on x86_64. I have not tried any
>> other host yet.
> 
> okay.
> 
> 
>> Attached the dwc3 logs as instructed.
> 
> Thank you.
> 
> (in below logs, I've removed register access traces to make it easier to read)
> 
> Roger, your PHY is toast :-(
> 
>  irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event (0901): 
> Erratic Error [U0]
>  irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event (0901): 
> Erratic Error [U0]
> 

This is known issue due to operating a HighSpeed PHY in SuperSpeed mode.

from dwc3/gadget.c:2015

/*
 * WORKAROUND: DWC3 revision < 2.20a have an issue
 * which would cause metastability state on Run/Stop
 * bit if we try to force the IP to USB2-only mode.
 *
 * Because of that, we cannot configure the IP to any
 * speed other than the SuperSpeed
 *
 * Refers to:
 *
 * STAR#9000525659: Clock Domain Crossing on DCTL in
 * USB 2.0 Mode
 */
if (dwc->revision < DWC3_REVISION_220A) {
reg |= DWC3_DCFG_SUPERSPEED;
} else {

If we undo this workaround, the Erratic Error messages should go away.

> Seems like your FFS HID is missing Data phase for this clear feature
> 

Re: DWC3 Gadget backtrace

2017-10-31 Thread Felipe Balbi

Hi,

"Howey, Dylan"  writes:
> Felipe,
>
> On 10/30/2017 15:28, Felipe Balbi wrote:
>> 
>> Hi,
>> 
>> "Howey, Dylan"  writes:
>> > Felipe,
>> >
>> > It's also happening in v4.14-rc7.
>> 
>> Please make sure to also Cc: linux-usb@vger.kernel.org and send
>> plain-text emails, also avoid top-posting :-)
>> 
>> > [   59.716702] [ cut here ]
>> > [   59.721365] WARNING: CPU: 0 PID: 966 at drivers/usb/dwc3/gadget.c:2610 
>> > dwc3_stop_active_transfer.constprop.4+0xe8/0xec
>> > [   59.732038] Modules linked in: matrix_keypad
>> > [   59.736311] CPU: 0 PID: 966 Comm: irq/90-dwc3 Tainted: GW   
>> > 4.14.0-rc7 #3
>> > [   59.744124] Hardware name: Generic AM43 (Flattened Device Tree)
>> > [   59.750029] Backtrace:
>> > [   59.752494] [] (dump_backtrace) from [] 
>> > (show_stack+0x18/0x1c)
>> > [   59.760051]  r7:0009 r6: r5:c0889bd0 r4:
>> > [   59.765707] [] (show_stack) from [] 
>> > (dump_stack+0x24/0x28)
>> > [   59.772926] [] (dump_stack) from [] 
>> > (__warn+0xe8/0x100)
>> > [   59.779877] [] (__warn) from [] 
>> > (warn_slowpath_null+0x28/0x30)
>> > [   59.787433]  r9: r8:a00e0093 r7:0002 r6:0003 
>> > r5:ee8b7810 r4:ee8bbf00
>> > [   59.795166] [] (warn_slowpath_null) from [] 
>> > (dwc3_stop_active_transfer.constprop.4+0xe8/0xec)
>> > [   59.805413] [] (dwc3_stop_active_transfer.constprop.4) from 
>> > [] (__dwc3_gadget_ep_disable+0x24/0x110)
>> > [   59.816259]  r6:ee8b7810 r5:ee8bbf34 r4:ee8bbf00
>> > [   59.820871] [] (__dwc3_gadget_ep_disable) from [] 
>> > (dwc3_gadget_ep_disable+0x30/0xac)
>> > [   59.830332]  r7:0002 r6:ee987638 r5:0001 r4:200e0093
>> > [   59.835993] [] (dwc3_gadget_ep_disable) from [] 
>> > (usb_ep_disable+0x30/0x3c)
>> > [   59.844585]  r5:0001 r4:ee8bbf00
>> > [   59.848158] [] (usb_ep_disable) from [] 
>> > (ffs_func_eps_disable+0x50/0x78)
>> > [   59.856576]  r5:0001 r4:ef0cfc80
>> > [   59.860145] [] (ffs_func_eps_disable) from [] 
>> > (ffs_func_set_alt+0x90/0x290)
>> > [   59.868827]  r9:5533194a r8:55332309 r7:ee98b254 r6: 
>> > r5:200e0093 r4:ee1f5e64
>> > [   59.876556] [] (ffs_func_set_alt) from [] 
>> > (ffs_func_disable+0x18/0x1c)
>> > [   59.884805]  r10:ee9f3d14 r9:5533194a r8:55332309 r7:ee98b254 
>> > r6: r5:200e0093
>> > [   59.892615]  r4:ee1f5e64
>> > [   59.895145] [] (ffs_func_disable) from [] 
>> > (composite_disconnect+0x4c/0x94)
>> 
>> okay, so you're using ffs. I see you're implementing your own HID gadget
>> on top of FFS. Could it be you have a bug there? Why not use the in-tree
>> HID function? Can you capture dwc3 logs? More details here:
>> 
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/usb/dwc3.rst#n113
>> 
>
> This implementation works on an AM335x platform.

that really doesn't mean much :-) Different controller will behave
completely differently when it comes to transfer cancellation.

> I should add that the host is Linux v4.4.0 on x86_64. I have not tried any
> other host yet.

okay.


> Attached the dwc3 logs as instructed.

Thank you.

(in below logs, I've removed register access traces to make it easier to read)

Roger, your PHY is toast :-(

 irq/90-dwc3-969   [000] d...52.323145: dwc3_event: event (0901): 
Erratic Error [U0]
 irq/90-dwc3-969   [000] d...52.560646: dwc3_event: event (0901): 
Erratic Error [U0]
 irq/90-dwc3-969   [000] d...52.798144: dwc3_event: event (0901): 
Erratic Error [U0]
 irq/90-dwc3-969   [000] d...53.035646: dwc3_event: event (0901): 
Erratic Error [U0]
 irq/90-dwc3-969   [000] d...53.273143: dwc3_event: event (0901): 
Erratic Error [U0]
 irq/90-dwc3-969   [000] d...53.510657: dwc3_event: event (0901): 
Erratic Error [U0]
 irq/90-dwc3-969   [000] d...53.748142: dwc3_event: event (0901): 
Erratic Error [U0]
 irq/90-dwc3-969   [000] d...53.985640: dwc3_event: event (0901): 
Erratic Error [U0]

Seems like your FFS HID is missing Data phase for this clear feature
request. Either that, or should stall this unknown interface feature

(and seems like I need to figure out a way to add the raw value to the
trace)

 irq/90-dwc3-969   [000] d...54.372175: dwc3_ctrl_req: Clear Interface 
Feature(UNKNOWN)
 irq/90-dwc3-969   [000] d...54.372186: dwc3_event: event (10c2): 
ep0in: Transfer Not Ready (Not Active) [Data Phase]
  UI_Touchscreen-963   [000] d...54.372437: dwc3_ep_queue: ep1in: req 
ee268c00 length 0/64 zsI ==> -115
  UI_Touchscreen-963   [000] d...54.372451: dwc3_prepare_trb: ep1in: 1/1 
trb f0a27000 buf a9409580 size 64 ctrl 0811 (Hlcs:sC:normal)
  UI_Touchscreen-963   [000] d...54.372468: dwc3_gadget_ep_cmd: ep1in: cmd 
'Start Transfer' [1030] params  be844000  --> status: Successful
  UI_Touchscreen-965   [000] d...54.393628: dwc3_ep_queue: 

Re: DWC3 Gadget backtrace

2017-10-31 Thread Roger Quadros
Hi Dylan,

On 30/10/17 10:59, Felipe Balbi wrote:
> 
> Hi,
> 
> "Howey, Dylan"  writes:
>> Hello,
>>
>> I'm on an AM437x platform and I'm using FunctionFS to create a HID
>> gadget. The device enumerates correctly when I plug it into a Linux
>> host. If I unplug the cord and then plug it in again, I get a
>> backtrace from dwc3, and the device fails to enumerate.
>>
>> I'm on ti-linux-4.9.y, but I see the same issue with 4.9.40 from
>> kernel.org.
>>
>> Is this a known issue, and is there a workaround or a fix available?
> 
> sorry, you need to ask help from TI. Either that, or test current
> mainline (v4.14-rc7) and let me know if the same problem is there.
> 
> BTW, latest v4.9 stable is v4.9.58, not v4.9.40.
> 
> 
> Adding Roger Quadros here who works for TI and can, perhaps, point you
> in the right direction.

I couldn't reproduce the problem with g_zero or with configfs based ethernet 
(ECM)
so I'm suspecting something is not going well with the ffs based HID solution.

Do you have a known good kernel version where the ffs based HID solution works?
If there is such a kernel then could you please share the ffs-HID solution so I 
can try it at my end?

> 
> Best
> 
>> [   30.746934] [ cut here ]
>> [   30.751587] WARNING: CPU: 0 PID: 947 at drivers/usb/dwc3/gadget.c:2303 
>> dwc3_stop_active_transfer.constprop.5+0xd4/0xd8
>> [   30.762259] Modules linked in: matrix_keypad
>> [   30.766539] CPU: 0 PID: 947 Comm: irq/90-dwc3 Not tainted 
>> 4.9.40-02118-gde0a93a #4
>> [   30.774092] Hardware name: Generic AM43 (Flattened Device Tree)
>> [   30.779996] Backtrace:
>> [   30.782465] [] (dump_backtrace) from [] 
>> (show_stack+0x18/0x1c)
>> [   30.790020]  r7:0009 r6: r5:c0899298 r4:
>> [   30.795679] [] (show_stack) from [] 
>> (dump_stack+0x24/0x28)
>> [   30.802903] [] (dump_stack) from [] 
>> (__warn+0xe8/0x100)
>> [   30.809857] [] (__warn) from [] 
>> (warn_slowpath_null+0x28/0x30)
>> [   30.817413]  r9:55332309 r8:a093 r7: r6:ee82a010 r5:0003 
>> r4:ee82c900
>> [   30.825147] [] (warn_slowpath_null) from [] 
>> (dwc3_stop_active_transfer.constprop.5+0xd4/0xd8)
>> [   30.835393] [] (dwc3_stop_active_transfer.constprop.5) from 
>> [] (dwc3_remove_requests+0x1c/0x98)
>> [   30.845805]  r6:ee82a010 r5:ee82c934 r4:ee82c900
>> [   30.850415] [] (dwc3_remove_requests) from [] 
>> (__dwc3_gadget_ep_disable+0x38/0xdc)
>> [   30.859700]  r5:ee9b13f8 r4:ee82c900
>> [   30.863271] [] (__dwc3_gadget_ep_disable) from [] 
>> (dwc3_gadget_ep_disable+0x30/0xac)
>> [   30.872731]  r7: r6:0002 r5:ee9b13f8 r4:2093
>> [   30.878387] [] (dwc3_gadget_ep_disable) from [] 
>> (usb_ep_disable+0x30/0x3c)
>> [   30.886979]  r5:ee9b13f8 r4:ee82c900
>> [   30.890557] [] (usb_ep_disable) from [] 
>> (ffs_func_eps_disable+0x40/0x64)
>> [   30.898975]  r5:ee9b13f8 r4:ee7c8280
>> [   30.902547] [] (ffs_func_eps_disable) from [] 
>> (ffs_func_set_alt+0x90/0x288)
>> [   30.911229]  r9:55332309 r8:55332509 r7:ee018e54 r6: r5: 
>> r4:ee0271a4
>> [   30.918960] [] (ffs_func_set_alt) from [] 
>> (ffs_func_disable+0x18/0x1c)
>> [   30.927211]  r10:55331839 r9:55332309 r8:55332509 r7:ee018e54 r6: 
>> r5:2093
>> [   30.935021]  r4:ee0271a4
>> [   30.937562] [] (ffs_func_disable) from [] 
>> (composite_disconnect+0x4c/0x94)
>> [   30.946160] [] (composite_disconnect) from [] 
>> (usb_gadget_udc_reset+0x18/0x3c)
>> [   30.955101]  r7:ee82cd80 r6:ee82a010 r5:0004 r4:ee82a160
>> [   30.960752] [] (usb_gadget_udc_reset) from [] 
>> (dwc3_gadget_reset_interrupt+0x60/0x1d0)
>> [   30.970383]  r5:0004 r4:ee8251d0
>> [   30.973953] [] (dwc3_gadget_reset_interrupt) from [] 
>> (dwc3_thread_interrupt+0x220/0xaa8)
>> [   30.983759]  r7:ee82cd80 r6:ee82a010 r5:0004 r4:ee8251d0
>> [   30.989421] [] (dwc3_thread_interrupt) from [] 
>> (irq_thread_fn+0x24/0x5c)
>> [   30.997843]  r10: r9:c0b15fe4 r8:c0157eac r7:ee82cd80 r6:0001 
>> r5:ee82cd80
>> [   31.005654]  r4:ee00be40
>> [   31.008185] [] (irq_thread_fn) from [] 
>> (irq_thread+0x11c/0x19c)
>> [   31.015825]  r7:ee82cd80 r6:0001 r5:ee4b4000 r4:ee00be40
>> [   31.021478] [] (irq_thread) from [] 
>> (kthread+0xfc/0x114)
>> [   31.028514]  r9: r8: r7:c015802c r6:ee00be40 r5:ee00be00 
>> r4:
>> [   31.036246] [] (kthread) from [] 
>> (ret_from_fork+0x14/0x3c)
>> [   31.043452]  r7: r6: r5:c01440b8 r4:ee00be00
>> [   31.049096] ---[ end trace 612f02bb50d0379b ]---
> 

-- 
cheers,
-roger

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: DWC3 Gadget backtrace

2017-10-30 Thread Howey, Dylan
Felipe,

On 10/30/2017 15:28, Felipe Balbi wrote:
> 
> Hi,
> 
> "Howey, Dylan" <dylan.ho...@tennantco.com> writes:
> > Felipe,
> >
> > It's also happening in v4.14-rc7.
> 
> Please make sure to also Cc: linux-usb@vger.kernel.org and send
> plain-text emails, also avoid top-posting :-)
> 
> > [   59.716702] [ cut here ]
> > [   59.721365] WARNING: CPU: 0 PID: 966 at drivers/usb/dwc3/gadget.c:2610 
> > dwc3_stop_active_transfer.constprop.4+0xe8/0xec
> > [   59.732038] Modules linked in: matrix_keypad
> > [   59.736311] CPU: 0 PID: 966 Comm: irq/90-dwc3 Tainted: GW   
> > 4.14.0-rc7 #3
> > [   59.744124] Hardware name: Generic AM43 (Flattened Device Tree)
> > [   59.750029] Backtrace:
> > [   59.752494] [] (dump_backtrace) from [] 
> > (show_stack+0x18/0x1c)
> > [   59.760051]  r7:0009 r6: r5:c0889bd0 r4:
> > [   59.765707] [] (show_stack) from [] 
> > (dump_stack+0x24/0x28)
> > [   59.772926] [] (dump_stack) from [] 
> > (__warn+0xe8/0x100)
> > [   59.779877] [] (__warn) from [] 
> > (warn_slowpath_null+0x28/0x30)
> > [   59.787433]  r9: r8:a00e0093 r7:0002 r6:0003 r5:ee8b7810 
> > r4:ee8bbf00
> > [   59.795166] [] (warn_slowpath_null) from [] 
> > (dwc3_stop_active_transfer.constprop.4+0xe8/0xec)
> > [   59.805413] [] (dwc3_stop_active_transfer.constprop.4) from 
> > [] (__dwc3_gadget_ep_disable+0x24/0x110)
> > [   59.816259]  r6:ee8b7810 r5:ee8bbf34 r4:ee8bbf00
> > [   59.820871] [] (__dwc3_gadget_ep_disable) from [] 
> > (dwc3_gadget_ep_disable+0x30/0xac)
> > [   59.830332]  r7:0002 r6:ee987638 r5:0001 r4:200e0093
> > [   59.835993] [] (dwc3_gadget_ep_disable) from [] 
> > (usb_ep_disable+0x30/0x3c)
> > [   59.844585]  r5:0001 r4:ee8bbf00
> > [   59.848158] [] (usb_ep_disable) from [] 
> > (ffs_func_eps_disable+0x50/0x78)
> > [   59.856576]  r5:0001 r4:ef0cfc80
> > [   59.860145] [] (ffs_func_eps_disable) from [] 
> > (ffs_func_set_alt+0x90/0x290)
> > [   59.868827]  r9:5533194a r8:55332309 r7:ee98b254 r6: r5:200e0093 
> > r4:ee1f5e64
> > [   59.876556] [] (ffs_func_set_alt) from [] 
> > (ffs_func_disable+0x18/0x1c)
> > [   59.884805]  r10:ee9f3d14 r9:5533194a r8:55332309 r7:ee98b254 
> > r6: r5:200e0093
> > [   59.892615]  r4:ee1f5e64
> > [   59.895145] [] (ffs_func_disable) from [] 
> > (composite_disconnect+0x4c/0x94)
> 
> okay, so you're using ffs. I see you're implementing your own HID gadget
> on top of FFS. Could it be you have a bug there? Why not use the in-tree
> HID function? Can you capture dwc3 logs? More details here:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/usb/dwc3.rst#n113
> 

This implementation works on an AM335x platform.

I should add that the host is Linux v4.4.0 on x86_64. I have not tried any
other host yet.

Attached the dwc3 logs as instructed.

> > [   59.903742] [] (composite_disconnect) from [] 
> > (usb_gadget_udc_reset+0x18/0x3c)
> > [   59.912683]  r7:55332509 r6:ee8b7810 r5:0004 r4:ee8b7978
> > [   59.918334] [] (usb_gadget_udc_reset) from [] 
> > (dwc3_gadget_reset_interrupt+0x60/0x128)
> > [   59.927966]  r5:0004 r4:ee8ba9d0
> > [   59.931535] [] (dwc3_gadget_reset_interrupt) from [] 
> > (dwc3_thread_interrupt+0x3ac/0x830)
> > [   59.941342]  r7:55332509 r6:ee8b7810 r5:0004 r4:ee8ba9d0
> > [   59.947002] [] (dwc3_thread_interrupt) from [] 
> > (irq_thread_fn+0x24/0x5c)
> > [   59.955424]  r10:ee9f3d14 r9:c0a44a71 r8:c0156da8 r7:ef20f200 
> > r6:0001 r5:ef20f200
> > [   59.963234]  r4:ee1fcec0
> > [   59.965764] [] (irq_thread_fn) from [] 
> > (irq_thread+0x11c/0x19c)
> > [   59.973404]  r7:ef20f200 r6:0001 r5:ee9a4000 r4:ee1fcec0
> > [   59.979067] [] (irq_thread) from [] 
> > (kthread+0x128/0x158)
> > [   59.986190]  r9:ee1fce18 r8:c0156f28 r7:ee1fcec0 r6:ee1fce80 r5: 
> > r4:ee1fce00
> > [   59.993922] [] (kthread) from [] 
> > (ret_from_fork+0x14/0x24)
> > [   60.001129]  r10: r9: r8: r7: 
> > r6: r5:c0141cac
> > [   60.008941]  r4:ee1fce80 r3:ee9a4000
> > [   60.012505] ---[ end trace 5159dae85b75ffe4 ]---
> > 
> > From: Felipe Balbi <felipe.ba...@linux.intel.com>
> > Sent: Monday, October 30, 2017 3:59 AM
> > To: Howey, Dylan
> > Cc: Roger Quadros
> > Subject: Re: DWC3 Gadget backtrace
> >
> >
> > Hi,
> >
> > "Howey, Dylan" <

Re: DWC3 Gadget backtrace

2017-10-30 Thread Felipe Balbi

Hi,

"Howey, Dylan" <dylan.ho...@tennantco.com> writes:
> Felipe,
>
> It's also happening in v4.14-rc7.

Please make sure to also Cc: linux-usb@vger.kernel.org and send
plain-text emails, also avoid top-posting :-)

> [   59.716702] [ cut here ]
> [   59.721365] WARNING: CPU: 0 PID: 966 at drivers/usb/dwc3/gadget.c:2610 
> dwc3_stop_active_transfer.constprop.4+0xe8/0xec
> [   59.732038] Modules linked in: matrix_keypad
> [   59.736311] CPU: 0 PID: 966 Comm: irq/90-dwc3 Tainted: GW   
> 4.14.0-rc7 #3
> [   59.744124] Hardware name: Generic AM43 (Flattened Device Tree)
> [   59.750029] Backtrace:
> [   59.752494] [] (dump_backtrace) from [] 
> (show_stack+0x18/0x1c)
> [   59.760051]  r7:0009 r6: r5:c0889bd0 r4:
> [   59.765707] [] (show_stack) from [] 
> (dump_stack+0x24/0x28)
> [   59.772926] [] (dump_stack) from [] (__warn+0xe8/0x100)
> [   59.779877] [] (__warn) from [] 
> (warn_slowpath_null+0x28/0x30)
> [   59.787433]  r9: r8:a00e0093 r7:0002 r6:0003 r5:ee8b7810 
> r4:ee8bbf00
> [   59.795166] [] (warn_slowpath_null) from [] 
> (dwc3_stop_active_transfer.constprop.4+0xe8/0xec)
> [   59.805413] [] (dwc3_stop_active_transfer.constprop.4) from 
> [] (__dwc3_gadget_ep_disable+0x24/0x110)
> [   59.816259]  r6:ee8b7810 r5:ee8bbf34 r4:ee8bbf00
> [   59.820871] [] (__dwc3_gadget_ep_disable) from [] 
> (dwc3_gadget_ep_disable+0x30/0xac)
> [   59.830332]  r7:0002 r6:ee987638 r5:0001 r4:200e0093
> [   59.835993] [] (dwc3_gadget_ep_disable) from [] 
> (usb_ep_disable+0x30/0x3c)
> [   59.844585]  r5:0001 r4:ee8bbf00
> [   59.848158] [] (usb_ep_disable) from [] 
> (ffs_func_eps_disable+0x50/0x78)
> [   59.856576]  r5:0001 r4:ef0cfc80
> [   59.860145] [] (ffs_func_eps_disable) from [] 
> (ffs_func_set_alt+0x90/0x290)
> [   59.868827]  r9:5533194a r8:55332309 r7:ee98b254 r6: r5:200e0093 
> r4:ee1f5e64
> [   59.876556] [] (ffs_func_set_alt) from [] 
> (ffs_func_disable+0x18/0x1c)
> [   59.884805]  r10:ee9f3d14 r9:5533194a r8:55332309 r7:ee98b254 r6: 
> r5:200e0093
> [   59.892615]  r4:ee1f5e64
> [   59.895145] [] (ffs_func_disable) from [] 
> (composite_disconnect+0x4c/0x94)

okay, so you're using ffs. I see you're implementing your own HID gadget
on top of FFS. Could it be you have a bug there? Why not use the in-tree
HID function? Can you capture dwc3 logs? More details here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/usb/dwc3.rst#n113

> [   59.903742] [] (composite_disconnect) from [] 
> (usb_gadget_udc_reset+0x18/0x3c)
> [   59.912683]  r7:55332509 r6:ee8b7810 r5:0004 r4:ee8b7978
> [   59.918334] [] (usb_gadget_udc_reset) from [] 
> (dwc3_gadget_reset_interrupt+0x60/0x128)
> [   59.927966]  r5:0004 r4:ee8ba9d0
> [   59.931535] [] (dwc3_gadget_reset_interrupt) from [] 
> (dwc3_thread_interrupt+0x3ac/0x830)
> [   59.941342]  r7:55332509 r6:ee8b7810 r5:0004 r4:ee8ba9d0
> [   59.947002] [] (dwc3_thread_interrupt) from [] 
> (irq_thread_fn+0x24/0x5c)
> [   59.955424]  r10:ee9f3d14 r9:c0a44a71 r8:c0156da8 r7:ef20f200 r6:0001 
> r5:ef20f200
> [   59.963234]  r4:ee1fcec0
> [   59.965764] [] (irq_thread_fn) from [] 
> (irq_thread+0x11c/0x19c)
> [   59.973404]  r7:ef20f200 r6:0001 r5:ee9a4000 r4:ee1fcec0
> [   59.979067] [] (irq_thread) from [] 
> (kthread+0x128/0x158)
> [   59.986190]  r9:ee1fce18 r8:c0156f28 r7:ee1fcec0 r6:ee1fce80 r5: 
> r4:ee1fce00
> [   59.993922] [] (kthread) from [] 
> (ret_from_fork+0x14/0x24)
> [   60.001129]  r10: r9: r8: r7: r6: 
> r5:c0141cac
> [   60.008941]  r4:ee1fce80 r3:ee9a4000
> [   60.012505] ---[ end trace 5159dae85b75ffe4 ]---
> 
> From: Felipe Balbi <felipe.ba...@linux.intel.com>
> Sent: Monday, October 30, 2017 3:59 AM
> To: Howey, Dylan
> Cc: Roger Quadros
> Subject: Re: DWC3 Gadget backtrace
>
>
> Hi,
>
> "Howey, Dylan" <dylan.ho...@tennantco.com> writes:
>> Hello,
>>
>> I'm on an AM437x platform and I'm using FunctionFS to create a HID
>> gadget. The device enumerates correctly when I plug it into a Linux
>> host. If I unplug the cord and then plug it in again, I get a
>> backtrace from dwc3, and the device fails to enumerate.
>>
>> I'm on ti-linux-4.9.y, but I see the same issue with 4.9.40 from
>> kernel.org.
>>
>> Is this a known issue, and is there a workaround or a fix available?
>
> sorry, you need to ask help from TI. Either that, or test current
> mainline (v4.14-rc7) and let me know if the same problem is there.
>
> BTW, latest v4.9 stable is